-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSQL CODE.txt
105 lines (92 loc) · 2.91 KB
/
SQL CODE.txt
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
// SQL SERVER CODE
CREATE LOGIN [project] WITH PASSWORD = 'modernMAM';
EXEC sp_addsrvrolemember 'project', 'sysadmin';
CREATE TABLE Sales_Office (
Office_Number INT PRIMARY KEY,
Location VARCHAR(50) NOT NULL
);
CREATE TABLE Employee (
Employee_ID INT PRIMARY KEY,
Employee_Name VARCHAR(50) NOT NULL,
Office_Number INT NOT NULL,
Is_Manager BIT NOT NULL,
CONSTRAINT fk_Employee_Sales_Office FOREIGN KEY (Office_Number)
REFERENCES Sales_Office(Office_Number)
);
CREATE TABLE Property (
Property_ID INT PRIMARY KEY,
Address VARCHAR(100) NOT NULL,
City VARCHAR(50) NOT NULL,
State VARCHAR(50) NOT NULL,
Postcode VARCHAR(20) NOT NULL,
Office_Number INT NOT NULL,
CONSTRAINT fk_Property_Sales_Office FOREIGN KEY (Office_Number)
REFERENCES Sales_Office(Office_Number)
);
CREATE TABLE Owner (
Owner_ID INT PRIMARY KEY,
Owner_Name VARCHAR(50) NOT NULL
);
CREATE TABLE Property_Owner (
Property_ID INT NOT NULL,
Owner_ID INT NOT NULL,
Percent_Owned DECIMAL(5,2) NOT NULL,
CONSTRAINT pk_Property_Owner PRIMARY KEY (Property_ID, Owner_ID),
CONSTRAINT fk_Property_Owner_Property FOREIGN KEY (Property_ID)
REFERENCES Property(Property_ID),
CONSTRAINT fk_Property_Owner_Owner FOREIGN KEY (Owner_ID)
REFERENCES Owner(Owner_ID)
);
CREATE TABLE user_login(
ID int NOT NULL IDENTITY(1,1),
username varchar(100) not null,
password varchar(100) not null,
PRIMARY KEY (ID)
);
select * from user_login
// end of sql server code
// MYSQL SERVER CODE
MYSQL 5.7:
CREATE TABLE Sales_Office (
Office_Number INT PRIMARY KEY,
Location VARCHAR(50) NOT NULL
);
CREATE TABLE Employee (
Employee_ID INT PRIMARY KEY,
Employee_Name VARCHAR(50) NOT NULL,
Office_Number INT NOT NULL,
Is_Manager BIT NOT NULL,
CONSTRAINT fk_Employee_Sales_Office FOREIGN KEY (Office_Number)
REFERENCES Sales_Office(Office_Number)
);
CREATE TABLE Property (
Property_ID INT PRIMARY KEY,
Address VARCHAR(100) NOT NULL,
City VARCHAR(50) NOT NULL,
State VARCHAR(50) NOT NULL,
Postcode VARCHAR(20) NOT NULL,
Office_Number INT NOT NULL,
CONSTRAINT fk_Property_Sales_Office FOREIGN KEY (Office_Number)
REFERENCES Sales_Office(Office_Number)
);
CREATE TABLE Owner (
Owner_ID INT PRIMARY KEY,
Owner_Name VARCHAR(50) NOT NULL
);
CREATE TABLE Property_Owner (
Property_ID INT NOT NULL,
Owner_ID INT NOT NULL,
Percent_Owned DECIMAL(5,2) NOT NULL,
CONSTRAINT pk_Property_Owner PRIMARY KEY (Property_ID, Owner_ID),
CONSTRAINT fk_Property_Owner_Property FOREIGN KEY (Property_ID)
REFERENCES Property(Property_ID),
CONSTRAINT fk_Property_Owner_Owner FOREIGN KEY (Owner_ID)
REFERENCES Owner(Owner_ID)
);
CREATE TABLE user_login(
ID int NOT NULL AUTO_INCREMENT,
username varchar(100) not null,
password varchar(100) not null,
PRIMARY KEY (ID)
);
//end of mysql server code