-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFinalProject.sql
More file actions
134 lines (115 loc) · 4.15 KB
/
Copy pathFinalProject.sql
File metadata and controls
134 lines (115 loc) · 4.15 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
create table Customers
(ID int,
First_Name varchar(15) not null,
Last_Name varchar(15) not null,
Gender char not null,
Status varchar(10),
Email varchar(20),
phone varchar(15) not null,
Address varchar(30),
Birth_Date Date,
Registeration_Date Date,
Primary key (ID));
create table Departments
(ID int,
Dep_Name varchar(15) not null,
Mgr_ID int,
primary key (ID),
);
create table Employees
(ID int,
Status varchar(10),
Salary Decimal(10,2),
First_Name varchar(15) not null,
Last_Name varchar(15) not null,
Email varchar(20),
Gender varchar(10) not null,
Attribute varchar(20),
Super_ID int,
Phone varchar(15),
Dep_ID int,
Address varchar(30),
Birth_Date date,
Hire_Date date,
primary key (ID),
constraint SuperFK
foreign key (Super_ID) references Employees(ID),
constraint DepFK
foreign key (Dep_ID) references Departments(ID));
alter table Departments add constraint MgrFk
foreign key (Mgr_ID) references Employees(ID);
create table Orders
(ID int,
Amount int,
Order_Date Date,
Delivery_Date Date,
Status varchar(10),
Customer_ID int,
Delivery_ID int,
primary key (ID),
constraint CustomerFK
foreign key (Customer_ID) references Customers(ID),
constraint EmployeeFK
foreign key (Delivery_ID) references Employees(ID));
create table Categories
(ID int,
Description varchar(50),
Name varchar(15) not null,
primary key (ID));
create table Products
(ID int,
Price Decimal(10,2),
Name varchar(15) not null,
Quantity int,
Category_ID int,
Status varchar(10) not null,
primary key (ID),
constraint CategoryFK
foreign key (Category_ID) references Categories(ID));
create table Order_Details
(Order_ID int,
Product_ID int,
Quantity int not null,
Price decimal(10,2) not null,
constraint OrderFK
foreign key (Order_ID) references Orders(ID),
constraint ProductFK
foreign key (Product_ID) references Products(ID));
create table Warehouse
(ID int,
Name int not null,
Location varchar(30) not null,
Capacity int
Primary key (ID));
create table Contain
(Category_ID int,
Warehouse_ID int,
Product_ID int,
Quantity int,
constraint CategoryFK1
foreign key (Category_ID) references Categories(ID),
constraint ProductFK1
foreign key (Product_ID) references Products(ID),
constraint WarehouseFK
foreign key (Warehouse_ID) references Warehouse(ID));
create table Vendor
(ID int,
First_Name varchar(15) not null,
Last_Name varchar(15) not null,
Email varchar(30),
Address varchar(30),
Phone varchar(15),
primary key (ID));
create table Sell
(Product_ID int,
Category_ID int,
Vendor_ID int,
Quantity int not null,
Date date,
Price decimal(10,2) not null,
constraint CategoryFK2
foreign key (Category_ID) references Categories(ID),
constraint ProductFK2
foreign key (Product_ID) references Products(ID),
constraint VendorFK
foreign key (Vendor_ID) references Vendor(ID));