0% found this document useful (0 votes)
6 views2 pages

Task 2 DDL

The document outlines the SQL schema for an e-commerce database, including tables for customers, products, categories, orders, order items, payment details, reviews, and inventory. Each table is defined with specific fields, data types, and constraints to manage various aspects of the e-commerce platform. Key features include unique identifiers for records, relationships between tables, and data integrity checks such as rating limits for reviews.

Uploaded by

Pavan Kumar
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)
6 views2 pages

Task 2 DDL

The document outlines the SQL schema for an e-commerce database, including tables for customers, products, categories, orders, order items, payment details, reviews, and inventory. Each table is defined with specific fields, data types, and constraints to manage various aspects of the e-commerce platform. Key features include unique identifiers for records, relationships between tables, and data integrity checks such as rating limits for reviews.

Uploaded by

Pavan Kumar
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/ 2

--Customer table

create table customers(


customer_id int auto_increment primary key,
full_name varchar(100) not null,
e_mail varchar(50) unique not null,
phone_number varchar(20) unique,
passwordu varchar(20) not null unique,
address text,
registration_date Date);
--product table
create table Product_details(
product_id int auto_increment primary key,
product_name varchar(100) not null,
descriptionu text,
price decimal(10,2) not null,
stock_quantity int not null,
category_id int not null,
added_date Date);
--category table
create table category(
category_id int auto_increment primary key,
category_name varchar(100) not null,
descriptionu text)
--orders
create table orders(
order_id int auto_increment primary key,
customer_id int unique not null,
order_date date not null,
total_amount int not null,
order_status enum('pending','shipped','delivered','cancelled'));
--order_items
create table order_items(
order_item_id int auto_increment primary key,
order_id int unique not null,
product_id int not null,
quantity int not null,
price_at_purchase int not null);
--Payment details table
create table payment(
payment_id int auto_increment primary key,
order_id int unique not null,
customer_id int not null,
payment_method enum('credit card','debit card','paypal','COD'),
payment_status enum('pending','completed', 'failed'),
transaction_date date not null);
--reviews table
create table reviews(
review_id int auto_increment primary key,
customer_id int not null,
product_id int not null,
rating int check (rating between 1 and 5),
review text,
review_date datetime default current_timestamp);
--inventory table
create table inventory(
inventory_id int auto_increment primary key,
product_id int not null,
quantity_added int ,
quantity_removed int,
updated_date datetime default current_timestamp);

You might also like