0% found this document useful (0 votes)
4 views5 pages

Exp7 8 Online Shopping

The document outlines two experiments focused on SQL queries for an Online Shopping System. Experiment 07 demonstrates nested and complex queries to retrieve data related to customers, sellers, and products, while Experiment 08 covers Data Control Language (DCL) and Transaction Control Language (TCL) commands for managing permissions and transactions. Both experiments conclude with successful execution of the respective SQL operations.

Uploaded by

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

Exp7 8 Online Shopping

The document outlines two experiments focused on SQL queries for an Online Shopping System. Experiment 07 demonstrates nested and complex queries to retrieve data related to customers, sellers, and products, while Experiment 08 covers Data Control Language (DCL) and Transaction Control Language (TCL) commands for managing permissions and transactions. Both experiments conclude with successful execution of the respective SQL operations.

Uploaded by

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

EXPERIMENT NO:-07

Aim: Perform Nested and Complex Queries for Online Shopping System

Theory:

Nested and complex queries involve subqueries and set operations to retrieve complex data

relations. These queries help filter and aggregate data based on certain conditions.

Case Study: Online Shopping System

Entities: Seller, Customer, Product, Order

Nested and Complex Queries:

1. List all customers who placed orders for products in the 'Electronics' category.

SELECT Name

FROM Customers

WHERE Customer_ID IN (

SELECT DISTINCT Order_CustomerID

FROM Orders

WHERE Product_ID IN (

SELECT Product_ID

FROM Products

WHERE Category = 'Electronics'

);
2. List product names sold by sellers located in 'Mumbai'.

SELECT Product_Name

FROM Products

WHERE Seller_ID IN (

SELECT Seller_ID

FROM Sellers

WHERE City = 'Mumbai'

);

3. Find sellers who have sold products but do not have any pending orders.

SELECT Seller_ID, Seller_Name

FROM Sellers

WHERE Seller_ID NOT IN (

SELECT DISTINCT Seller_ID

FROM Orders

WHERE Order_Status = 'Pending'

);

4. Display product names that are available in both 'Electronics' and 'Home Appliances' categories.

SELECT Product_Name

FROM Products

WHERE Category = 'Electronics'

INTERSECT

SELECT Product_Name

FROM Products
WHERE Category = 'Home Appliances';

5. Find customers who placed orders but never ordered products costing above 10,000.

SELECT Customer_ID, Name

FROM Customers

WHERE Customer_ID IN (

SELECT DISTINCT Order_CustomerID

FROM Orders

) AND Customer_ID NOT IN (

SELECT DISTINCT Order_CustomerID

FROM Orders

WHERE Total_Amount > 10000

);

Conclusion: Nested and complex queries were successfully performed for the Online Shopping

System.

---

EXPERIMENT NO:-08

Aim: Perform DCL and TCL Commands for Online Shopping System

Theory:

- DCL (Data Control Language) includes GRANT and REVOKE commands for permissions.

- TCL (Transaction Control Language) includes COMMIT, ROLLBACK, and SAVEPOINT for
transaction management.

DCL Commands:

1. Grant SELECT and INSERT permission on Orders to user 'admin'.

GRANT SELECT, INSERT ON Orders TO 'admin'@'localhost';

2. Revoke UPDATE permission on Products from user 'admin'.

REVOKE UPDATE ON Products FROM 'admin'@'localhost';

TCL Commands:

1. COMMIT Example:

START TRANSACTION;

UPDATE Products SET Price = Price * 0.95 WHERE Category = 'Fashion';

COMMIT;

2. ROLLBACK Example:

START TRANSACTION;

DELETE FROM Orders WHERE Order_Status = 'Cancelled';

ROLLBACK;

3. SAVEPOINT Example:

START TRANSACTION;

UPDATE Customers SET City = 'Pune' WHERE City = 'Mumbai';

SAVEPOINT sp1;
UPDATE Customers SET City = 'Delhi' WHERE City = 'Chennai';

ROLLBACK TO sp1;

COMMIT;

Conclusion: Successfully performed DCL and TCL commands on the Online Shopping System

database.

You might also like