Professional Documents
Culture Documents
COM222 Test1 Marksheet
COM222 Test1 Marksheet
CA- ii
1. Introduction to Databases
a. Describe a database? (4)
[A shared collection (1) of logically related data (1) and its description (1),
designed to meet the information needs of an organization (1) --4]
b. How many distinct tuples are in a relation instance with cardinality 4,785? (2)
c. What is the difference between a super, candidate and primary key for a given relation?
(5)
[Super key: set of fields that uniquely identifies a tuple according to a key constraint
Candidate key: minimal set of fields that uniquely identifies a tuple according to a key
constraint - 2
Primary key: is a chosen candidate key among the many in a relation (1) that a DBMS
expects, prefers and optimizes to make references to tuples in the relation (2) -- 3]
d. Describe two major components of SQL. (4)
[DDL: Data definition language – statements used to create the DB structure and define
access mechanism – 2
DML: Data manipulation language – statements used to populate and query the tables –
2 --- 4]
e. What is the difference between a subquery (or nested query) and a join. Under what
circumstances would you not be able to use a subquery? (3)
[Subquery: - a select statement inside the WHERE (or HAVING) clause of another select
statement --- 1 mark
Join: - combines columns from several tables into a single result table --- 1 mark
A subquery cannot work when the columns in the result table must come from multiple
tables not just one as is the case with join – 1 --- 3]
2. Practical
a. Write a SQL statement to create a simple table countries, which already exists,
including columns country_id, country_name and region_id set a constraint on NULL
values; (5)
[CREATE TABLE IF NOT EXISTS countries (
COUNTRY_ID varchar(2) NOT NULL,
COUNTRY_NAME varchar(40) NOT NULL,
REGION_ID decimal(10,0) NOT NULL
);]
MAX_PRICE decimal(6,0)
CHECK(MAX_PRICE<=25000)
);]
c. Given the sample table of employees below. Write an SQL statement to change the
email and commission_pct column of employees table with 'not available' and 0.10 for
all employees in department with Id number 40. (3)
commission_pct=0.10
3. Map the the ERD below into relations. Assume that Act[a,b,c,d,e(FK)] represents mapping for an
entity/relationship “act” where a,b,..,e are its attributes, c represent primary key and (FK)
indicates attribute e is a foreign key. State any assumptions made. (15)
b) Contact(e_number(FK), contact)
c) Child(e_number(FK),name,dob)
d) Department(d_number,d_name,budget)
If d) then
f) Department(d_number,d_name,budget,emp_manager(FK),mgr_start_date)
If a) then
g) Course(c_number,credits,c_name,e-number(FK))
OR
h) Course(c_number,credits,c_name)
i) Teaches(e_number(FK),c_number(FK))
k) Course(c_number,credits,c_name)
[ ]