0% found this document useful (0 votes)
51 views1 page

Online Shopping DataBase

Uploaded by

deepthigowda225
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views1 page

Online Shopping DataBase

Uploaded by

deepthigowda225
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

create database Online_Shopping_DB;

use Online_Shopping_DB;

CREATE TABLE Customers (


customer_id INT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100)
);

CREATE TABLE Products (


product_id INT PRIMARY KEY,
name VARCHAR(100),
price DECIMAL(10,2),
stock INT
);

CREATE TABLE Orders (


order_id INT PRIMARY KEY,
customer_id INT,
order_date DATE,
FOREIGN KEY (customer_id) REFERENCES Customers(customer_id)
);

CREATE TABLE OrderDetails (


order_id INT,
product_id INT,
quantity INT,
PRIMARY KEY (order_id, product_id),
FOREIGN KEY (order_id) REFERENCES Orders(order_id),
FOREIGN KEY (product_id) REFERENCES Products(product_id)
);

CREATE TABLE Payments (


payment_id INT PRIMARY KEY,
order_id INT,
payment_method VARCHAR(50),
payment_date DATE,
FOREIGN KEY (order_id) REFERENCES Orders(order_id)
);

You might also like