-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJewel_Shop.sql
83 lines (57 loc) · 1.9 KB
/
Jewel_Shop.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
create database Shop
use Shop
--User data Table
create table Login(
username varchar(50) primary key,
password varchar(50),
);
insert into Login values ('Admin', 'Admin')
select * from Login
create table lul(
price int,
quantity int,
)
alter table lul add total as (price * quantity)
select * from lul
insert into lul values (30,20)
--Employee Table
create table Employee(
emp_id int primary key, --id is PK
emp_name varchar(30) not null, --name of employee
emp_cnic int unique, --cnic of employee
emp_gen varchar(15) not null, --gender
emp_no int not null, --contact number
emp_exp int not null, --employee experience
emp_post varchar(20) not null, --employee post in store
);
--Customer Table
create table Customer(
c_id int primary key, --customer id
c_name varchar(30) not null, --customer name
c_no int not null, --customer number
c_adress varchar(50) not null, --customer address
c_cnic int unique, --customer cnic
);
--Product Table
create table Product(
p_id varchar(30) primary key, --product id
p_company varchar(30) not null, --company of the product
p_catagory varchar(30) not null, --product catagory
p_type varchar(30) not null, --product type
p_price float not null, --product price
);
--Bill Table
create table Bill(
rec_no int unique, --reciept number
c_id int foreign key references Customer(c_id) not null, --customer name
p_id varchar(30) foreign key references Product(p_id), --p_id as FK
u_price float not null, --unit price of product
quantity int not null, --quantity of product
);
alter table Bill add T_Price as (u_price * quantity) --derived column
alter table Bill add datee varchar(30)
select * from Employee
select * from Customer
select * from Product
select * from Bill
insert into Employee(emp_id,emp_name,emp_cnic) values(10, 'Ahmad',5656)