SHARE
TWEET

sss

a guest Nov 12th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 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';
  2.  
  3. 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';
  4.  
  5. CREATE TABLE Kierunki(id int not null auto_increment primary key, wydzialy_id int not null, nazwa varchar(100)) ENGINE = 'innoDB';
  6.  
  7. 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';
  8.  
  9. 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';
  10.  
  11. ALTER TABLE Studenci ADD
  12.  
  13.  
  14. ALTER TABLE Wydzialy ADD CONSTRAINT fk_idwydzialy FOREIGN KEY (uniwersytety_id) REFERENCES Uniwersytety(id);
  15.  
  16. ALTER TABLE Kierunki ADD CONSTRAINT fk_idkierunki FOREIGN KEY (wydzialy_id) REFERENCES Wydzialy (id);
  17.  
  18. ALTER TABLE Kierunki_studenci ADD CONSTRAINT fk_idkierstudenci FOREIGN KEY (kierunki_id) REFERENCES Kierunki(id);
  19.  
  20. ALTER TABLE Kierunki_studenci ADD CONSTRAINT fk_idkierstudenci2 FOREIGN KEY (studenci_id) REFERENCES Studenci(id);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top