0% found this document useful (0 votes)
4 views2 pages

Database Schema for Tramway System

The document outlines the creation of a database named 'tramwayrabat' with tables for 'arrondissement', 'station', 'Ligne', and 'Travaux'. Each table includes primary keys and foreign key constraints to maintain relationships between them. Additionally, it includes modifications to the 'Arrondissement' and 'Ligne' tables to add a new column and change an existing column name, respectively.

Uploaded by

rifiadam639
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Database Schema for Tramway System

The document outlines the creation of a database named 'tramwayrabat' with tables for 'arrondissement', 'station', 'Ligne', and 'Travaux'. Each table includes primary keys and foreign key constraints to maintain relationships between them. Additionally, it includes modifications to the 'Arrondissement' and 'Ligne' tables to add a new column and change an existing column name, respectively.

Uploaded by

rifiadam639
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

create database tramwayrabat;

use tramwayrabat;
create table arrondissement (
numArrondissement INT NOT NULL,
superficie DOUBLE ,
nbrHabitants INT ,
PRIMARY KEY(numArrondissement));
create table station (
numStation INT NOT NULL,
nomStation VARCHAR(45),
numArrondissement INT ,
PRIMARY KEY(numStation),
INDEX arrondissement_fk_idx (numArrondissement),
CONSTRAINT arrondissement_fk
FOREIGN KEY (numArrondissement)
REFERENCES Arrondissement (numArrondissement)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

CREATE TABLE Ligne (


NumLigne INT NOT NULL,
nbrStations INT ,
nbrPassager2018 INT ,
DateMService DATE ,
stationDepart INT ,
stationArrivee INT ,
PRIMARY KEY (NumLigne),
INDEX stationDepart_fk_idx (stationDepart),
INDEX stationArrivee_fk_idx (stationArrivee),
CONSTRAINT stationDepart_fk
FOREIGN KEY (stationDepart)
REFERENCES Station (numStation)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT stationArrivee_fk
FOREIGN KEY (stationArrivee)
REFERENCES Station (numStation)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

create table Travaux (


numArrondissement INT NOT NULL,
numLigne INT NOT NULL,
DateDebut DATE NOT NULL,
duree DOUBLE ,
PRIMARY KEY (numArrondissement, numLigne, DateDebut),
INDEX ligne_fk_idx (numLigne ASC),
CONSTRAINT arrondissement_travaux_fk
FOREIGN KEY (numArrondissement)
REFERENCES Arrondissement (numArrondissement)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT ligne_travaux_fk
FOREIGN KEY (numLigne)
REFERENCES Ligne (NumLigne)
ON DELETE NO ACTION
ON UPDATE NO ACTION);

alter table Arrondissement


ADD COLUMN nomArrond VARCHAR(45) ;
alter table Ligne
CHANGE COLUMN nbrPassager2018 nbrPassager2020 INT ;

You might also like