0% found this document useful (0 votes)
3 views

CSE433P-DBMS lab.docx (1) (1)

The document outlines three experiments focused on database design and SQL commands. The first experiment involves creating an Entity-Relationship Diagram (ERD) for a banking system, while the second and third experiments cover Data Definition Language (DDL) and Data Manipulation Language (DML) commands in RDBMS. Each section includes aims, questions, and solutions related to database creation, manipulation, and querying.

Uploaded by

Piyush Kumar 15
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)
3 views

CSE433P-DBMS lab.docx (1) (1)

The document outlines three experiments focused on database design and SQL commands. The first experiment involves creating an Entity-Relationship Diagram (ERD) for a banking system, while the second and third experiments cover Data Definition Language (DDL) and Data Manipulation Language (DML) commands in RDBMS. Each section includes aims, questions, and solutions related to database creation, manipulation, and querying.

Uploaded by

Piyush Kumar 15
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/ 16

4BTCS A​ ​ ​ ​ ​

​ ​ ​ ​ ​
2360479 - VIDHI GARG

Exp. No : 1
DATABASE DESIGN USING E-R MODEL
Date :

AIM:
To Study, understand and Implementing the Database Design Using ER Model for a selective
application.

Question:
Design an E-R diagram for the university database.
Entity-Relationship Model:

This represents an Entity Relationship Diagram (ERD) for a banking system. The ERD
provides a visual representation of the relationships between entities in the system, including
customers, accounts, transactions, loans, branches, and banks.
The banking system is a complex system that involves various entities and relationships. The
ERD is a powerful tool that helps to model and understand these relationships. It provides a clear
and concise representation of the data structure, making it easier to design and implement a
relational database.
The ERD presented in this report is the result of a thorough analysis of the banking system. It

1
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG

takes into account the various entities, attributes, and relationships that exist in the system. The
ERD is a critical component of the database design process, as it helps to ensure that the database
is properly structured and organized.
The benefits of using an ERD in database design include:
Improved data modeling
Reduced data redundancy
Enhanced data integrity
Improved data sharing and integration
Better support for data security and access control
ENTITIES:
The following entities are included in the ERD:
1. Customer: Represents an individual or organization that banks with the institution.
2. Account: Represents a financial account held by a customer.
3. Transaction: Represents a financial transaction made on an account.
4. Loan: Represents a loan provided to a customer.
5. Branch: Represents a physical branch of the bank.
6. Bank: Represents the banking institution itself.
RELATIONSHIP:
The following relationships exist between the entities:
1. Customer-Account: A customer can have multiple accounts, but each account belongs to one
customer (one-to-many).
2. Account-Transaction: An account can have multiple transactions, but each transaction belongs
to one account (one-to-many).
3. Customer-Loan: A customer can take multiple loans, but each loan is associated with one
customer (one-to-many).
4. Branch-Account/Loan: A branch can manage multiple accounts and loans, but each
account/loan belongs to a single branch (one-to-many).
5. Branch-Bank: Each branch belongs to one bank, and a bank can have multiple branches
(oneto-many).
Result:
Thus, the Database Design Using ER Model for a selective application has been studied,
understood and implemented successfully.

2
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG

Exp. No : 2
Data Definition Language (DDL) and Data Manipulation
Date :20/11/2024 Language (DML) Commands in RDBMS

AIM:
To implement the Commands of Data Definition Language (DDL) and Data Manipulation
Language for a Selective application in RDBMS.
Question:
a)​ Create Tables as follows by choosing appropriate data type:
●​ Customer (Custid, Custname, Age, phno)
●​ Loan (Loanid, Amount, Custid, Emi)
●​ VLoan (VLoanid, Amount, Custid)
b)​ Use DESC Command to display the created table schemas.
c)​ Rename the table customer as tbl_customer, loan table as tbl_hloan and VLoan as tbl_vloan.
d)​ Rename the column Custid as customer_id in the table tbl_customer.
e)​ Rename the column Loanid as hloan_id in the table tbl_hloan.
f)​ Add a column cust_address in tbl_customer table
g)​ Add rate_od_intrest column in both the table tbl_hloan and tbl_vloan.
h)​ Modify the type of an column in all the tables.
i)​ Remove the column phno from tbl_customer.
j)​ Add primary key constraint for the columns customer_id in tbl_customer, hloadn_id in
tbl_tbl_hloan and vloanid in tbl_vloan.
k)​ Drop the table tbl_vloan and recreate it.
l)​ Insert minimum 10 rows for each table in different ways of insert query. (while inserting the
data cust_id, column value in the tbl_customer should be match with the value of both the
tables tbl_hloan, tbl_vloan column cust_id).

Solution:
SQL> CREATE table Customer(Cust_id number(10),Cust_name varchar(10),Age number(2),phno
number(10));
Table created.
SQL> CREATE table Loan(loanid number(10),amount number(10),Cust_id number(10),Emi
number(10));
Table created.
SQL> CREATE table Vloan(Vloanid number(10),amount number(10),custid number(10));
Table created.
SQL> desc Customer;
Name Null? Type
----------------------------------------- -------- ----------------------------
CUST_ID NUMBER(10)

3
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
CUST_NAME VARCHAR2(10)
AGE NUMBER(2)
PHNO NUMBER(10)
SQL> desc Loan;
Name Null? Type
----------------------------------------- -------- ----------------------------
LOANID NUMBER(10)
AMOUNT NUMBER(10)
CUST_ID NUMBER(10)
EMI NUMBER(10)
SQL> desc Vloan;
Name Null? Type
----------------------------------------- -------- ----------------------------
VLOANID NUMBER(10)
AMOUNT NUMBER(10)
CUSTID NUMBER(10)
SQL> Rename Customer to tbl_Customer;
Table renamed.
SQL> Rename Loan to tbl_hloan;
Table renamed.
SQL> Rename Vloan to tbl_Vloan;
Table renamed.
SQL> Alter table tbl_Customer RENAME COLUMN Cust_id to customer_id;
Table altered.
SQL> Alter table tbl_hloan RENAME COLUMN loanid to hloan_id;
Table altered.
SQL> Alter table tbl_Customer ADD cust_address varchar(15);
Table altered.
SQL> desc tbl_Customer;
Name Null? Type
----------------------------------------- -------- ----------------------------
CUSTOMER_ID NUMBER(10)
CUST_NAME VARCHAR2(10)

4
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
AGE NUMBER(2)
PHNO NUMBER(10)
CUST_ADDRESS VARCHAR2(15)
SQL> Alter table tbl_Customer MODIFY customer_id varchar(10);
Table altered.
SQL> Alter table tbl_Customer DROP COLUMN Cust_name;
Table altered.
SQL> Alter table tbl_Customer ADD CONSTRAINT cusid PRIMARY KEY(customer_id);
Table altered.
SQL> Alter table tbl_hloan ADD CONSTRAINT loanid PRIMARY KEY(hloan_id);
Table altered.
SQL> Alter table tbl_Vloan ADD CONSTRAINT vloanid PRIMARY KEY(Vloanid);
Table altered.
SQL> Drop table tbl_Vloan;
Table dropped.
SQL> CREATE table Vloan(hVloanid number(10),amount number(10),Cust_id number(10));
Table created.

Result:
​ Thus, the implementation of Data Definition Language (DDL) and Data Manipulation Language
(DML) commands for a Selective application in RDBMS has been successfully executed and verified.

5
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
Exp. No : 3
(DML) Commands
Date :09/12/2024

AIM:
To understand and implement Data Manipulation Language (DML) commands using select queries.

Question 1:
1. Display the last_name, job_id, department_id of the employee whose last name starts with ‘W’.
2. Select the employee first_name, salary, department_id and display who are all getting more than
3000 as salary from employees table
3. Fetch the salary between 2500 and 3500 and display the employee last name, department id and
salary.
4. Display the employee_id and salary from the employees table of those who have their manager id as
100,201.
5. list the employees first_name, department_id whose names contain the substring 'man' anywhere in
their name.
6. List all unique departments present in the employee table.
Question 2:
A supermarket manager likes to keep records about all the items in his store these records should hold
the following information about each item (Attributes are item_id, item_name, item_price, item_color,
quantity in hand)
7. Create the appropriate table(Tuple = 4)
8. List the names and prices for all items that have a quantity in hand >20.
9. Add a new attribute Seller Name.
10. Add a unique name for the seller name column.
11. Find out the lowest, highest price of the items and display the item id, item name from the table.
12. What is the average price of all the items? 13. Count the total no of items where price is greater than
2500.

Solution:
SQL> SELECT last_name,job_id,department_id FROM employees WHERE last_name LIKE 'W%';
LAST_NAME JOB_ID DEPARTMENT_ID
------------------------- ---------- -------------
Walsh SH_CLERK 50
Weiss ST_MAN 50
Whalen AD_ASST 10

6
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
3 rows selected.
SQL> SELECT first_name,salary,department_id FROM employees WHERE salary>3000;
FIRST_NAME SALARY DEPARTMENT_ID
-------------------- ----------- -------------
Steven 24000 90
Neena 17000 90
Lex 17000 90
Alexander 9000 60
Bruce 6000 60
David 4800 60
Valli 4800 60
Diana 4200 60
Nancy 12000 100
Daniel 9000 100
John 8200 100
Ismael 7700 100
Jose Manuel 7800 100
Luis 6900 100
Den 11000 30
Alexander 3100 30
Matthew 8000 50
Adam 8200 50
Payam 7900 50
Shanta 6500 50
Kevin 5800 50
Julia 3200 50
Laura 3300 50
Jason 3300 50
Renske 3600 50
Stephen 3200 50
Trenna 3500 50
Curtis 3100 50
John 14000 80
Karen 13500 80
Alberto 12000 80

7
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
Gerald 11000 80
Eleni 10500 80
Peter 10000 80
David 9500 80
Peter 9000 80
Christopher 8000 80
Nanette 7500 80
Oliver 7000 80
Janette 10000 80
Patrick 9500 80
Allan 9000 80
Lindsey 8000 80
Louise 7500 80
Sarath 7000 80
Clara 10500 80
Danielle 9500 80
Mattea 7200 80
David 6800 80
Sundar 6400 80
Amit 6200 80
Lisa 11500 80
Harrison 10000 80
Tayler 9600 80
William 7400 80
Elizabeth 7300 80
Sundita 6100 80
Ellen 11000 80
Alyssa 8800 80
Jonathon 8600 80
Jack 8400 80
Kimberely 7000
Charles 6200 80
Winston 3200 50
Jean 3100 50
Nandita 4200 50

8
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
Alexis 4100 50
Julia 3400 50
Kelly 3800 50
Jennifer 3600 50
Sarah 4000 50
Britney 3900 50
Samuel 3200 50
Alana 3100 50
Jennifer 4400 10
Michael 13000 20
Pat 6000 20
Susan 6500 40
Hermann 10000 70
Shelley 12000 110
William 8300 110
81 rows selected.
SQL> SELECT last_name, department_id,salary FROM employees WHERE salary BETWEEN 2500
AND 3500;
LAST_NAME DEPARTMENT_ID SALARY
------------------------- ------------- ----------
Khoo 30 3100
Baida 30 2900
Tobias 30 2800
Himuro 30 2600
Colmenares 30 2500
Nayer 50 3200
Mikkilineni 50 2700
Bissot 50 3300
Atkinson 50 2800
Marlow 50 2500
Mallin 50 3300
Rogers 50 2900
Stiles 50 3200
Seo 50 2700
Patel 50 2500

9
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
Rajs 50 3500
Davies 50 3100
Matos 50 2600
Vargas 50 2500
Taylor 50 3200
Fleaur 50 3100
Sullivan 50 2500
Geoni 50 2800
Dellinger 50 3400
Cabrio 50 3000
Gates 50 2900
Perkins 50 2500
McCain 50 3200
Jones 50 2800
Walsh 50 3100
Feeney 50 3000
OConnell 50 2600
Grant 50 2600
33 rows selected.
SQL> SELECT employee_id,salary FROM employees WHERE manager_id IN(100,201);
EMPLOYEE_ID SALARY
----------- ----------
101 17000
102 17000
114 11000
120 8000
121 8200
122 7900
123 6500
124 5800
145 14000
146 13500
147 12000
148 11000
149 10500

10
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
201 13000
202 6000
15 rows selected.
SQL> SELECT employee_id,department_id FROM employees WHERE first_name LIKE '%man%';
EMPLOYEE_ID DEPARTMENT_ID
----------- -------------
204 70
1 row selected.
SQL> SELECT DISTINCT * FROM employees;
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE
JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
----------- -------------------- ------------------------------------------------- -------------------- --------- ----------
108 Nancy Greenberg NGREENBE 515.124.4569 17-AUG-94 FI_MGR 12000 101 100
110 John Chen JCHEN 515.124.4269 28-SEP-97 FI_ACCOUNT 8200 108 100
133 Jason Mallin JMALLIN 650.127.1934 14-JUN-96 ST_CLERK 3300 122 50
139 John Seo JSEO 650.121.2019 12-FEB-98 ST_CLERK 2700 123 50
143 Randall Matos RMATOS 650.121.2874 15-MAR-98 ST_CLERK 2600 124 50
144 Peter Vargas PVARGAS 650.121.2004 09-JUL-98 ST_CLERK 2500 124 50
145 John Russell JRUSSEL 011.44.1344.429268 01-OCT-96 SA_MAN 14000.4 100 80
159 Lindsey Smith LSMITH 011.44.1345.729268 10-MAR-97 SA_REP 8000.3 146 80
160 Louise Doran LDORAN 011.44.1345.629268 15-DEC-97 SA_REP 7500.3 146 80
167 Amit Banda ABANDA 011.44.1346.729268 21-APR-00 SA_REP 6200.1 147 80
170 Tayler Fox TFOX 011.44.1343.729268 24-JAN-98 SA_REP 9600.2 148 80
175 Alyssa Hutton AHUTTON 011.44.1644.429266 19-MAR-97 SA_REP 8800.25 149 80
203 Susan Mavris SMAVRIS 515.123.7777 07-JUN-94 HR_REP 6500 101 40
105 David Austin DAUSTIN 590.423.4569 25-JUN-97 IT_PROG 4800 103 60
119 Karen Colmenares KCOLMENA 515.127.4566 10-AUG-99 PU_CLERK 2500 114 30
123 Shanta Vollman SVOLLMAN 650.123.4234 10-OCT-97 ST_MAN 6500 100 50
127 James Landry JLANDRY 650.124.1334 14-JAN-99 ST_CLERK 2400 120 50
147 Alberto Errazuriz AERRAZUR 011.44.1344.429278 10-MAR-97 SA_MAN 12000.3 100 80
150 Peter Tucker PTUCKER 011.44.1344.129268 30-JAN-97 SA_REP 10000 .3 145 80
153 Christopher Olsen COLSEN 011.44.1344.498718 30-MAR-98 SA_REP 8000 .2 145 80
154 Nanette Cambrault NCAMBRAU 011.44.1344.987668 09-DEC-98 SA_REP 7500 .2 145 80
163 Danielle Greene DGREENE 011.44.1346.229268 19-MAR-99 SA_REP 9500 .15 147 80
169 Harrison Bloom HBLOOM 011.44.1343.829268 23-MAR-98 SA_REP 10000 .2 148 80
171 William Smith WSMITH 011.44.1343.629268 23-FEB-99 SA_REP 7400 .15 148 80
11
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
173 Sundita Kumar SKUMAR 011.44.1343.329268 21-APR-00 SA_REP 6100 .1 148 80
179 Charles Johnson CJOHNSON 011.44.1644.429262 04-JAN-00 SA_REP 6200 .1 149 80
194 Samuel McCain SMCCAIN 650.501.3876 01-JUL-98 SH_CLERK 3200 123 50
195 Vance Jones VJONES 650.501.4876 17-MAR-99 SH_CLERK 2800 123 50
109 Daniel Faviet DFAVIET 515.124.4169 16-AUG-94 FI_ACCOUNT 9000 108 100
113 Luis Popp LPOPP 515.124.4567 07-DEC-99 FI_ACCOUNT 6900 108 100
130 Mozhe Atkinson MATKINSO 650.124.6234 30-OCT-97 ST_CLERK 2800 121 50
178 Kimberely Grant KGRANT 011.44.1644.429263 24-MAY-99 SA_REP 7000 .15 149
180 Winston Taylor WTAYLOR 650.507.9876 24-JAN-98 SH_CLERK 3200 120 50
188 Kelly Chung KCHUNG 650.505.1876 14-JUN-97 SH_CLERK 3800 122 50
112 Jose Manuel Urman JMURMAN 515.124.4469 07-MAR-98 FI_ACCOUNT 7800 108 100
142 Curtis Davies CDAVIES 650.121.2994 29-JAN-97 ST_CLERK 3100 124 50
152 Peter Hall PHALL 011.44.1344.478968 20-AUG-97 SA_REP 9000 .25 145 80
155 Oliver Tuvault OTUVAULT 011.44.1344.486508 23-NOV-99 SA_REP 7000 .15 145 80
158 Allan McEwen AMCEWEN 011.44.1345.829268 01-AUG-96 SA_REP 9000 .35 146 80
164 Mattea Marvins MMARVINS 011.44.1346.329268 24-JAN-00 SA_REP 7200 .1 147 80
183 Girard Geoni GGEONI 650.507.9879 03-FEB-00 SH_CLERK 2800 120 50
186 Julia Dellinger JDELLING 650.509.3876 24-JUN-98 SH_CLERK 3400 121 50
187 Anthony Cabrio ACABRIO 650.509.4876 07-FEB-99 SH_CLERK 3000 121 50
190 Timothy Gates TGATES 650.505.3876 11-JUL-98 SH_CLERK 2900 122 50
196 Alana Walsh AWALSH 650.507.9811 24-APR-98 SH_CLERK 3100 124 50
202 Pat Fay PFAY 603.123.6666 17-AUG-97 MK_REP 6000 201 20
111 Ismael Sciarra ISCIARRA 515.123.4369 30-SEP-97 FI_ACCOUNT 7700 108 100
120 Matthew Weiss MWEISS 650.123.1234 18-JUL-96 ST_MAN 8000 100 50
122 Payam Kaufling PKAUFLIN 650.123.3234 01-MAY-95 ST_MAN 7900 100 50
131 James Marlow JAMRLOW 650.124.7234 16-FEB-97 ST_CLERK 2500 121 50
137 Renske Ladwig RLADWIG 650.121.1234 14-JUL-95 ST_CLERK 3600 123 50
148 Gerald Cambrault GCAMBRAU 011.44.1344.619268 15-OCT-99 SA_MAN 11000 .3 100 80
161 Sarath Sewall SSEWALL 011.44.1345.529268 03-NOV-98 SA_REP 7000 .25 146 80
166 Sundar Ande SANDE 011.44.1346.629268 24-MAR-00 SA_REP 6400 .1 147 80
174 Ellen Abel EABEL 011.44.1644.429267 11-MAY-96 SA_REP 11000 .3 149 80
176 Jonathon Taylor JTAYLOR 011.44.1644.429265 24-MAR-98 SA_REP 8600 .2 149 80
177 Jack Livingston JLIVINGS 011.44.1644.429264 23-APR-98 SA_REP 8400 .2 149 80
184 Nandita Sarchand NSARCHAN 650.509.1876 27-JAN-96 SH_CLERK 4200 121 50
192 Sarah Bell SBELL 650.501.1876 04-FEB-96 SH_CLERK 4000 123 50

12
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
198 Donald OConnell DOCONNEL 650.507.9833 21-JUN-99 SH_CLERK 2600 124 50
102 Lex De Haan LDEHAAN 515.123.4569 13-JAN-93 AD_VP 17000 100 90
103 Alexander Hunold AHUNOLD 590.423.4567 03-JAN-90 IT_PROG 9000 102 60
107 rows selected.
SQL> CREATE TABLE Tuple(item_id number(10),item_name varchar(10),item_price
number(10),item_color varchar(10),quantity number(10));
Table created.
SQL> SELECT * from Tuple;
ITEM_ID ITEM_NAME ITEM_PRICE ITEM_COLOR QUANTITY
---------- ---------- ---------- ---------- ----------
100 TOOTHPASTE 30 RED 10
101 TOOTHBRUSH 20 WHITE 5
102 BOOK 50 BLUE 40
10 BOTTLE 250 GREY 60
104 PEN 15 BLACK 100
105 POWDER 150 WHITE 3
106 MAGGIE 14 YELLOW 42
7 rows selected.
SQL> SELECT item_name,item_price FROM Tuple WHERE quantity>20;
ITEM_NAME ITEM_PRICE
---------- ----------
BOOK 50
BOTTLE 250
PEN 15
MAGGIE 14
4 rows selected.
SQL> Alter table Tuple ADD seller_name varchar(10);
Table altered.
SQL>ALTER TABLE Tuple ADD CONSTRAINT unique_seller_name UNIQUE (seller_name);
Table altered.
SQL>SELECT item_id, item_name, item_price FROM Tuple WHERE item_price = (SELECT
MIN(item_price) FROM Tuple);
ITEM_ID ITEM_NAME ITEM_PRICE
---------- ---------- ----------
106 MAGGIE 14
1 row selected
13
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
SQL>SELECT item_id, item_name, item_price FROM Tuple WHERE item_price = (SELECT
MAX(item_price) FROM Tuple);
ITEM_ID ITEM_NAME ITEM_PRICE
---------- ---------- ----------
103 BOTTLE 250
1 row selected
SQL>SELECT AVG(item_price) AS average_price FROM Tuple;
AVERAGE_PRICE
-------------
75.5714285714
1 row selected
SQL>SELECT COUNT(*) AS total_items_above_2500 FROM Tuple WHERE item_price > 2500;
TOTAL_ITEMS_ABOVE_2500
----------------------
0
1 row selected

14
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG
Exp. No : 5
VIEWS
Date :08/01/2025

AIM:
To understand and implement Views queries.
Questions :
1. Write a query to create a view named CustomerCityView that includes CustomerID,
CustomerName, and City from the Customer table.
2. Write a query to create a view named CustomerOrderSummary that combines data from Customer
and OrderDetails. Include the columns CustomerName, City, OrderedItem, and OrderAmount.
3. Modify the CustomerCityView view to include the ContactNumber column. Use the CREATE OR
REPLACE VIEW statement.
4. Create a view named ChennaiOrdersView that displays all orders placed by customers from
Chennai. Use a join between Customer and OrderDetails.
5. Create a view named ElectronicsOrders that displays all orders where the OrderedItem is
"Electronics."
6. Create a view named CustomerOrdersView that includes CustomerID and OrderAmount. Write a
query to delete an order from the OrderDetails table using this view.
7. Write a query to drop the CustomerCityView view from the database.
Solution:
SQL> SELECT * FROM Customer;
CUSTOMERID CUSTOMERNA CITY CONTACTNUMBER
---------- ---------- ---------- -------------
1 Alice Chennai 1236547890
2 Bob Banglore 4562317892
3 Charlie Mumbai 1542637895
4 Diana Delhi 1452369870
SQL> SELECT * FROM OrderDetails;
ORDERID CUSTOMERID ORDERAMOUNT ORDEREDITEM
---------- ---------- ----------- --------------------
101 1 500 Books
102 2 1000 Electronics
103 3 750 Kitchen Appliances
104 4 1200 Funiture
SQL> CREATE VIEW CustomerCityView AS SELECT CustomerID,CustomerName,City FROM
Customer;

15
4BTCS A​ ​ ​ ​ ​
​ ​ ​ ​ ​
2360479 - VIDHI GARG

View created.
SQL> CREATE VIEW CustomerOrderSummary AS SELECT
Customer.CustomerName,Customer.City,OrderDetails.OrderedItem,OrderDetails.OrderAmount
FROM Customer JOIN OrderDetails ON Customer.CustomerID=OrderDetails.CustomerID;
View created.
SQL> CREATE OR REPLACE VIEW CustomerCityView AS SELECT
CustomerID,CustomerName,City,ContactNumber FROM Customer;
View created.
SQL> CREATE VIEW ChennaiOrdersView AS SELECT
OrderDetails.OrderID,OrderDetails.CustomerID,OrderDetails.OrderAmount,OrderDetails.OrderedIte
m FROM Customer JOIN OrderDetails ON Customer.CustomerID=OrderDetails.CustomerID
WHERE Customer.City='Chennai';
View created.
SQL> CREATE VIEW ElectronicsOrder AS SELECT * FROM OrderDetails WHERE
OrderedItem='Electronics';
View created.
SQL> CREATE VIEW CustomerOrdersView AS SELECT CustomerID,OrderAmount FROM
OrderDetails;
View created.
SQL> DELETE FROM OrderDetails WHERE OrderID=103;
1 row deleted.
SQL> DROP VIEW CustomerCityView;
View dropped.
SQL> spool off

16

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy