2019-06-10 13:11:41 +02:00
|
|
|
CREATE DATABASE PizzaFat;
|
|
|
|
|
2019-06-10 12:19:10 +02:00
|
|
|
CREATE TABLE 'zamowienia'
|
|
|
|
(
|
|
|
|
'id' int PRIMARY KEY,
|
|
|
|
'date' datetime,
|
|
|
|
'id_faktury' int,
|
|
|
|
'id_klienta' int
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE 'zamowienia_wiersze'
|
|
|
|
(
|
|
|
|
'id' int PRIMARY KEY,
|
|
|
|
'order_id' int,
|
|
|
|
'pizza_id' int,
|
|
|
|
'ilosc' int,
|
|
|
|
'cena' double,
|
|
|
|
'kwota' double
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE 'pizze'
|
|
|
|
(
|
|
|
|
'id' int PRIMARY KEY,
|
|
|
|
'name' varchar(255),
|
|
|
|
'price' int
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE 'pizze_przepisy'
|
|
|
|
(
|
|
|
|
'pizza_id' int,
|
|
|
|
'skladnik_id' int,
|
|
|
|
'ilosc' double,
|
|
|
|
'koszt' double,
|
|
|
|
'kwota_kosztu' double
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE 'skladniki'
|
|
|
|
(
|
|
|
|
'id' int PRIMARY KEY,
|
|
|
|
'name' varchar(255),
|
|
|
|
'cena' double
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE 'sladniki_transakcje'
|
|
|
|
(
|
|
|
|
'id' int PRIMARY KEY,
|
|
|
|
'data' datetime,
|
|
|
|
'skladnik_id' int,
|
|
|
|
'zamowienie_wiersz_id' int,
|
|
|
|
'ilosc' double,
|
|
|
|
'koszt' double,
|
|
|
|
'cena' double,
|
|
|
|
'kwota_kosztu' double,
|
|
|
|
'kwota_sprzedazy' double,
|
|
|
|
'zysk' double
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE 'zakupy'
|
|
|
|
(
|
|
|
|
'id' int PRIMARY KEY,
|
|
|
|
'id_faktury' int,
|
|
|
|
'skladnik_id' int,
|
|
|
|
'ilosc' double,
|
|
|
|
'koszt' double
|
|
|
|
);
|
|
|
|
|
|
|
|
ALTER TABLE 'zamowienia_wiersze' ADD FOREIGN KEY ('order_id') REFERENCES 'zamowienia' ('id');
|
|
|
|
|
|
|
|
ALTER TABLE 'zamowienia_wiersze' ADD FOREIGN KEY ('pizza_id') REFERENCES 'pizze' ('id');
|
|
|
|
|
|
|
|
ALTER TABLE 'pizze_przepisy' ADD FOREIGN KEY ('pizza_id') REFERENCES 'pizze' ('id');
|
|
|
|
|
|
|
|
ALTER TABLE 'pizze_przepisy' ADD FOREIGN KEY ('skladnik_id') REFERENCES 'skladniki' ('id');
|
|
|
|
|
|
|
|
ALTER TABLE 'sladniki_transakcje' ADD FOREIGN KEY ('skladnik_id') REFERENCES 'skladniki' ('id');
|
|
|
|
|
|
|
|
ALTER TABLE 'sladniki_transakcje' ADD FOREIGN KEY ('zamowienie_wiersz_id') REFERENCES 'zamowienia_wiersze' ('id');
|
|
|
|
|
|
|
|
ALTER TABLE 'zakupy' ADD FOREIGN KEY ('skladnik_id') REFERENCES 'skladniki' ('id');
|