IS222 S12018 FE Sample Answers
IS222 S12018 FE Sample Answers
Final Examination
Semester I 2018
INSTRUCTIONS
Instructions:
Identify and circle the choice that best completes the statement or answers the question in the
provided answer sheet on page 8. There is only one possible answer.
a. Multivalued, composite
b. Composite, multivalued
c. Simple, single valued
d. Single valued, simple
3) In the INVOICE_LINE table, the PROD_ID is listed for each product in the INVOICE_LINE
however; the PROD_ID is not used to uniquely identify an invoice line. In this ________
relationship between INVOICE_LINE and PRODUCT, INVOICE_LINE can be regarded as a
________ entity
5) Surrogate primary keys are especially helpful when there is no ____ key.
a. primary
b. foreign
c. Natural
d. None of the above
6) In the CUSTOMER table with CUS_ID as the primary key, _____ dependencies will not be
present when the table is in 1NF.
a. partial
b. transitive
c. functional
d. All of the above
9) A ____ is a textual representation of the database tables where each table is listed by its
name followed by the list of its attributes in parentheses.
a. relational dictionary
b. logical schema
c. relational schema
d. data dictionary
a. The number of attributes must be the same, and data types are alike.
b. The names of the relation attributes can be different, but the data types must be
identical.
c. The names of the relation attributes must be the same, but the data types can
be different.
d. The number of attributes must be the same but their data types can be different.
11) If an employee within an EMPLOYEE entity has a relationship with itself, that
relationship is known as a _____ relationship.
a. self
b. self-referring
c. looping
d. recursive
12) Attribute A _____ attribute B if all of the rows in the table that agree in value for
attribute A also agree in value for attribute B
a. determines
b. controls
c. derives from
d. owns
13) CUSTOMER table contains 12 rows, while the CUSTOMER_2 table contains 8 rows.
Customers Ronal and Sally are included in the CUSTOMER table as well as in the
CUSTOMER_2 table. How many records are returned when using the UNION operator?
a. 8
b. 12
c. 20
d. 18
14) When inserting a new record in a table, you must specify the keyword(s) ____ for any
fields in which you do not have a value.
a. BLANK
b. NULL
c. VOID
d. NO VALUE
15) One of the three most common data integrity and consistency problem is ___.
a. lost updates
b. disk failures
c. user errors
d. deadlocks
16) Which of these commands will delete a table called XXX if you have appropriate
authority?
a. DROP XXX
b. DROP XXX WHERE confirm = “YES”
c. DROP TABLE XXX
d. DELETE TABLE XXX
17) You must be logged in with the ____ account or have sufficient privileges to take away
privileges from another user account.
a. base
b. root
c. source
d. global
19) A ____ lock prevents the use of any tables in the database from one transaction while
another transaction is being processed.
a. database-level
b. table-level
c. page-level
d. row-level
Use the following case study to answer parts (a) to (d) of this question.
The aim of this case study is to design and develop a database for the hospital to maintain the
records of various departments, rooms, and doctors in the hospital. It also maintains records
of the regular patients, patients admitted in the hospital, the check-up of patients done by the
doctors, the patients that have been operated, and patients discharged from the hospital.
In hospital, there are many departments like Orthopaedic, Pathology, Emergency, Dental,
Gynaecology, Anaesthetics, I.C.U., Blood Bank, Operation Theatre, Laboratory, M.R.I.,
Neurology, Cardiology, Cancer Department, Corpse, etc. For each department, name, location
and facilities available should be stored. When patient arrives, a patient number is generated.
Other details like name, age, sex, address, city, phone number, entry date, and name of the
doctor referred to, diagnosis, and department name are also stored. After storing the
necessary details patient is sent to the doctor for check-up. There is an OPD where patients
come and get a card (that is, entry card of the patient) for check up from the concerned doctor.
After making entry in the card, they go to the concerned doctor’s room and the doctor checks
up their ailments. A doctor can check-up many patients. A patient can go to any doctor.
According to the ailments, the doctor either prescribes medicine or admits the patient in the
concerned department. The patient may choose either private or general room according to
his/her need. But before getting admission in the hospital, the patient has to fulfil certain
formalities of the hospital like room charges, etc. After the treatment is completed, the doctor
discharges the patient. Before discharging from the hospital, the patient again has to complete
certain formalities of the hospital like balance charges, test charges, operation charges (if any),
blood charges, doctors’ charges, etc. When patient is admitted, his/her related details are
stored in the database. Information stored includes patient number, advance payment, mode
of payment, room number, department, date of admission, initial condition, diagnosis,
treatment, number of the doctor under whom treatment is done, attendant name, etc. If
patient is operated in the hospital, his/her details are stored in the database. Information
stored includes patient number, date of admission, date of operation, number of the doctor
who conducted the operation, number of the Operation Theatre in which operation was
carried out, type of operation, patient’s condition before and after operation, treatment
advice, etc.
There are two types of the doctors in the hospital, namely, regular doctors and call on doctors.
Regular doctors are those doctors who come to the hospital daily. Calls on doctors are those
doctors who are called by the hospital if the concerned doctor is not available. Each doctor is
given an identity number starting with DR (regular) or DC (on-call) prefixes only. For each
doctor, doctor id, name, qualification, address, phone number, address is stored. A regular
doctor should have doctor id, salary, and date of joining stored. An on-call doctor will have
doctor id, fees per call and payment due stored.
a) List any two techniques the database designer can apply to identify the business rules.
(2 marks)
Ans:
b) List all possible business rules that emerge from the given scenario. (5 Marks)
ANS:
1. A department can have zero or many doctors. A doctor can work in one
department.
2. A doctor can check zero or many patients. A patient can be checked by zero or
many doctors.
3. A doctor can operate zero or many patients. A patient can be operated by zero or
many doctors.
4. A doctor can be a regular doctor. A regular doctor is a doctor of the hospital.
5. A doctor can be an on-call doctor. An on-call doctor is a doctor of the hospital.
6. A patient can be admitted. An admitted patient is a patient of the hospital.
DOCTOR
PK DOC_NO
DOC_QUAL
DOC_PHONE
DOC_LNAME DEPARTMENT
DOC_FNAME ON_CALL_DOCTOR
FK1 DEPART_ID PK DEPART_ID
PK,FK1 DOC_NO
DEPART_NAME
ON_CALL_FEES DEPART_LOCATION
DEPART_FACILITIES
CHECKUP
PK,FK1 DOC_NO PATIENT
PK,FK2 PAT_NO
PK CHECKUP_DATE PK PAT_NO
CHECKUP_STATUS PAT_AGE
CHECKUP_TREATMENT PAT_PHONE
PAT_GENDER
PAT_LNAME
OPERATION PAT_FNAME
PK OPER_DATE
REGULAR_DOCTOR PK,FK1 DOC_NO
PK,FK2 PAT_NO
PK,FK1 DOC_NO
OPER_TYPE REGULAR_PATIENT
RDOC_SALARY OPER_MED
RDOC_APPOINT_DATE PK RPAT_DATE
PK,FK1 PAT_NO
RPAT_PAYMENT
ADMIT_PATIENT
PK ADMIT_DATE
PK,FK1 PAT_NO
ADMIT_ROOM_NO
i. How do the business rules help you when creating the ERD? (1 mark)
Ans:
It helps identify the entities and the relationship between the entities.
ii. Choose any one attribute that should be indexed apart from the primary and
foreign keys, and briefly justify your choice. (2 marks)
Ans:
Many answers are possible, therefore, marker discretion is required. An example could be:
assign_date: this attribute could be used frequently to identify employees working on a
particular project on certain dates.
Use the following description to answer parts (a) to (d) of this question.
The Gill Art Gallery wishes to maintain data on their customers, artists and paintings. They may
have several paintings by each artist in the gallery at one time. Paintings may be bought and sold
several times. In other words, the gallery may sell a painting, then buy it back at a later date and
sell it to another customer. Below is a gallery customer history form.
Customer Name
Purchases Made
Normalization is a process for evaluating and correcting table structures to minimize data
redundancies, thereby reducing the likelihood of data anomalies. The normalization
b) Identify functional, partial, and transitive dependencies (if any) by drawing a dependency
diagram. (8 marks)
c) Using the initial dependency diagram from question 2. b), convert your table structure
to second normal form (2NF), and draw the new dependency diagram. (5 marks)
d) Using the dependency diagram from question 2. c), convert your table structure to third
normal form (3NF), and draw the new dependency diagram. (5 marks)
Use the following description and the ERD given below to answer parts (a) to (l) of this question.
The management team needs some reports for their upcoming meeting. In the following
questions, you will be required to write the relevant queries that will provide the required
information for their report. Your queries should be written for a MySQL database. You are
required to use the given attribute names in the following ERD diagram in your queries.
a) Write the necessary SQL command(s) that will display the name of the user who is
currently using the system? (1 mark)
SELECT CURRENT_USER();
b) Write the necessary SQL command(s) to see all the tables in the database?
(1 mark)
show tables;
c) The structure of the movies table is given in Figure 1 below. Write the necessary SQL
Statement to create the MOVIE table (4 Marks)
Figure 1
MOVIE_COST decimal(5,2),
MOVIE_GENRE VARCHAR(50),
PRICE_CODE int(2),
);
d) Using SQL Statement(s), add the flowing two records to the MOVIE table. (2 Marks)
MOVIE
Movie_Num Movie_Name Movie_Year Movie_Cost Movie_Genre Price_Code
1234 The Cesar Family Christmas 2014 39.95 FAMILY 2
1235 Smokey Mountain Wildlife 2011 59.95 ACTION 1
e) Write the SQL command(s) to save the two recorded you have added. (1 Mark)
COMMIT;
f) List the movie number, name and the number of copies aliased as Copies of each
movie that has more than five copies. (5 Marks)
SELECT m.Movie_Num, Movie_Title, count(VID_NUM) AS 'copies'
g) List the members (full name) aliased as Name, and member balance sorted by
member last name in ascending order. (2 Marks)
SELECT CONCAT_WS( ' ', Mem_LName, Mem_FName) AS Name,
Mem_Balance
FROM MEMBERSHIP
ORDER BY Mem_LName;
h) List the movie name and movie year for all movies that have a price code.
(2 Marks)
SELECT MOVIE_TITLE, MOVIE_YEAR
FROM MOVIE
j) Write a stored procedure to select all Movie records from the movies table. The name
of the stored procedure should be AllMovies (2 marks)
DELIMITER //
BEGIN
END
//
DELIMITER ;
Implementing consistent data processing logic, that is, how data is processed by the
RDBMS.
Implementing data access control, that is, control the access to the tables.
Question 1
Question 2
Deadlock is a major issue in the context of databases. Using examples, briefly describe deadlock
and how it could be addressed. (3 Marks)
A deadlock occurs when two transactions wait indefinitely for each other to unlock data. For
example, a deadlock occurs when two transactions, T1 and T2, exist in the following mode: T1 =
access data items X and Y T2 = access data items Y and X If T1 has not unlocked data item Y, T2
cannot begin; if T2 has not unlocked data itemX, T1 cannot continue. Consequently, T1 and T2
each wait for the other to unlock the required data item. Such a deadlock is also known as a
deadly embrace.
The three basic techniques to control deadlocks are:
• Deadlock prevention.
• Deadlock detection.
• Deadlock avoidance.
Question 3
Use the following description to answer parts (a) to (b) of this question.
Suppose you are a manufacturer of product AB, which is composed of parts A and B. Each time a
new product is created, it must be added to the product inventory, using the PROD_QOH in a
table named PRODUCT. And each time the product AB is created, the parts inventory, using
PART_QOH in a table named PART, must be reduced by one each of parts A and B. The sample
database contents are shown in Figure 2.
AB 2,563 A 895
B 129
Figure 2
a) How many database requests can you identify for an inventory update for both
PRODUCT and PART? (1 Mark)
Depending on how the SQL statements are written, there are two correct answers: 3
or 2.
COMMIT;
THE END