DBMS - Tutorial - 1
DBMS - Tutorial - 1
Table Name: PC
Column Name Purpose
Model_No The unique identifier for each PC
Speed Clock Speed of the PC
RAM RAM in MB
HD The hard-disk capacity of the PC in GB
CD The speed of the CD Drive
Price Price of the PC
The product_info table serves as a master table containing the list of all models of pc, laptop
and printers manufactured by all makers. The PC, Laptop and the printer table give specific
details about each product in that class.
6. Insert a tuple such that the model value is PC100, it is manufactured by HCL and has
a speed of 3 GHz, RAM of 256 MB, HD of 40 GB and CD of speed 52x. The price is
50000.
8. Manufacturer IBM buys manufacture HCL. Change all products made by HCL so
they are now made by IBM.
9. For each PC double the amount of RAM and add 10 gb to the HDD.
10. For the printer whose modelno=pr124 subtract Rs. 4000 from the price.
2. KEY CONSTRAINTS
1. Alter the table product_info to make the type column NOT NULL.
3. Create suitable primary keys for all the tables of the above database schema
a. Check if the primary keys are created successfully (User_Constraints table)
4. Create suitable foreign keys for all the tables of the above database schema
a. Check if the foreign keys are created successfully (User_Constraints table)
b. Demonstrate the usage of On delete cascade
5. Check Constraints:
a. Apply a check constraint on the product_info table such that the only permitted
values for the type column are ‘pc’, ‘lp’ and ‘pr’.
b. Apply a check constraint such that the prices of pc, laptop and printer are all
positive.
c. Check if the check constraints are created successfully (User_Constraints
table)
6. What are the different values for constraint_type in the user_constraints table and
what is the meaning of each of those values?
7. Create a table named ‘Type_info’ with the columns model , type from ProductInfo
table ( Use the “create table yyy as select” construct )
a. Initially no rows should be present in the dummy table
b. Insert all the rows from product_info into ‘Type_Info’ (only selected columns)
11. Without removing the table definition from the database remove all the rows from the
table ‘Type_info’.
Name Age
DICK JONES 33
WILLIAM SWING 30
BART SARJEANT 32
SUMA RANGANATH 21
RICHARD WILLIAMS 29
BHARTH KUMAR 36
JOHN PEARSON 28
JACKSON 34
MEENA KUMARI 29
ADAH TALBOT 27
1. List those rows of the table PC where RAM sizes are either ‘128’ or ‘256’ and the
capacity of HD is greater than or equal to 50.
2. List all the rows from PRINTER except the printers ‘pr112’ or ‘pr124’.
3. List all the rows from LAPTOP in ascending and descending order of the screen size.
4. List the makers of PC’s. Use ‘like’ operator in the model field (don’t use type).
5. List the laptop details where the screen size is not 17.
6. List the printers whose price is between 5000 and 10000. (Use between).
7. Give examples for any one arithmetic , logical operator , between … and & in.