Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE Uniwersytety(id int not null AUTO_INCREMENT primary key, nazwa varchar(100) NOT NULL UNIQUE KEY, adres varchar(200) NOT NULL) ENGINE = 'innoDB';
- CREATE TABLE Wydzialy(id int not null AUTO_INCREMENT primary key, uniwersytety_id int not null, nazwa varchar(100), adres varchar(100) not null) ENGINE = 'innoDB';
- CREATE TABLE Kierunki(id int not null auto_increment primary key, wydzialy_id int not null, nazwa varchar(100)) ENGINE = 'innoDB';
- CREATE TABLE Kierunki_studenci(kierunki_id int not null, studenci_id int not null , data_start varchar(15) not null, data_stop varchar(15), primary key (kierunki_id, studenci_id)) ENGINE = 'innoDB';
- CREATE TABLE Studenci(id int not null AUTO_INCREMENT primary key, imie varchar(30) not null, nazwisko varchar(50) not null, numer_albumu varchar(10) not null, pesel varchar(11) not null, UNIQUE(numer_albumu, pesel)) ENGINE = 'innoDB';
- ALTER TABLE Studenci ADD
- ALTER TABLE Wydzialy ADD CONSTRAINT fk_idwydzialy FOREIGN KEY (uniwersytety_id) REFERENCES Uniwersytety(id);
- ALTER TABLE Kierunki ADD CONSTRAINT fk_idkierunki FOREIGN KEY (wydzialy_id) REFERENCES Wydzialy (id);
- ALTER TABLE Kierunki_studenci ADD CONSTRAINT fk_idkierstudenci FOREIGN KEY (kierunki_id) REFERENCES Kierunki(id);
- ALTER TABLE Kierunki_studenci ADD CONSTRAINT fk_idkierstudenci2 FOREIGN KEY (studenci_id) REFERENCES Studenci(id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement