- --zad1
- --create database uczelnia;
- --use uczelnia;
- --zad2
- /*create table studenci
- (
- nr_indeksu int not null primary key,
- imie varchar(255) not null,
- nazwisko varchar(255) not null,
- adres varchar(50) not null,
- narodowosc varchar(255) not null default 'Polska'
- );*/
- --zad3
- /*create table wykladowcy
- (
- wykladowca_id int not null primary key,
- imie varchar(255) not null,
- nazwisko varchar(255) not null,
- )*/
- --zad4
- /*create table kierunki
- (
- kierunek_id int not null primary key,
- nazwa varchar(255) not null,
- )*/
- --zad5
- /*create table przedmioty
- (
- przedmiot_id int not null primary key,
- kierunek_id int foreign key references kierunki(kierunek_id) not null,
- wykladowca_id int foreign key references wykladowcy(wykladowca_id) not null,
- nazwa varchar(255) not null
- )*/
- -- zad6
- /*create table studenci_przedmioty
- (
- nr_indeksu int foreign key references studenci(nr_indeksu),
- przedmiot_id int foreign key references przedmioty(przedmiot_id)
- primary key(nr_indeksu,przedmiot_id)
- )*/
- -- zad7
- /*create table oceny
- (
- ocena_id int primary key,
- nr_indeksu int foreign key references studenci(nr_indeksu),
- przedmiot_id int foreign key references przedmioty(przedmiot_id) not null,
- wartosc float not null default '2.0',
- data date not null default getdate()
- )*/
- --zad8
- --alter table oceny add check(wartosc between 2.0 and 5.0);
- --alter table przedmioty add unique(nazwa)
- --alter table kierunki add unique(nazwa)
- --alter table kierunki add opis text default 'pusty opis'
- -- zad9
- --insert into studenci values(12345,'Jan','Kowalski','Makowa','Polska')
- --insert into studenci values(12645,'Mahomed','Akbar','Berlin','Niemcy')
- --insert into studenci values(18745,'Abdul','Hariri','Paryz','Francja')
- --insert into wykladowcy values(1,'Marcin', 'Nowak')
- --insert into wykladowcy values(2,'Jakub', 'Kowal')
- --insert into wykladowcy values(3,'Marcin', 'Kowalski')
- --insert into kierunki values(1,'Informatyka', 'Kierunek dla ludzi z pasjommmm')
- --insert into kierunki values(2,'automatyka i robotyka', 'takie znane przyslowie ')
- --insert into kierunki values(3,'energeytyka', 'Kierunek dla chetnych')
- --insert into przedmioty values(1,2,3, 'PAIRy' )
- --insert into przedmioty values(2,2,3, 'niePairy' )
- --insert into przedmioty values(3,2,3, 'Pairy nie' )
- --insert into studenci_przedmioty values(12345,1)
- --insert into studenci_przedmioty values(12645,2)
- --insert into studenci_przedmioty values(18745,3)
- insert into oceny values(12345,2,3.0,default )