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

Dbms+Tutorial+Sheet 1

This document provides a series of SQL queries to perform on tables in a sample database with Suppliers (S), Parts (P), and a Supplier Parts (SP) junction table. The queries include: 1) Creating the tables and defining primary and foreign keys 2) Inserting sample records 3) Performing queries to retrieve supplier names, quantities, colors, and other data based on criteria 4) Altering table structures and adding/dropping constraints

Uploaded by

Padam Garg
Copyright
© Attribution Non-Commercial (BY-NC)
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)
141 views2 pages

Dbms+Tutorial+Sheet 1

This document provides a series of SQL queries to perform on tables in a sample database with Suppliers (S), Parts (P), and a Supplier Parts (SP) junction table. The queries include: 1) Creating the tables and defining primary and foreign keys 2) Inserting sample records 3) Performing queries to retrieve supplier names, quantities, colors, and other data based on criteria 4) Altering table structures and adding/dropping constraints

Uploaded by

Padam Garg
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 2

DBMS TUTORIAL SHEET-1 SQL QUERIES:

5) Solve the following on the given database S(Sno. Sname ,City, Status)] P(Pno, Pname,Color, Weight) SP(Sno,Pno,Qty) 6) Create the above tables by identifying appropriate primary keys and foreign keys. 7) Apply Column level constraints such that Qty such that it may be only Amritsar, Delhi, Batala and Qadian. 8) Apply Column level constraints such Qty should be between 100 to 1000, weight NOT NULL , Sname is NOT NULL and Pname is UNIQUE. 9) Insert five records in each table 10) Get supplier name where city is Amritsar. 11) Get Quantity Supplied by Ajay. 12) Get the supplier name and city that supply part P1. 13) Get color of parts supplied by S1. 14) Get color of parts supplied by Ajay. 15) Get supplier name who supply at least one red part. 16) Get part name where weight>100 and Sno=S1. 17) Get supplier name who supply part P1 with Quantity>100. 18) Get supplier name who supply pencils with Quantity>100. 19) Get supplier number who supplies maximum quantity. 20) Get supplier number who supply quantity greater than average Quantity. 21) Get supplier name that supply maximum quantity. 22) Get total number of Suppliers. 23) Get total number of parts supplied by supplier S1.

24) Count the parts having red color. 25) Count red parts supplied by Ajay. 26) Get the total quantity supplied by S1. 27). Get maximum quantity supplied by S1. 28) Get maximum quantity supplied by Rakesh. 29) Get total quantity supplied for each supplier. 30) Get total number of records supplied for each part. 31) Increase the Quantity of part P1 by 10 %. 32) Change the color of Red parts supplied by Ajay to Green. 33) Delete all the red parts supplied by supplier S1. 34) Delete all the entries of part P1. 35) Create view on table S that contains Sno and Sname of suppliers Amritsar. 36) Create a sequence that has minimum value 100 and maximum 1000. 37) Use the above sequence to store quantity information. 38) Alter the structure of table S to change the width of column Sname. 39) Alter the structure of table P to apply constraint NOT NULL on column color. 40) Drop view created above.

You might also like