You are on page 1of 3

create table zawody

(
nrzawodow int,
nazwazawodow varchar(40),
datazawodow date,
podtytul varchar(70),
primary key(nrzawodow)
);

create table kluby


(
nrklubu int,
nazwaklubu varchar(40) not null,
primary key (nrklubu)
);

create table kategorie


(
nrkategorii int,
nazwakategorii varchar(6) not null,
dolnyprog int not null,
gornyprog int not null,
primary key (nrkategorii)
);

create table zawodnicy


(
nrzawodnika int,
imie varchar(15) not null,
nazwisko varchar(25) not null,
plec varchar(1) not null,
check (upper(plec) = 'm' or upper(plec) = 'k'),
rokurodzenia int not null,
nrkategorii int not null,
nrklubu int not null,
primary key (nrzawodnika),
foreign key nrklubu
references kluby(nrklubu),
foreign key nrkategorii
references kategorie(nrkategorii)

);

create table wyniki


(
nrzawodow int,
nrzawodnika int,
rezultatmin int not null,
rezultatsek int not null,
pozycja int not null,
punktyglobalne int,
punktykategorii int,
pozycjakategoria int,
pozycjaglobalnie int,
lokatawbiegu int,
primary key (nrzawodow, nrzawodnika),
foreign key nrzawodow
references zawody(nrzawodow),
foreign key nrzawodnika
references zawodnicy(nrzawodnika)
);

load into table zawody from 'c:\documents and


settings\student\pulpit\dane\zawody.txt'
load into table kluby from 'c:\documents and
settings\student\pulpit\dane\kluby.txt'
load into table kategorie from 'c:\documents and
settings\student\pulpit\dane\kategorie.txt'
load into table zawodnicy from 'c:\documents and
settings\student\pulpit\dane\zawodnicy.txt'
load into table wyniki from 'c:\documents and
settings\student\pulpit\dane\wyniki.txt'

select*from wyniki

select imie,nazwisko, nazwaklubu


from zawodnicy, kluby
where zawodnicy.nrklubu=kluby.nrklubu

select distinct nazwisko,imie,nazwaklubu,nazwakategorii,rezultatmin,rezultatsek


from zawodnicy z,kluby k,kategorie c ,wyniki w,zawody p
where p.nrzawodow=w.nrzawodow
and w.nrzawodnika = z.nrzawodnika
and z.nrkategorii = c.nrkategorii
and k.nrklubu = z.nrklubu
and p.nrzawodow=2

select imie, nazwisko, nazwaklubu, 2006-rokurodzenia as wiek


from zawodnicy, kluby
where zawodnicy.nrklubu = kluby.nrklubu and wiek not between 20 and 70
order by 4

select substring(nazwisko,1,1) as identyfikator, nazwisko


from zawodnicy

select substring(upper(imie),1,10)+'.'+upper(nazwisko) as zawodnik, nazwakategorii


from zawodnicy, kategorie

select count(distinct pozycja)


from wyniki
where nrzawodow = 1

select min(punktykategorii)
from wyniki
where nrzawodnika = 333

select * from wyniki


where nrzawodnika = 333

select nrklubu, count(*) as [liczba zawodnik�w]


from zawodnicy
group by nrklubu
order by nrklubu

alter table zawody


add idsedziego int;

create table sedziowie


(
idsedziego integer primary key,
imie varchar(40),
nazwisko varchar(80),
datauprawnienia date,
);

select sedziowie from zawody

insert into sedziowie


( idsedziego, imie, nazwisko, datauprawnienia)
values
( 2, 'andrzej', 'lepper', '1990-05-12');

select * from sedziowie

You might also like