Facebook
From Colorant Pelican, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 235
  1. --zad1
  2. --create database uczelnia;
  3. --use uczelnia;
  4.  
  5. --zad2
  6. /*create table studenci
  7. (
  8.         nr_indeksu int not null primary key,
  9.         imie varchar(255) not null,
  10.         nazwisko varchar(255) not null,
  11.         adres varchar(50) not null,
  12.         narodowosc varchar(255) not null default 'Polska'
  13. );*/
  14.  
  15. --zad3
  16. /*create table wykladowcy
  17. (
  18.         wykladowca_id int not null primary key,
  19.         imie varchar(255) not null,
  20.         nazwisko varchar(255) not null,
  21. )*/
  22.  
  23. --zad4
  24. /*create table kierunki
  25. (
  26.         kierunek_id int not null primary key,
  27.         nazwa varchar(255) not null,
  28. )*/
  29.  
  30. --zad5
  31. /*create table przedmioty
  32. (
  33.         przedmiot_id int not null primary key,
  34.         kierunek_id int foreign key references kierunki(kierunek_id) not null,
  35.         wykladowca_id int foreign key references wykladowcy(wykladowca_id) not null,
  36.         nazwa varchar(255) not null
  37. )*/
  38.  
  39. -- zad6
  40. /*create table studenci_przedmioty
  41. (
  42.         nr_indeksu int foreign key references studenci(nr_indeksu),
  43.         przedmiot_id int foreign key references przedmioty(przedmiot_id)
  44.         primary key(nr_indeksu,przedmiot_id)
  45.  
  46. )*/
  47.  
  48. -- zad7
  49. /*create table oceny
  50. (
  51.         ocena_id int primary key,
  52.         nr_indeksu int foreign key references studenci(nr_indeksu),
  53.         przedmiot_id int foreign key references przedmioty(przedmiot_id) not null,
  54.         wartosc float not null default '2.0',
  55.         data date not null default getdate()
  56. )*/
  57.  
  58. --zad8
  59.  
  60. --alter table oceny add check(wartosc between 2.0 and 5.0);
  61. --alter table przedmioty add unique(nazwa)
  62. --alter table kierunki add unique(nazwa)
  63. --alter table kierunki add opis text default 'pusty opis'
  64.  
  65.  
  66. -- zad9
  67. --insert into studenci values(12345,'Jan','Kowalski','Makowa','Polska')
  68. --insert into studenci values(12645,'Mahomed','Akbar','Berlin','Niemcy')
  69. --insert into studenci values(18745,'Abdul','Hariri','Paryz','Francja')
  70. --insert into wykladowcy values(1,'Marcin', 'Nowak')
  71. --insert into wykladowcy values(2,'Jakub', 'Kowal')
  72. --insert into wykladowcy values(3,'Marcin', 'Kowalski')
  73. --insert into kierunki values(1,'Informatyka', 'Kierunek dla ludzi z pasjommmm')
  74. --insert into kierunki values(2,'automatyka i robotyka', 'takie znane przyslowie ')
  75. --insert into kierunki values(3,'energeytyka', 'Kierunek dla chetnych')
  76. --insert into przedmioty values(1,2,3, 'PAIRy' )
  77. --insert into przedmioty values(2,2,3, 'niePairy' )
  78. --insert into przedmioty values(3,2,3, 'Pairy nie' )
  79. --insert into studenci_przedmioty values(12345,1)
  80. --insert into studenci_przedmioty values(12645,2)
  81. --insert into studenci_przedmioty values(18745,3)
  82.  
  83.  
  84. insert into oceny values(12345,2,3.0,default )
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.