158.337 Database Development - Massey (Albany) - Exam - S1 2012

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

1201/158.

337 SC
ALB
Distance/Internal

MASSEY UNIVERSITY
ALBANY CAMPUS

EXAMINATION FOR
158.337 DATABASE DEVELOPMENT

Semester One 2012

Time allowed: THREE (3) hours

There are 89 questions: ALL questions should be attempted

This examination contributes 50 % to the final marks

SECTION A
64 Multi-choice questions (Scantron Card) 64 * 0 .75 = 48 Marks

SECTION B
24 True / False questions (Scantron Card) 24 * 0.5 = 12 Marks

SECTION C
One question (Blue Answer booklet) 40 Marks

Total: 100 Marks

THIS IS A CLOSED BOOK EXAMINATION.

Calculators, Dictionaries or any type of electronic assistants ARE NOT


ALLOWED.

Scantron Cards
Ensure that your name and identification number are entered on your Scantron Card.
Record your answer on your Scantron card by putting a solid horizontal pencil line
through the character representing the ‘best’ answer to the question with a blunt 2B
or 3B pencil, please. The Scantron Card will not read properly if you do not follow
these instructions. At the conclusion of the examination hand in the Scantron Card
separately.

Page 1 of 19
1201/158.337 SC
ALB
Distance/Internal

SECTION A
Attempt all the following questions. There is one (1) correct answer.
Record the answer that applies best on your Scantron card.
The Scantron Card has five options. Ignore the fifth option (e)
(Total Marks = 48)

1. _______________ rule states that - Application programs are unaffected when


changes are made to table structures that preserve the original values (e.g.,
changing order of columns).
a. Nonsubversion
b. Integrity Independence
c. Logical Data Independence
d. Guaranteed Access

2. Oracle 11g automatically creates an index for which type of constraints?


a. NOT NULL
b. CHECK
c. FOREIGN KEY
d. UNIQUE

3. A Homonym indicates _______________.


a. the use of same attribute name to label different attributes.
b. the use of different names to describe the same attribute.
c. that different data types (e.g., CHAR(20) and VARCHAR2(20)) can be used
in union – compatibility joins.
d. the use of same data type to be used in definition of derived attributes.

4. The database structure in a DBMS is stored as a ________.


a. file
b. collection of files
c. set of key/value pairs
d. collection of queries

5. _________ data exist in the format in which they were collected.


a. Structured
b. Unstructured
c. Semistructured
d. Historical

6. Which of the following statements is FALSE about a relation?


a. A tuple represents a group of related entities.
b. Each cell of the relation contains a single value.
c. The order of tuples in a relation is of no significance.
d. Values of an attribute are all from the same domain.

Page 2 of 19
1201/158.337 SC
ALB
Distance/Internal

7. Which is FALSE for a key-value data model?


a. It is schema-less.
b. It does not use declarative language to access data.
c. It does not enforce relationships among entities.
d. Indexes can be easily created for quick retrieval of data.

8. Which of the following statement is FALSE?


a. You can change the name of a table only if it doesn’t contain any data.
b. You can change the length of a column that doesn’t contain any data.
c. You can delete a column that doesn’t contain any data.
d. You can add a column to a table even if the table contains data.

9. Emerging data models used to support large scale distributed Web architectures
such as Twitter are NOT geared towards __________________.
a. eventual consistency
b. performance consistency
c. transaction consistency
d. eventual, performance and transaction consistencies

Questions 10 – 12 are based on Figure 1.


Given the following figure (Figure 1), choose the best answer (a –d) that matches the
type of dependency for attributes shown. Same answer can be applied more than once.
a. composite
b. functional
c. partial
d. transitive
Figure 1

C1 C2 C3 C4 C5

10. C1 → C2

11. C4 → C5

12. C1, C3 → C2, C4, C5

Page 3 of 19
1201/158.337 SC
ALB
Distance/Internal

13. Given Figure 2, which SQL statement(s) will add PRIMARY KEY and FOREIGN KEY
in the table LINE.
Figure 2

a. ALTER TABLE LINE


ADD PRIMARY KEY (INV_NUMBER, LINE_NUMBER)
ADD FOREIGN KEY (INV_NUMBER) REFERENCES INVOICE ON EDIT
CASCADE;

b. ALTER TABLE LINE


ADD PRIMARY KEY (INV_NUMBER, LINE_NUMBER)
ADD FOREIGN KEY (INV_NUMBER) REFERENCES INVOICE ON
DELETE CASCADE;

c. ALTER TABLE LINE


ADD PRIMARY KEY( LINE_NUMBER, INV_NUMBER)
ADD FOREIGN KEY (INV_NUMBER) REFERENCES INVOICE ON UPDATE
CASCADE;

d. ALTER TABLE LINE


ADD FOREIGN KEY (INV_NUMBER) REFERENCES INVOICE CASCADE
CONSTRAINTS;
ALTER TABLE LINE
ADD PRIMARY KEY(LINE_NUMBER, INV_NUMBER);

14. If you use a surrogate key, you must ensure that the candidate key of the entity in
question performs properly through the use of the ___________________
constraints.
a. UNIQUE and NOT NULL
b. CHECK and UNIQUE
c. REFERENCES
d. DEFAULT

Page 4 of 19
1201/158.337 SC
ALB
Distance/Internal

15. A ____ trap occurs when you have one entity in two 1:M relationships to other
entities, thus producing an association among the other entities that is not expressed
in the model.
a. surrogate
b. design
c. fan
d. time-variant

16. Which of the following does NOT match the string ‘_T%’ when used with the LIKE
operator?
a. MT
b. MTW
c. T
d. MTWRF

17. Given the following table (Table 1), which statement is FALSE?
Table 1
STUDENT_CLASSIFICATION
HOURS_COMPLETED CLASSIFICATION
Less than 30 Fr
30 - 59 So
60 - 89 Jr
90 or more Sr

a. We cannot determine exact value of HOURS_COMPLETED.


b. CLASSIFICATION determines many values of HOURS_COMPLETED
c. The CLASSIFICATION is determined based upon HOURS_COMPLETED.
d. The table STUDENT_CLASSIFICATION represents a superkey scenario.

18. Which statement would be used to select all students with more than one grade?
a. WHERE COUNT(grade) > 1
b. WHERE COUNT(grade) >= 1
c. HAVING COUNT(grade) > 1
d. HAVING COUNT(grade) >= 1

19. A(n) ____ is an alternate name for a query column.


a. record
b. alias
c. clause
d. row

Page 5 of 19
1201/158.337 SC
ALB
Distance/Internal

20. BCNF can be violated only if the table contains more than one ____ key.
a. primary
b. candidate
c. foreign
d. secondary

21. COMMIT and ROLLBACK do NOT work with ____________ command.


a. INSERT
b. DELETE
c. DROP
d. UPDATE

22. What are the two candidate keys in Figure 3?


Figure 3

A B C D

a. A+B and A+C


b. A+B and A+D
c. A+B and B+C
d. A+B and B+D

23. Which of the following statements is FALSE?


a. A weak entity produces a strong relationship.
b. A strong entity can have either identifying or non identifying relationships.
c. A strong relationship between two entities implies that one entity must
have a composite primary key.
d. A weak relationship between two entities implies that both entities do not
contain any foreign key.

24. Which of the following is a FALSE statement about Oracle sequences?


a. Sequences are not tied to a particular table or column.
b. Sequences always generate a numeric value.
c. Sequences are not a data type.
d. Sequence values once assigned to a table attribute cannot be edited.

25. A triggering event will NOT be fired by the ______________ statement.


a. DELETE
b. INSERT
c. SELECT
d. UPDATE

Page 6 of 19
1201/158.337 SC
ALB
Distance/Internal

26. When we use a SQL statement inside a PL/SQL block that returns more than one
row, we use a(n) __________ cursor.
a. explicit
b. implicit
c. fetch
d. join

27. Which of the following is NOT an advantage of fragmented data in DDBMS?


a. Enhances availability of data
b. Reduces response time
c. Reduces communication costs
d. Reduces processing overheads

Questions 28 – 30 are based on the following case.

Case: A database to keep track of expenses made during business trips for each
salesperson is designed as follows:
SalesPerson (Sales_Person_ID, FName, LName, Start_Year)
Trip (Trip_ID, From_City,To_City, Departure_Date, Return_Date)
Expense (Trip_ID, Account_Num, Amount)

28. Which table has no FKs?


a. SalesPerson
b. Trip
c. Expense
d. All three tables have FKs.

29. Which of the following is a weak entity?


a. SalesPerson
b. Trip
c. Expense
d. None of the above

30. Which of the following is TRUE about the relationship strength?


a. SalesPerson and Trip have a strong relationship
b. Salesperson and Expense have a strong relationship
c. Trip and Expense have a strong relationship
d. All three relationships are strong

31. The ___________ set operator is essential for each join operation.
a. CARTESIAN
b. PROJECT
c. UNION
d. UNION ALL

Page 7 of 19
1201/158.337 SC
ALB
Distance/Internal

32. Which of the following syntax is used for queries within a PL/SQL block?
a. SELECT <column_list> FROM <table_name>
INTO <declared_variables> WHERE <condition>
b. SELECT <column_list> INTO <declared_variables>
FROM <table_name> WHERE <condition>
c. SELECT <column_list> FROM <table_name>
WHERE <condition> INTO <declared_variables>
d. SELECT <column_list> INTO <declared_variables>
FROM <table_name> WHERE_BY <condition>

33. When we use a surrogate key as the primary key of an entity, we say that the entity
is _____________.
a. strong
b. weak
c. moderate
d. typed

34. Consider the following dependencies among attributes. This table structure can be
normalised further to ________.

A+B  C, D, E, F
EF
a. 2NF
b. 3NF
c. 4 NF
d. BCNF

35. Consider the following dependencies. The table structure is currently in _______.

A+B  C, D, E, F
A  C, F
DE
a. 1NF
b. 2NF
c. 3NF
d. 4NF

36. In ANSI/SPARC model architecture which of these levels represent a view used by
the application program?
a. Physical
b. Internal
c. External
d. Conceptual

Page 8 of 19
1201/158.337 SC
ALB
Distance/Internal

37. The ___________ SQL command modifies an attribute’s values in one or more rows
in a table.
a. INSERT
b. UPDATE
c. COMMIT
d. SELECT

38. A(n) ___________ cannot accept input parameters.


a. anonymous PL/SQL program
b. stored PL/SQL procedure
c. PL/SQL function
d. All of the above can accept input parameters.

39. Which of the following is a valid PL/SQL statement to request ST_SALARY from
STAFF table into a local variable V_SALARY?

STAFF
ST_STAFFNO
ST_NAME
ST_POSITION
ST_SALARY

a. SELECT ST_SALARY INTO V_SALARY FROM STAFF WHERE


ST_STAFFNO := 111;
b. SELECT ST_SALARY INTO V_SALARY FROM STAFF WHERE
ST_STAFFNO = “111”;
c. SELECT ST_SALARY INTO V_SALARY FROM STAFF WHERE
ST_STAFFNO = 111;
d. SELECT ST_SALARY FROM STAFF INTO V_SALARY WHERE
ST_STAFFNO IS 111;

40. If the following statement is executed, what happens to the triggers that exist for the
STAFF table?
DROP TABLE STAFF;
a. The triggers are disabled.
b. The triggers are dropped.
c. The triggers are not affected.
d. The triggers status is marked as INVALID.

41. A host/bind variable called g_result is declared. The variable g_result can be
accessed in a PL/SQL block by referencing it as
a. g_result
b. :g_result
c. #g_result
d. &g_result

Page 9 of 19
1201/158.337 SC
ALB
Distance/Internal

42. If a column has low selectivity, this means:


a. The column has many distinct values.
b. The column contains a small number of distinct values.
c. A WHERE clause is always used in a query on the column.
d. The column has no indexes associated with it.

43. Which of the following SQL statement is valid?


a. SELECT * FROM ORDERS WHERE SHIPDATE = NULL;
b. SELECT * FROM ORDERS WHERE SHIPDATE = ‘NULL’;
c. SELECT * FROM ORDERS WHERE SHIPDATE IS ‘NULL’;
d. SELECT * FROM ORDERS WHERE SHIPDATE IS NULL;

44. In the given PL/SQL block, we will display p_phone_formatted by using a(n)
________ variable.
CREATE OR REPLACE PROCEDURE phone_fmt_sp
(p_phone IN VARCHAR2, p_phone_formatted OUT VARCHAR2)
IS
BEGIN
p_phone_formatted := '(' || SUBSTR(p_phone,1,3) || ')' ||
SUBSTR(p_phone,4,3) || '-' || SUBSTR(p_phone,7,4);
END;
.
/

a. anchored
b. cursor
c. host
d. scalar

45. Consider a table STUDENT


STUDENT (STUD_ID, STUD_NAME, STUD_DOB)
Next, a sequence SEQ_STUDENT_ID is declared as follows
CREATE SEQUENCE SEQ_STUDENT_ID START WITH 1101;
Which of the following statements will successfully insert a new record into the
STUDENT table?
a. INSERT INTO STUDENT (SEQ_STUDENT_ID.INCREMENT, ‘JOHN’, ‘06-
APR-1985’);
b. INSERT INTO STUDENT (SEQ_STUDENT_ID.CURRVAL, ‘JOHN’, ‘06-APR-
1985’);
c. INSERT INTO STUDENT (SEQ_STUDENT_ID.NEXTVAL, ‘JOHN’, ‘06-APR-
1985’);
d. INSERT INTO STUDENT (SEQ_STUDENT_ID.UP, ‘JOHN’, ‘06-APR-1985’);

Page 10 of 19
1201/158.337 SC
ALB
Distance/Internal

46. Which command is required to display values from DBMS_OUTPUT.PUT_LINE


commands?
a. SET OUTPUT ON
b. SET SQLOUTPUT ON
c. SET SERVEROUTPUT ON
d. SET SERVEROUT ON

47. The ____ command is used with the ALTER TABLE command to modify the table for
deleting a column.
a. DROP
b. DELETE
c. REMOVE
d. ERASE

48. Review the following IF statement. What is the resulting value if lv_amt_num has a
value of 1200?
BEGIN
IF lv_amt_num > 500 THEN
lv_ship_num :=5;
ELSIF lv_amt_num > 1000 THEN
lv_ship_num :=8;
ELSIF lv_amt_num > 1700 THEN
lv_ship_num := 10;
ELSE
lv_ship_num :=13;
END IF;
DBMS_OUTPUT.PUT_LINE(lv_ship_num);
END;

a. 5
b. 8
c. 10
d. 13

49. Union-compatible means that the _________________.


a. names of the relation attributes can be different, but the data types must
be similar
b. names of the relation attributes must be the same, but the data types can
be different
c. number of the relation attributes are same, but the data types can be
different
d. number of the relation attributes are different, but all data types of the
attributes must be same

Page 11 of 19
1201/158.337 SC
ALB
Distance/Internal

50. The ____ statement in SQL combines rows from two queries and returns only the
rows that appear in the first set but not in the second.
a. UNION
b. UNION ALL
c. INTERSECT
d. MINUS

51. Which query is used to list a unique value for V_CODE, where the list will produce
only a list of those values that are different from one another?
a. SELECT ONLY V_CODE FROM PRODUCT;
b. SELECT UNIQUE V_CODE FROM PRODUCT;
c. SELECT DIFFERENT V_CODE FROM PRODUCT;
d. SELECT DISTINCT V_CODE FROM PRODUCT;

52. A(n) _________ join requires the use of a table alias to mimic the referencing of two
different tables, when in reality, they are the same table.
a. Union
b. Recursive
c. Cartesian
d. Alias

53. The set of possible values for an attribute is a ____.


a. domain
b. range
c. key
d. set

54. An explicit cursor is used in the following sequence:


a. DECLARE, FETCH, OPEN, CLOSE
b. DECLARE, OPEN, FETCH, CLOSE
c. DECLARE, OPEN, BIND, CLOSE
d. DECLARE, FETCH, BIND, CLOSE

55. If an entity can exist apart from one or more related entities, it is said to be ____-
independent.
a. business
b. existence
c. relationship
d. weak

Page 12 of 19
1201/158.337 SC
ALB
Distance/Internal

56. As long as two transactions, T1 and T2 access _______ data, the order of execution
is irrelevant to the final outcome.
a. shared
b. common
c. unrelated
d. locked

57. The scheduler guarantees that the execution of concurrent transactions will yield the
same result, as though the transactions were executed one after the other to ensure
transaction ________________.
a. atomicity
b. durability
c. isolatability
d. serializability

58. The ____ scenario describes a fully distributed DBMS with support for multiple data
processors and transaction processors at multiple sites.
a. multiple-site processing, single-site data
b. single-site processing, multiple-site data
c. single-site processing, single-site data
d. multiple-site processing, multiple-site data

59. ______________ means that the database will be in a permanent consistent state
after the execution of a transaction.
a. Atomicity
b. Durability
c. Isolation
d. Serializability

60. A(n) ____________ condition occurs when two or more transactions wait for each
other to unlock data.
a. deadlock
b. exclusive lock
c. binary lock
d. two-phase lock

61. Which of the following statement is FALSE about the Transaction Log (TL)?
a. TL stores the beginning and end of the transaction.
b. TL stores the type of operation (update, delete, etc) performed by each
SQL request.
c. TL plays a crucial role for database recovery and concurrency
management.
d. TL reduces the processing overheads of a DBMS.

Page 13 of 19
1201/158.337 SC
ALB
Distance/Internal

62. __________ transparency allows a database fragmented over multiple sites to be


treated as a single logical database.
a. Distribution
b. Transaction
c. Remote
d. Performance

63. Which of the following statement about transaction is FALSE?


a. A transaction is a logical unit of work.
b. A transaction must be entirely completed or aborted.
c. A transaction on completion yields intermediate states.
d. A transaction may consist of many SQL statements.

64. Each time a new product is created, it must be added to the product inventory, using
PROD_QOH in a table named PRODUCT.
Suppose you are a manufacturer of product ABC, which is composed of parts A,
B, and C. If a product ABC is created, then parts inventory, using PART_QOH in
a table named PART, must also be reduced by one for each of the parts A, B, and
C.

PRODUCT PART
PROD_CODE PROD_QOH PART_CODE PART_QOH
ABC 1,205 A 567
B 98
C 549

What is the minimum number of database requests (SQL statements) for an


inventory update for both PRODUCT and PART?
a. 1
b. 2
c. 3
d. 4

Page 14 of 19
1201/158.337 SC
ALB
Distance/Internal

SECTION B

Attempt all of the following questions.


Record your answers on your Scantron Card
The Scantron Card has five options. Use (a) for True and (b) for False.
Ignore the third, fourth & fifth options (c), (d) & (e)

(Total Marks = 12)


State True or False
65. The order of attributes defined in a composite primary key has no effect on the
indexing speed.
a. True
b. False

66. One of the disadvantages of stored procedures is that they increase network traffic.
a. True
b. False

67. Entity integrity is enforced automatically when the primary key is specified in the
CREATE TABLE command sequence.
a. True
b. False

68. You cannot insert a row containing a null attribute value using SQL.
a. True
b. False

69. Views using aggregate functions are NOT updatable.


a. True
b. False

70. With partial dependencies, data redundancies occur because every row entry
requires duplication of data.
a. True
b. False

71. A dependency of one nonprime attribute on another nonprime attribute is a partial


dependency.
a. True
b. False

Page 15 of 19
1201/158.337 SC
ALB
Distance/Internal

72. A Boolean variable in a PL/SQL block can hold three types of values – TRUE, FALSE
and BLANK.
a. True
b. False

73. The Cartesian product exhibits a many-to-many (M : M) relationship.


a. True
b. False

74. The DUAL table consists of two rows and one column.
(DUAL = DoUble rows + A coLumn)
a. True
b. False

75. The following statement is invalid and when executed will result in an ORACLE
error.
SELECT SYSDATE, 'Exam Time', student_id
FROM student
a. True
b. False

76. Given the following business rules, we will place the foreign key in DEPARTMENT
table:
An EMPLOYEE manages zero or one DEPARTMENT; each DEPARTMENT is
managed by one EMPLOYEE.
a. True
b. False

77. Relationship participation and relationship strength refer to the same issue for
recursive relationships.
a. True
b. False

78. A view is not dropped when its corresponding tables are dropped.
a. True
b. False

79. The COUNT(*) function can be used to include NULL values in its results.
a. True
b. False

80. Monotonicity ensures that time stamp values always increase.


a. True
b. False

Page 16 of 19
1201/158.337 SC
ALB
Distance/Internal

81. A field-level lock allows concurrent transactions to access the same row, as long as
they require the use of different fields within that row.
a. True
b. False

Questions 82 – 84 are based on the two tables – MACHINE and BOOTH – shown in
Figure 4
Figure 4
MACHINE BOOTH
MACHINE_PRODUCT MACHINE_PRICE BOOTH_PRODUCT BOOTH_PRICE
Chips 1.25 Chips 1.5
Chocolate Bar 1 Chocolate Bar 1.25
Energy Drink 2 Energy Drink 2

82. The following SQL statement will return 5 rows


SELECT MACHINE_PRODUCT PRODUCT, MACHINE_PRICE PRICE FROM MACHINE
UNION
SELECT BOOTH_PRODUCT, BOOTH_PRICE FROM BOOTH
a. True
b. False

83. The following SQL statement will return 1 row


SELECT MACHINE_PRODUCT PRODUCT, MACHINE_PRICE PRICE FROM MACHINE
INTERSECT
SELECT BOOTH_PRODUCT, BOOTH_PRICE FROM BOOTH
a. True
b. False

84. The following SQL statement will return 1 row


SELECT BOOTH_PRODUCT PRODUCT, BOOTH_PRICE PRICE FROM BOOTH
MINUS
SELECT MACHINE_PRODUCT PRODUCT, MACHINE_PRICE PRICE FROM MACHINE;
a. True
b. False

85. Given the following three business rules, PATIENT is in a ternary relationship
i. A DOCTOR writes one or more PRESCRIPTIONs.
ii. A PATIENT may receive one or more PRESCRIPTIONs.
iii. A DRUG may appear in one or more PRESCRIPTIONs.
a. True
b. False

86. Constraints defined in a table can be disabled and can also be dropped.
a. True
b. False

Page 17 of 19
1201/158.337 SC
ALB
Distance/Internal

87. Projection is a unary operator.


a. True
b. False

88. Cardinality expresses the minimum and maximum number of entity occurrences
associated with one occurrence of the related entity.
a. True
b. False

contd……

Page 18 of 19
1201/158.337 SC
ALB
Distance/Internal

SECTION C
(Total Marks = 40)

89. Given the information in Table 2, you have to do the following:

Table 2

Attribute Name Sample Value Sample Sample Value Sample Value


Value
EMP_NUM 1003 1018 1019 1023
EMP_LNAME Willaker Smith McGuire McGuire
EMP_EDUCATION BBA, MBA BBA BS, MS, Ph.D.
JOB_CLASS SLS SLS JNT DBA
DEPT_CODE MKTG MKTG SVC INFS
DEPT_NAME Marketing Marketing General Service Info. Systems
DEPT_MANAGER Jill H. Martin Jill H. Martin Hank B. Jones Carlos G. Ortez
EMP_TITLE Sales Agent Sales Agent Janitor DB Admin
EMP_DOB 23-Dec-1968 28-Mar-1979 18-May-1982 20-Jul-1959
EMP_HIRE_DATE 14-Oct-1997 15-Jan-2006 21-Apr-2003 15-Jul-1999
EMP_TRAINING L1, L2 L1 L1, L3, L8, L15
EMP_BASE_SALARY $38,255.00 $30,500.00 $19.750.00 $127,900.00
EMP_COMMISSION_RATE 0.015 0.010

a) Design relational schemas and corresponding dependency diagrams that are


each in the highest normal form. Indicate the key attributes of each relation and
also write the Normal Form against each relation.

(20 marks)
b) Use the above information to create an entity relationship diagram (ERD).
Use only Crow’s Foot notations in your diagram. Flag the primary and foreign
keys. Also add appropriate association names to your diagram and mark
relationships as identifying or non-identifying.
(20 marks)
NOTE: Use good naming conventions. You can add more attributes based on any
further assumptions you make.

Write any unspecified requirements and make appropriate assumptions to provide


a complete solution.
++++++++ Last Page +++++++

Page 19 of 19

You might also like