-
Notifications
You must be signed in to change notification settings - Fork 0
/
SQL
51 lines (26 loc) · 3.59 KB
/
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
/*creating the tables*/
CREATE TABLE SIZE_OF_BRANCH (ID INT,AREA_M2 CHAR,PRIMARY KEY(ID));
CREATE TABLE BRANCH (ID INT,NAME CHAR,AREA INT,ADRESS CHAR,POSTCODE INT,City CHAR,FOREIGN KEY(AREA) REFERENCES SIZE_OF_BRANCH(ID),PRIMARY KEY(ID));
CREATE TABLE MANAGERS (NAME CHAR,SURNAME CHAR,BRANCH_OF_MANAGER INT,FOREIGN KEY(BRANCH_OF_MANAGER) REFERENCES BRANCH(ID),PRIMARY KEY(BRANCH_OF_MANAGER));
CREATE TABLE CLIENTS (ID INT,NAME CHAR,SURNAME CHAR,BRANCH_OF_THE_CLIENT CHAR,PRIMARY KEY(ID),FOREIGN KEY(BRANCH_OF_THE_CLIENT) REFERENCES BRANCH(ID));
CREATE TABLE TAXATION_OF_SALARY (ID INT,EFFECTIVE_RATE FLOAT,PRIMARY KEY(ID));
CREATE TABLE SALARY (ID INT,AMOUNT_NOK INT,TAX CHAR,FOREIGN KEY(TAX) REFERENCES TAXATION_OF_SALARY(ID),PRIMARY KEY(ID));
CREATE TABLE POSITION (ID INT,NAME_OF_POSITION CHAR,SALARY_FOR_THE_POSITION CHAR,FOREIGN KEY(SALARY_FOR_THE_POSITION) REFERENCES SALARY(ID),PRIMARY KEY(ID));
CREATE TABLE EMPLOYEES (ID INT,NAME CHAR,SURNAME CHAR,BRANCH_EMP CHAR,POSITION_OF_EMPL INT,Phone INT,FOREIGN KEY(POSITION_OF_EMPL) REFERENCES POSITION(ID),PRIMARY KEY(ID),FOREIGN KEY(BRANCH_EMP) REFERENCES BRANCH(ID));
CREATE TABLE COUNTRY (ID INT,COUNTRY_NAME CHAR,CONTINENT CHAR,PRIMARY KEY(ID));
CREATE TABLE PRODUCERS (ID INT,PRODUCER CHAR,COUNTRY_OF_PRODUCER CHAR,FOREIGN KEY(COUNTRY_OF_PRODUCER) REFERENCES COUNTRY(ID),PRIMARY KEY(ID));
CREATE TABLE PHONES (ID INT,NAME_OF_THE_PHONE CHAR,SUPPLIER INT,FOREIGN KEY(SUPPLIER) REFERENCES PRODUCERS(ID),PRIMARY KEY(ID));
CREATE TABLE STOCKS (ID INT,MODEL_OF_PHONE INT,PIECES INT,BRANCH_OF_STOCK INT,FOREIGN KEY(MODEL_OF_PHONE) REFERENCES PHONES(ID),FOREIGN KEY (BRANCH_OF_STOCK) REFERENCES BRANCH(ID), PRIMARY KEY(ID));
/*insert data into the tables*/
INSERT INTO SIZE_OF_BRANCH VALUES ( 1, 'very small'), (2, 'small'), (3, 'medium'), (4, 'big'), (5, 'very big');
INSERT INTO BRANCH VALUES (1, 'TeleCom Tromso',1,'Dramsvegen 3',9009,'Tromso'), (2, 'TeleCom Oslo Center',5,'Gunhilds gate 3',0650,'Oslo'), (3, 'TeleCom Bergen', 1,'Festplassen 4',5015,'Bergen'), (4, 'TeleCom NHH', 2,'Hatleveien 11',5038,'Bergen'), (5, 'TeleCom Bodo', 2,'Parkveien 1',8007,'Bodo');
INSERT INTO CLIENTS VALUES (1, 'Anna', 'Smith',1),(2, 'Thomas', 'Jones', 1), (3, 'Rafeal', 'Hibner',3), (4, 'Thomas', 'Lee', 2), (5, 'Jane', 'Kim', 4);
INSERT INTO MANAGERS VALUES ('Jan', 'Andersen', 1), ('Tim', 'Kovasky', 2), ('Sara', 'Gimenez', 3),('Victoria', 'Leesen', 4), ('Maria', ' Tree', 5);
INSERT INTO TAXATION_OF_SALARY VALUES ( 1,0.25),(2,0.27), (3,0.29), (4,0.31), (5, 0.33);
INSERT INTO SALARY VALUES (1, 10000, 1), (2, 12000, 1), (3, 15000, 2), (4,17000,3), (5,19000,4);
INSERT INTO POSITION VALUES (1, 'INTERN',1),(2, 'JUNIOR CONSULTANT', 2), (3,'SENIOR CONSULTANT',3), (4, 'SUPERVISOR',4), (5, 'SENIOR SUPERVISOR', 5);
INSERT INTO EMPLOYEES VALUES ( 1, 'Liliana', 'Teres', 1, 1,06894451687), (2, 'Alex', 'Jane', 1, 2,06891142495), (3, 'Vivien', 'Lala', 2, 1,06889428763), (4, 'Janees', 'Helen', 2, 4,06891122311), (5, 'Robert', 'Zawadzki', 3, 4,06994754956), (6, 'Sandra', 'Home', 5,3,06891986597);
INSERT INTO COUNTRY VALUES (1, 'China','Asia'), (2, 'USA','North America'), ( 3, 'Germany','Europe'), (4, 'Japan','Asia'), (5, 'Korea','Asia');
INSERT INTO PRODUCERS VALUES ( 1, 'Nokia', 1), (2, 'Apple', 2), (3, 'Samsung', 3), (4, 'Xaomi', 1), ( 5, 'SuperPhones', 2) ;
INSERT INTO PHONES VALUES (1, 'Nokia 3310', 1), (2, 'iPhone 6', 2), (3, 'Samsung 4', 3), (4, 'iPhone 7 ', 2),(5, 'Xaomi 3', 4), ( 6, 'SuperPhone 3390', 5) ;
INSERT INTO STOCKS VALUES ( 1, 1, 30, 1),( 2, 1, 40, 1), (3, 1, 50, 2), (4,2, 70, 2), (5, 3, 35, 2), (6, 3, 45, 3), ( 7, 4, 78, 3), (8, 5, 90, 4), (9, 6, 10, 5);