-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLQuery.sql
More file actions
175 lines (134 loc) · 3.05 KB
/
SQLQuery.sql
File metadata and controls
175 lines (134 loc) · 3.05 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
CREATE TABLE Customers (
id INT PRIMARY KEY IDENTITY(1,1),
customerName VARCHAR(50) NOT NULL UNIQUE,
customerPass VARCHAR(50) NOT NULL,
)
INSERT INTO Customers(customerName, customerPass) VALUES(
'Mo',
'Qwerty'
)
INSERT INTO Customers(customerName, customerPass) VALUES(
'Kendall',
'cAtS'
)
SELECT * FROM Customers
DROP TABLE Customers
--------------------------------------------------------------------------------
CREATE TABLE Products(
id INT PRIMARY KEY IDENTITY (1,1),
productName VARCHAR(50) NOT NULL,
price FLOAT NOT NULL
)
INSERT INTO Products(productName, price) VALUES(
'Lethal League Blaze',
14.99
)
INSERT INTO Products(productName, price) VALUES(
'The Binding of Issac: Repentance',
59.99
)
INSERT INTO Products(productName, price) VALUES(
'Outer Wilds',
24.99
)
INSERT INTO Products(productName, price) VALUES(
'Elden Ring',
59.99
)
SELECT * FROM Products
DROP TABLE Products
--------------------------------------------------------------------------------
CREATE TABLE Stores(
id INT PRIMARY KEY IDENTITY (1,1),
storeLocation VARCHAR (100) NOT NULL
)
INSERT INTO Stores(storeLocation) VALUES(
'New Jersey'
)
INSERT INTO Stores(storeLocation) VALUES(
'Florida'
)
INSERT INTO Stores(storeLocation) VALUES(
'Kentucky'
)
SELECT * FROM Stores
DROP TABLE Stores
--------------------------------------------------------------------------------
CREATE TABLE Inventory(
id INT PRIMARY KEY IDENTITY (1,1),
quantity INT NOT NULL,
productID INT FOREIGN KEY REFERENCES Products(id),
storeID INT NOT NULL FOREIGN KEY REFERENCES Stores(id) ON DELETE CASCADE
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
1,
10,
1
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
2,
15,
1
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
3,
5,
1
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
6,
9,
1
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
4,
20,
1
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
3,
15,
2
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
5,
25,
2
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
6,
15,
2
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
1,
20,
3
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
2,
5,
3
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
4,
30,
3
)
INSERT INTO Inventory(productID, quantity, storeID) VALUES(
6,
30,
3
)
SELECT * FROM Inventory
DROP TABLE Inventory
--------------------------------------------------------------------------------
CREATE TABLE Orders(
id INT PRIMARY KEY IDENTITY (1,1),
dateCreated DATETIME NULL,
total FLOAT,
storeID INT NOT NULL FOREIGN KEY REFERENCES Stores(id),
customerID INT NOT NULL FOREIGN KEY REFERENCES Customers(id) ON DELETE CASCADE
)
SELECT * FROM Orders
DROP TABLE Orders