Docsity

A basic database Digital assessment, Exercises of Database Management Systems (DBMS)

Toggle sidebar
bg1
BCSE302L Database Systems
Task 4: To create Software Stores Management SystemConsider a database of a Software
Stores that stores details of PCs, Printers, and Laptops and it involves the following tables:
Product (maker, model, type);
PC (model, speed, ram, hd, cd, price);
Laptop (model, speed, ram, hd, screen, price);
Printer (model, color, type, price);
The Product relation gives the manufacturer, model number and type (PC, Laptop, Printer) of
various products. Assume that model numbers are unique.
The PC relation gives for each model number that is a PC, the speed of the processor in MHz,
RAM size in MB, size of hard disk in GB, the speed of the CD reader, and the price.
The Laptop relation is similar, except that the screen size in inches is recorded in the place of
CD speed.
The Printer relation records for each printer model, whether the printer produces color output
(T, if so), the process type (Laser/Inkjet/Dry) and the price.
1. Create these tables with appropriate key constraints in Oracle and populate them
using‘SWStores_Asgn1_create’file
2. Write the following queries in SQL:
(a)Find the hard disk sizes that occur in 2 or more PCs.
(b)Find the manufacturer of a color printer with lowest price.
(c)Find for each speed of PC above 150 MHz, the average price.
3. Validate the following by adding a check constraint while creating the table
(a) The speed of the Laptop computer must be at least 100.
(b) The speed of a CD can be only 4X, 6X, 8X or 12X.
(c) The color of Printer must be T or F
pf3

Partial preview of the text

Download A basic database Digital assessment and more Exercises Database Management Systems (DBMS) in PDF only on Docsity!

BCSE302L Database Systems Task 4: To create Software Stores Management SystemConsider a database of a Software

Stores that stores details of PCs, Printers, and Laptops and it involves the following tables:

Product (maker, model, type);

PC (model, speed, ram, hd, cd, price);

Laptop (model, speed, ram, hd, screen, price);

Printer (model, color, type, price);

The Product relation gives the manufacturer, model number and type (PC, Laptop, Printer) of various products. Assume that model numbers are unique.

The PC relation gives for each model number that is a PC, the speed of the processor in MHz, RAM size in MB, size of hard disk in GB, the speed of the CD reader, and the price.

The Laptop relation is similar, except that the screen size in inches is recorded in the place of CD speed.

The Printer relation records for each printer model, whether the printer produces color output (T, if so), the process type (Laser/Inkjet/Dry) and the price.

  1. Create these tables with appropriate key constraints in Oracle and populate them using‘SWStores_Asgn1_create’file
  2. Write the following queries in SQL:

(a)Find the hard disk sizes that occur in 2 or more PCs.

(b)Find the manufacturer of a color printer with lowest price.

(c)Find for each speed of PC above 150 MHz, the average price.

  1. Validate the following by adding a check constraint while creating the table (a) The speed of the Laptop computer must be at least 100. (b) The speed of a CD can be only 4X, 6X, 8X or 12X. (c) The color of Printer must be T or F

Syntax:

Check constraint

Column Level Check Constraint Write a query to create Check constraints with column level Syntax for clumn level constraints using Check:

CREATE <OBJ.TYPE> <OBJ.NAME> (COLUMN NAME.1 (SIZE) CONSTRAINT (CONSTRAITNS CRITERIA) , COLUMN NAME2 (SIZE));

Example CREATE TABLE EMP7(EMPNO NUMBER(3), ENAME VARCHAR2(20), DESIGN VARCHAR2(15), SAL NUMBER(5)CONSTRAINT EMP7_SAL_CK CHECK(SAL>500 AND SAL<10001), DEPTNO NUMBER(2));

Table Level Check Constraint: Write a query to create Check constraints with table level Syntax for Table level constraints using Check:

CREATE <OBJ.TYPE> <OBJ.NAME> (COLUMN NAME.1 (SIZE), (COLUMN NAME2 (SIZE), CONSTRAINT (CONSTRAITNS CRITERIA)) ; Example SQL>CREATE TABLE EMP8(EMPNO NUMBER(3), ENAME VARCHAR2(20),

DESIGN VARCHAR2(15), SAL NUMBER(5),DEPTNO NUMBER(2), CONSTRAINTS EMP8_SAL_CK CHECK(SAL>500 AND SAL<10001));

Check Constraint with Alter Command Write a query to create Check constraints with table level using alter command. Syntax for Table level constraints using Check:

CREATE <OBJ.TYPE> <OBJ.NAME> (COLUMN NAME.1 (SIZE), (COLUMN NAME2 (SIZE), CONSTRAINT (CONSTRAITNS CRITERIA)) ;