










Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!











Ayesha
Saqib^ Azair DATA
DATABASE
INTRODUCTION This inventory management system helps track products, brands, and stores while managing customer purchases. It allows adding new items, viewing data, and processing transactions efficiently. The system is built using a MySQL database and provides essential tools to streamline inventory and sales management.. Aim and Objectives Aims:
-- Create provides table CREATE TABLE provides ( bid INT NOT NULL, sid INT NOT NULL, discount DECIMAL( 5 , 2 ), PRIMARY KEY (bid, sid), FOREIGN KEY (bid) REFERENCES brands(bid), FOREIGN KEY (sid) REFERENCES stores(sid) ); -- Create customer_cart table CREATE TABLE customer_cart ( cust_id INT PRIMARY KEY, name VARCHAR( 20 ) NOT NULL, mobno VARCHAR( 10 ) -- Changed to VARCHAR to accommodate non-numeric characters ); -- Create select_product table CREATE TABLE select_product ( cust_id INT NOT NULL, pid INT NOT NULL, quantity INT NOT NULL, PRIMARY KEY (cust_id, pid), FOREIGN KEY (cust_id) REFERENCES customer_cart(cust_id), FOREIGN KEY (pid) REFERENCES product(pid) ); -- Create [transaction] table CREATE TABLE [transaction] ( id INT PRIMARY KEY, total_amount DECIMAL( 10 , 2 ) NOT NULL, paid DECIMAL( 10 , 2 ) NOT NULL, due DECIMAL( 10 , 2 ) NOT NULL, gst DECIMAL( 5 , 2 ), discount DECIMAL( 10 , 2 ), payment_method VARCHAR( 10 ), cart_id INT NOT NULL, FOREIGN KEY (cart_id) REFERENCES customer_cart(cust_id) ); -- Create invoice table CREATE TABLE invoice ( item_no INT NOT NULL, product_name VARCHAR( 20 ) NOT NULL, quantity INT NOT NULL, net_price DECIMAL( 10 , 2 ) NOT NULL,
transaction_id INT NOT NULL, PRIMARY KEY (item_no, transaction_id), FOREIGN KEY (transaction_id) REFERENCES transaction );
INSERT INTO brands (bid, bname) VALUES ( 1 , 'BrandA'), ( 2 , 'BrandB'), ( 3 , 'BrandC'), ( 4 , 'BrandD'), ( 5 , 'BrandE'); INSERT INTO inv_user (user_id, name, password, last_login, user_type) VALUES ('user1', 'Alice', 'password1', '2024- 09 - 01 10:00:00', 'admin'), ('user2', 'Bob', 'password2', '2024- 09 - 02 11:30:00', 'user'), ('user3', 'Charlie', 'password3', '2024- 09 - 03 12:45:00', 'user'), ('user4', 'David', 'password4', '2024- 09 - 04 13:00:00', 'user'), ('user5', 'Eve', 'password5', '2024- 09 - 05 14:15:00', 'admin'); INSERT INTO categories (cid, category_name) VALUES ( 1 , 'Electronics'), ( 2 , 'Clothing'), ( 3 , 'Books'), ( 4 , 'Furniture'), ( 5 , 'Toys'); INSERT INTO stores (sid, sname, address, mobno) VALUES ( 1 , 'Store1', '123 Main St', '1234567890'), ( 2 , 'Store2', '456 Elm St', '2345678901'), ( 3 , 'Store3', '789 Oak St', '3456789012'), ( 4 , 'Store4', '101 Pine St', '4567890123'), ( 5 , 'Store5', '202 Maple St', '5678901234'); INSERT INTO product (pid, cid, bid, sid, pname, p_stock, price, added_date) VALUES ( 1 , 1 , 1 , 1 , 'Laptop', 10 , 999.99, '2024- 09 - 01'), ( 2 , 2 , 2 , 2 , 'Jacket', 50 , 79.99, '2024- 09 - 02'), ( 3 , 3 , 3 , 3 , 'Novel', 100 , 19.99, '2024- 09 - 03'), ( 4 , 4 , 4 , 4 , 'Sofa', 5 , 499.99, '2024- 09 - 04'), ( 5 , 5 , 5 , 5 , 'Action Figure', 25 , 29.99, '2024- 09 - 05'); INSERT INTO provides (bid, sid, discount) VALUES ( 1 , 1 , 10.00), ( 2 , 2 , 15.00), ( 3 , 3 , 5.00), ( 4 , 4 , 20.00), ( 5 , 5 , 10.00); INSERT INTO customer_cart (cust_id, name, mobno) VALUES
Product table
: Provides table: Customer_cart table: Select_product table:
Explanation of the Inventory Management System Query (ER Diagram)
brands 7 al product pt ER provides bat bat Paleck t dacot stores 1 al categories E cgury.т aldrs mabr inv user transaction TWITH pawrd lnt login aerJype inv_user customor cart 1 cint af TMETH 1 due g dacaat payтw^ тld 8 select product cint af invoice ENTING product nат qy rt prce qay 8
Q2: