· 8 years ago · Apr 19, 2018, 03:06 PM
1drop table if exists Ankieta;
2
3drop table if exists Posilek;
4
5drop table if exists Produkt;
6
7drop table if exists ProduktPosilek;
8
9drop table if exists User;
10
11/*==============================================================*/
12/* Table: Ankieta */
13/*==============================================================*/
14create table Ankieta
15(
16 IdAnkiety int not null,
17 Login char(15),
18 Plec char(1) default 'K' comment 'Oznacza płeć osoby:
19 K - Kobieta
20 M - Mężczyzna',
21 Masa int,
22 Wzrost int,
23 Budzet float(5),
24 Wiek int,
25 primary key (IdAnkiety)
26);
27
28/*==============================================================*/
29/* Table: Posilek */
30/*==============================================================*/
31create table Posilek
32(
33 IdPosilku int not null,
34 Login char(15),
35 Nazwa char(15),
36 primary key (IdPosilku)
37);
38
39/*==============================================================*/
40/* Table: Produkt */
41/*==============================================================*/
42create table Produkt
43(
44 IdProduktu int not null,
45 Nazwa char(15),
46 Bialko int,
47 Weglowodany int,
48 Tluszcze int,
49 Cena float(5),
50 primary key (IdProduktu)
51);
52
53/*==============================================================*/
54/* Table: ProduktPosilek */
55/*==============================================================*/
56create table ProduktPosilek
57(
58 IdProduktu int not null,
59 IdPosilku int not null,
60 primary key (IdProduktu, IdPosilku)
61);
62
63/*==============================================================*/
64/* Table: User */
65/*==============================================================*/
66create table User
67(
68 Login char(15) not null,
69 Haslo char(20),
70 primary key (Login)
71);
72
73alter table Ankieta add constraint FK_Relationship_2 foreign key (Login)
74 references User (Login);
75
76alter table Posilek add constraint FK_Relationship_1 foreign key (Login)
77 references User (Login);
78
79alter table ProduktPosilek add constraint FK_ProduktPosilek foreign key (IdProduktu)
80 references Produkt (IdProduktu);
81
82alter table ProduktPosilek add constraint FK_ProduktPosilek2 foreign key (IdPosilku)
83 references Posilek (IdPosilku);