projetAcoBDDv30.03.26

This commit is contained in:
Aco
2026-03-30 16:10:26 +02:00
parent fedbf51c91
commit 455eee67f7
42 changed files with 2018 additions and 0 deletions

View File

View File

@@ -0,0 +1,44 @@
<?php
$db_name = "gamesdb" ; // Nom de la base de données (pré-existante)
$db_host = "127.0.0.1" ; // Si le serveur MySQL est sur la machine locale
$db_port = "3306" ; // Port par défaut de MySQL
// Informations d'authentification de votre script PHP
$db_user = "gameuse" ; // Utilisateur par défaut de MySQL (... à changer)
$db_pwd = "MyStrongPassword123!" ; // Mot de passe par défaut pour l'utilisateur root (.. à changer !!!)
//GRANT ALL PRIVILEGES ON gamesdb.* TO 'gameuse'@'localhost';
//gameuse'@'localhost'
//MyStrongPassword123
// Connexion à la BDD
//j'ai fabriquer cet utilisateur spécialement pour cette exo sur le serv
//mysql
// Connexion à la BDD
// Connexion à la BDD
try{
// Agrégation des informations de connexion dans une chaine DSN (Data Source Name)
$dsn = 'mysql:dbname=' . $db_name . ';host='. $db_host. ';port=' . $db_port;
// Connexion et récupération de l'objet connecté
$pdo = new PDO($dsn, $db_user, $db_pwd);
}
// Récupération d'une éventuelle erreur
catch (\Exception $ex){ ?>
<!-- Affichage des informations liées à l'erreur-->
<div style="color: red">
<b>!!! ERREUR DE CONNEXION !!!</b><br>
Code : <?= $ex->getCode() ?><br>
Message : <?= $ex->getMessage() ?>
</div><?php
// Arrêt de l'exécution du script PHP
die("-> Exécution stoppée <-") ;
}
// Poursuite de l'exécution du script ?>
<div style="color: green">Connecté à <b><?= $dsn ?></b></div> <?php ?>

View File

@@ -0,0 +1,156 @@
-- MySQL dump 10.13 Distrib 5.5.27, for Win64 (x86)
--
-- Host: localhost Database: cinema
-- ------------------------------------------------------
-- Server version 5.5.27
-- note pour l'execution, 'sur mon ordinateur personnel' dans le terminal
-- sudo mysql --local-infile=1 -p < codemysql/basedonneee.sql (obliger de sudo pour que ca marche sur mon ordi perso)
-- et aussi sudo mysql -p pour juste lancer
-- comment faire tourner mon code sur workbench
-- j'ai modifier les chemins des loads data
-- pour utiliser un chemin relatif* (car chemin relatif ne marche pas dans
-- workbench, mais fonctionne dans les fichiers de script. (il doit y avoir une option pour sur WB)
DROP DATABASE IF EXISTS siterecette;
CREATE DATABASE siterecette;
DROP USER IF EXISTS 'admin'@'localhost';
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'adminpass123';
GRANT ALL PRIVILEGES ON siterecette.* TO 'admin'@'localhost';
USE siterecette;
--
-- Table structure for table acteur
--
DROP TABLE IF EXISTS Recette;
CREATE TABLE Recette (
num_recette INT NOT NULL,
titre_recette VARCHAR(60) NOT NULL,
slug VARCHAR(200) NOT NULL,
description_recette VARCHAR(1000) NOT NULL,
photo VARCHAR(200) NOT NULL,
publication_date DATE NOT NULL,
temps_de_preparation INT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Table structure for table realisateur
--
DROP TABLE IF EXISTS Tag;
CREATE TABLE Tag (
num_tag INT NOT NULL,
nom_tag VARCHAR(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Table structure for table salle
--
DROP TABLE IF EXISTS Ingredient;
CREATE TABLE Ingredient (
num_ingredient INT NOT NULL,
nom_ingredient INT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Table structure for table film
--
DROP TABLE IF EXISTS Listeingredient;
CREATE TABLE Listeingredient (
num_recette INT NOT NULL,
num_ingredient INT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Table structure for table projection
--
DROP TABLE IF EXISTS Referencetag;
CREATE TABLE Referencetag (
num_recette INT NOT NULL,
num_tag INT NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS User;
CREATE TABLE User (
num_user INT NOT NULL,
username VARCHAR(20) NOT NULL,
userpassword VARCHAR(60) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- CONTRAINTES
--
-- en utilisant les 'alter table' sinon on peut directement les specifier dans les create table
ALTER TABLE Recette
ADD CONSTRAINT pk_recette PRIMARY KEY (num_recette);
ALTER TABLE Ingredient
ADD CONSTRAINT pk_ingredient PRIMARY KEY (num_ingredient);
ALTER TABLE Tag
ADD CONSTRAINT pk_tag PRIMARY KEY (num_tag);
ALTER TABLE User
ADD CONSTRAINT pk_user PRIMARY KEY (num_user);
ALTER TABLE Listeingredient
ADD CONSTRAINT fk_numrecette_ingredient FOREIGN KEY (num_recette) REFERENCES Recette (num_recette),
ADD CONSTRAINT fk_recette_numingredient FOREIGN KEY (num_ingredient) REFERENCES Ingredient (num_ingredient);
ALTER TABLE Referencetag
ADD CONSTRAINT fk_numrecette_tag FOREIGN KEY (num_recette) REFERENCES Recette (num_recette),
ADD CONSTRAINT fk_recette_numtag FOREIGN KEY (num_tag) REFERENCES Tag (num_tag);
-- si besoin exemple de chargement csv
-- LOAD DATA LOCAL INFILE 'nom.csv'
-- INTO TABLE nom
-- FIELDS TERMINATED BY ','
-- ENCLOSED BY '"'
-- LINES TERMINATED BY '\n'
-- IGNORE 1 ROWS;
-- les chemin ./filename.csv ne marche que dans le terminal avec le cli mysql via la commande $
-- select * from column;
INSERT INTO Recette (num_recette,titre_recette,slug,description_recette,photo,publication_date,temps_de_preparation)
values(1,"nomdrecette","slugdpage","descriptiondrecette","urldephoto",'2023-12-31',500),
(2,"nomdrecette","slugdpage","descriptiondrecette","urldephoto",'2023-12-31',500),
(3,"nomdrecette","slugdpage","descriptiondrecette","urldephoto",'2023-12-31',500);
-- select * from Recette;
-- INSERT INTO Tag (num_tag,nom_tag)
-- values(1,"nomdtag");
-- INSERT INTO Referencetag(num_recette, num_tag)
-- values(1,1);
-- INSERT INTO Ingredient(num_ingredient,nom_ingredient)
-- values(2,2);
-- INSERT INTO Listeingredient(num_recette,num_ingredient)
-- values(1,2);

View File

@@ -0,0 +1,16 @@
quand on créer une recette
(le but c'est que quand on en créer une
on est en même temps au moins une instance d'association
qui enregistre cette recette et ses ingrédients simultanément
de manière obligatoire)
idée 1 : on ignore l'obligation d'associer une liste d'ingredients a une recette à sa création.
idée 2 : les ingredients d'une liste d'ingredients qui est associés a une recette sont représenter comme une suite de caractère en une ligne séparer par des espace ce qui ferait un seul élément respectant la normalisation 2NF
idée 3 : ajouter des règles de contraintes à la créations d'une recette par exemple quand on créer une recette il faut que ...
soit dans la base de données soit juste dans le backend
idée ... :

45
basededonnee/entité.txt Normal file
View File

@@ -0,0 +1,45 @@
recettes ID
Titre
Slug
Description
Photo
Date d'ajout
liste-recettes (entités)
-Id listerecettes
Recette-Ingrédients
ID_Recette
ID_Ingrédient
Recette-Tags
ID_Recette
ID_Tag
Ingrédients
ID
Nom
Image
Tag
ID
Nom
Utilisateurs
ID
Username
MDP (Hashé, bien entendu...)
. Permission (utilisateurs)

103
basededonnee/test.drawio Normal file
View File

@@ -0,0 +1,103 @@
<mxfile host="65bd71144e">
<diagram id="i3f546belnF2-wjsbEOy" name="Page-1">
<mxGraphModel dx="1489" dy="755" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="2" value="Recette" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=none;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" vertex="1" parent="1">
<mxGeometry x="300" y="232" width="170" height="182" as="geometry"/>
</mxCell>
<mxCell id="3" value="(PK)idrecette" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="2">
<mxGeometry y="26" width="170" height="26" as="geometry"/>
</mxCell>
<mxCell id="4" value="titrerecette varchar(60)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="2">
<mxGeometry y="52" width="170" height="26" as="geometry"/>
</mxCell>
<mxCell id="14" value="slug varchar(200) (idweb)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="2">
<mxGeometry y="78" width="170" height="26" as="geometry"/>
</mxCell>
<mxCell id="15" value="Description varchar(1000)&amp;nbsp;" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="2">
<mxGeometry y="104" width="170" height="26" as="geometry"/>
</mxCell>
<mxCell id="16" value="photo (url) varchar(200)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="2">
<mxGeometry y="130" width="170" height="26" as="geometry"/>
</mxCell>
<mxCell id="17" value="publicationdate DATE" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="2">
<mxGeometry y="156" width="170" height="26" as="geometry"/>
</mxCell>
<mxCell id="6" value="Referencetag" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=none;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" vertex="1" parent="1">
<mxGeometry x="140" y="320" width="111" height="78" as="geometry"/>
</mxCell>
<mxCell id="8" value="(FK)idrecette" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="6">
<mxGeometry y="26" width="111" height="26" as="geometry"/>
</mxCell>
<mxCell id="9" value="(FK)idtag" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="6">
<mxGeometry y="52" width="111" height="26" as="geometry"/>
</mxCell>
<mxCell id="10" value="Tag" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=none;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" vertex="1" parent="1">
<mxGeometry x="-60" y="340" width="121" height="78" as="geometry"/>
</mxCell>
<mxCell id="11" value="(PK)idtag" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="10">
<mxGeometry y="26" width="121" height="26" as="geometry"/>
</mxCell>
<mxCell id="19" value="nomtag varchar(30)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="10">
<mxGeometry y="52" width="121" height="26" as="geometry"/>
</mxCell>
<mxCell id="23" value="" style="endArrow=none;html=1;exitX=1;exitY=0;exitDx=0;exitDy=0;entryX=0;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="10" target="6">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="360" y="410" as="sourcePoint"/>
<mxPoint x="410" y="360" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="24" value="" style="endArrow=none;html=1;entryX=0;entryY=0;entryDx=0;entryDy=0;exitX=1;exitY=0;exitDx=0;exitDy=0;" edge="1" parent="1" source="6" target="2">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="200" y="300" as="sourcePoint"/>
<mxPoint x="290" y="240" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="28" value="1,n" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="50" y="334" width="60" height="30" as="geometry"/>
</mxCell>
<mxCell id="31" value="1,1" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="250" y="238" width="60" height="30" as="geometry"/>
</mxCell>
<mxCell id="338" value="" style="endArrow=none;html=1;exitX=0.982;exitY=1.115;exitDx=0;exitDy=0;entryX=0;entryY=0;entryDx=0;entryDy=0;exitPerimeter=0;" edge="1" parent="1" source="354" target="2">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="350" y="80" as="sourcePoint"/>
<mxPoint x="310" y="250" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="339" value="1,1" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="280" y="202" width="60" height="30" as="geometry"/>
</mxCell>
<mxCell id="341" value="" style="endArrow=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=-0.018;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;" edge="1" parent="1" source="354" target="342">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="-5" y="90" as="sourcePoint"/>
<mxPoint x="60" y="130" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="342" value="Ingredient" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=none;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" vertex="1" parent="1">
<mxGeometry x="-40" y="190" width="121" height="78" as="geometry"/>
</mxCell>
<mxCell id="343" value="(PK)idingredient" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="342">
<mxGeometry y="26" width="121" height="26" as="geometry"/>
</mxCell>
<mxCell id="344" value="nomtag varchar(30)" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="342">
<mxGeometry y="52" width="121" height="26" as="geometry"/>
</mxCell>
<mxCell id="345" value="1,n" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry y="160" width="60" height="30" as="geometry"/>
</mxCell>
<mxCell id="351" value="Listeingredient" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize=26;fillColor=none;horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=1;marginBottom=0;html=1;" vertex="1" parent="1">
<mxGeometry x="140" y="70" width="111" height="78" as="geometry"/>
</mxCell>
<mxCell id="353" value="(FK)idrecette" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="351">
<mxGeometry y="26" width="111" height="26" as="geometry"/>
</mxCell>
<mxCell id="354" value="(FK)idingredient" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=top;spacingLeft=4;spacingRight=4;overflow=hidden;rotatable=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;whiteSpace=wrap;html=1;" vertex="1" parent="351">
<mxGeometry y="52" width="111" height="26" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>