Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Online Retail System

(Sahil ,1917634)
Create database db_Online_Retail_System;
use db_Online_Retail_System;

---create table customer


create table tbl_customer(
first_name varchar(40),
last_name varchar(40),
home_address varchar(50),
contact_no int,
email_address varchar(50),
customer_id int primary key,
customer_password varchar(40)

);

--create product table


create table tbl_products(
product_name varchar(30),
product_id int primary key,
price int,
product_description varchar(400)
);
---create table cart item
create table tbl_cart_item(
cart_item_id int primary key,
quantity int,
total_cost int

);

---create table cart


create table tbl_cart(
cart_id int,
total_cost int
);
---create table payment
create table payment(
amount int,
payment_id varchar(40) primary key,
payment_type varchar(40)
);

--create table account

create table tbl_account(


ac_no varchar(20) primary key,
account_type varchar(30),
balance int
);
alter table tbl_cart_item add product_id int foreign key references
tbl_products(product_id);
alter table payment add customer_id int foreign key references
tbl_customer(customer_id);
alter table payment add unique(amount) ;
alter table tbl_account add payment int foreign key references payment(amount);

-----select statements
select * from tbl_account;
select * from tbl_cart;
select * from tbl_cart_item;
select * from tbl_customer;
select * from tbl_products;
select * from payment;

--insert into tables


insert into tbl_account values(12122,'saving Account',232320);
insert into tbl_cart values(5,33250);
insert into tbl_cart_item values(4,1,40);
insert into tbl_customer values('Raju','Hansraj','332
Sector',466546561,'32@yahoo.com',33,'rahanahgabhala');
insert into tbl_products values('Shampoo',121,3132,'Exclusive product');
insert into payment values(3132,'2ap','credit card');

You might also like