Developpement/23BDD/SAE/BDD23(part3).sql

52 lines
1.0 KiB
MySQL
Raw Normal View History

2024-12-09 11:53:11 +01:00
DROP TABLE Voyage;
DROP TABLE Trajet;
DROP TABLE Train;
DROP TABLE Conducteur;
DROP TABLE Personne;
DROP TABLE Gare;
CREATE TABLE Gare (
IdGare INT Primary Key,
Ville varchar2(100),
NomGare varchar2(50)
);
CREATE TABLE Personne (
idPersonne INT Primary Key,
NomPers varchar2(50),
PrenomPers varchar2(50),
AdressePers varchar2(100),
TelPers varchar2(10)
);
CREATE TABLE Conducteur (
idPersonne INT Primary Key REFERENCES Personne,
telPro varchar2(10),
centreRattachement varchar2(50),
datePermis Date
);
CREATE TABLE Train (
idTrain INT Primary Key,
typeTrain varchar2(50),
duplex Boolean,
idGareDep INT REFERENCES Gare,
idGareArrivee INT REFERENCES Gare,
idPersonne INT REFERENCES Conducteur
);
CREATE TABLE Trajet (
IdTrain INT REFERENCES Train,
dateDepart DATE,
heureDepart INT,
heureArrivee INT,
tarifBase INT,
Primary Key (IdTrain,dateDepart,heureDepart)
);
CREATE TABLE Voyage(
IdVoyage INT PRIMARY KEY,
dateCreation DATE,
codeTarif INT,
idTrain INT,
DateDepart DATE,
heureDepart INT,
Foreign Key (idTrain,dateDepart, heureDepart) REFERENCES Trajet
);