-
Notifications
You must be signed in to change notification settings - Fork 0
/
Create.sql
108 lines (59 loc) · 2.2 KB
/
Create.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
create schema SkladiscePB;
use SkladiscePB;
CREATE TABLE `Oddelek` (
`ID_Oddelek` int(11) NOT NULL DEFAULT '0',
`Placa` int(11) NOT NULL DEFAULT '0',
`Naziv` varchar(35) NOT NULL DEFAULT '',
PRIMARY KEY (`ID_Oddelek`)
);
CREATE TABLE `Posta` (
`ID_Posta` int(11) NOT NULL DEFAULT '0',
`Ime_Poste` char(35) NOT NULL DEFAULT '',
PRIMARY KEY (`ID_Posta`)
);
CREATE TABLE `Zaposleni` (
`ID_Zaposleni` int NOT NULL AUTO_INCREMENT UNIQUE,
`Ime` varchar(35) NOT NULL DEFAULT '',
`Priimek` varchar(35) NOT NULL DEFAULT '',
`Starost` float(3,1) NOT NULL DEFAULT '0',
`Naslov` varchar(35) NOT NULL DEFAULT '',
`ID_Posta` int(11) NOT NULL DEFAULT '0',
`GSM` varchar(35) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID_Zaposleni`),
FOREIGN KEY (ID_Posta) REFERENCES Posta(ID_Posta)
);
CREATE TABLE `Vilicar` (
`SerialNo` int NOT NULL AUTO_INCREMENT UNIQUE,
`Model` char(35) NOT NULL DEFAULT '',
`Datum_nakupa` date,
PRIMARY KEY (`SerialNo`)
);
CREATE TABLE `Skladisce` (
`ID_Skladisce` int NOT NULL AUTO_INCREMENT UNIQUE,
`Naslov` varchar(35) NOT NULL DEFAULT '',
`ID_Posta` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID_Skladisce`),
FOREIGN KEY (ID_Posta) REFERENCES Posta(ID_Posta)
);
CREATE TABLE `Vilicar_Skladisce` (
`ID_Skladisce` int(11) NOT NULL DEFAULT '0',
`SerialNo` int(11) NOT NULL DEFAULT '0',
FOREIGN KEY (ID_Skladisce) REFERENCES skladisce(ID_Skladisce),
FOREIGN KEY (SerialNo) REFERENCES vilicar(SerialNo)
);
CREATE TABLE `Zaposlen_Skladisce` (
`ID_Skladisce` int(11) NOT NULL DEFAULT '0',
`ID_Zaposleni` int(11) NOT NULL DEFAULT '0',
`ID_Oddelek` int(11) NOT NULL DEFAULT '0',
FOREIGN KEY (ID_Skladisce) REFERENCES skladisce(ID_Skladisce),
FOREIGN KEY (ID_Zaposleni) REFERENCES Zaposleni(ID_Zaposleni),
FOREIGN KEY (ID_Oddelek) REFERENCES Oddelek(ID_Oddelek)
);
CREATE TABLE `Vilicar_Zaposleni` (
`ID_Zaposleni` int(11) NOT NULL DEFAULT '0',
`SerialNo` int(11) NOT NULL DEFAULT '0',
`Ure` int(11) NOT NULL DEFAULT '0',
FOREIGN KEY (ID_Zaposleni) REFERENCES Zaposleni(ID_Zaposleni),
FOREIGN KEY (SerialNo) REFERENCES vilicar(SerialNo)
);
-- SELECT * FROM Vilicar_skladisce order by ID_skladisce;