Professional Documents
Culture Documents
2. Consider the following SQL query “select distinct a1,a2….an from r1,r2,…rm where P
For an arbitrary predicate P, this query is equivalent to which of the following RA
expressions?
a) π a1,a2,…anσp(r1xr2x….x rm)
b) π a1,a2,…anσp (r1*r2*….* rm) * - natural join
c) π a1,a2,…anσp (r1Ur2U….U rm)
d) π a1,a2,…anσp (r1ᴖr2ᴖ….ᴖ rm)
5. Consider the set of relations shown below and write the SQL query to display the
name of students who have got an A grade in at least one of the courses taught by James
Students(Rollno, name, dateofbirth) Courses(courseno, coursename, instructor)
Grades(Rollno, courseno, grade)
6. Write the SQL query to display the average salary of male employees is more than
the average salary of employees in the same department by considering the relation
employee(name, gender, salary, deptname)
8. Let E1 and E2 be two entities in an ER diagrams with simple single valued attributes.
R1 and R2 are two relationships between E1 and E2, where R1 is one-to-many and R2 is
many-to-many. R1 and R2 do not have any attributes of their own. What is the minimum
number of tables required to represent this situation in the relational model?
a) 2 b)3 c)4 d)5
9. The following table has two attributes A and C where A is the primary key and C is
the foreign key referencing A with on-delete-cascade.
A C
2 4
3 4
4 3
5 2
7 2
9 5
6 4
The set of all tuples that must be additionally deleted to preserve referential
integrity when the tuple (2,4) is deleted is:
a) (3,4) and (6,4) b) (5,2) and (7,2) c) (5,2) (7,2) and (9,5) d) (6,4)
11. Which of the following scenarios may lead to an irrecoverable error in a database
system?
T1 T2 T3
R(D3)
R(D2)
W(D2)
R(D2)
R(D3)
R(D1)
W(D1)
W(D2)
W(D3)
R(D1)
R(D2)
W(D2)
W(D1)
13. Consider the following log sequence of two transactions on a bank account, with
initial balance 12000, that transfer 2000 to a mortgage payment and then apply a 5%
interest.
1. T1 start 2. T1 B old = 12000 new=10000 3. T1 M old=0 new=2000
4. T1 commit 5. T2 start 6. T2 B old=10000 new=10500 7. T2 commit
Suppose the database system crashed just before log record 7 is written. When the
system is restarted, which one of the statements is true of the recovery procedure?
a) We must redo log record 6 to set B to 10500
b) We must undo log record 6 to set B to 10000 and then redo log records 2 and 3
c) We need not redo log records 2 and 3 because transaction T1 has committed
d) We can apply redo and undo operations in arbitrary order because they are
idempotent
16. Which of the following concurrency control protocols ensure both conflict
serilaizablity and freedom from deadlock?
I. 2-phase locking II. Time-stamp ordering
a) I only b) II only c) Both I and II d) Neither I nor II
17. The following functional dependencies hold for relations R(A,B,C) and S(B,D,E):
B-> A A->C
The relation R contains 200 tuples and the relation S contains 100 tuples. What
is the maximum number of tuples possible in the natural join of R and S.
18. Given the basic ER and relational models, which of the following is INCORRECT?
(A) An attribute of an entity can have more than one value
(B) An attribute of an entity can be composite
(C) In a row of a relational table, an attribute can have more than one value
(D) In a row of a relational table, an attribute can have exactly one value or a NULL
value
19. Which of the following statements are TRUE about an SQL query?
P : An SQL query can contain a HAVING clause even if it does not have a GROUP BY
clause
Q : An SQL query can contain a HAVING clause only if it has a GROUP BY clause
R : All attributes used in the GROUP BY clause must appear in the SELECT clause
S : Not all attributes used in the GROUP BY clause need to appear in the SELECT clause
(A) P and R (B) P and S (C) Q and R (D) Q and S
20. Suppose R1(A, B) and R2(C, D) are two relation schemas. Let r1 and r2 be the
corresponding
relation instances. B is a foreign key that refers to C in R2. If data in r1 and r2 satisfy
referential
integrity constraints, which of the following is ALWAYS TRUE?
(A) B(r1) C(r2) =
(B) C(r2) B(r1) =
(C) B(r1) = C(r2)
(D) B(r1) C(r2) ≠
21. How many tuples does the result of the following relational algebra expression contain?
Assume
that the schema of A∪B is the same as that of A.
(A∪B) ⋈ A.Id > 40 C.Id < 15 C
(A) 7 (B) 4 (C) 5 (D) 9
H ow many tuples does the result of the following SQL query contain?
SELECT A.Id
FROM A
WHERE A.Age > ALL (SELECT B.Age
FROM B
WHERE B.Name = ‘Arun’)
(A) 4 (B) 3 (C) 0 (D) 1
23. Consider the following transactions with data items P and Q initialized to zero:
T1 :read (P);
read (Q);
if P = 0 then Q := Q + 1 ;
write (Q).
T2 : read (Q);
read (P);
if Q = 0 then P := P + 1 ;
write (P).
Any non-serial interleaving of T1 and T2 for concurrent execution leads to
(A) a serializable schedule
(B) a schedule that is not conflict serializable
(C) a conflict serializable schedule
(D) a schedule for which a precedence graph cannot be drawn
24. Which statement finds the rows in the CUSTOMERS table that do not have a postal code?
A. SELECT customer_id, customer_name FROM customers WHERE postal_code CONTAINS
NULL;
B. SELECT customer_id, customer_name FROM customers WHERE postal_code = '________';
C. SELECT customer_id, customer_name FROM customers WHERE postal_code IS
NULL;
D. SELECT customer_id, customer_name FROM customers WHERE postal code IS NVL;
E. SELECT customer_id, customer_name FROM customers WHERE postal_code = NULL;
25. SELECT last_name, salary , hire_date FROM EMPLOYEES ORDER BY salary DESC;
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC;
What is true about them?
A. The two statements produce identical results.
B. The second statement returns a syntax error.
C. There is no need to specify DESC because the results are sorted in descending order by
default.
D. The two statements can be made to produce identical results by adding a column alias for the
salary column in the second SQL statement.
27. You want to use a function in you column clause of a SQL statement. The NVL function
accomplishes which of the following tasks?
A. Assists in the distribution of output across multiple columns.
B. Enables you to specify alternate output for non-NULL column values.
C. Enables you to specify alternated out for NULL column values.
D. Nullifies the value of the column output.
29. You need to display the last names of those employees who have the letter “A” as the second
character in their names.
Which SQL statement displays the required results?
A. SELECT last_name FROM EMP WHERE last_name LIKE ‘_A%’;
B. SELECT last_name FROM EMP WHERE last name =’*A%’
C. SELECT last_name FROM EMP WHERE last name =’_A%’;
D. SELECT last_name FROM EMP WHERE last name LIKE ‘*A%’
30. The CUSTOMER_ID column is the primary key for the table.
Which two statements find the number of customers? (Choose two.)
A. SELECT TOTAL(*) FROM customers;
B. SELECT COUNT(*) FROM customers;
C. SELECT TOTAL(customer_id) FROM customers;
D. SELECT COUNT(customer_id) FROM customers;
E. SELECT COUNT(customers) FROM customers;
F. SELECT TOTAL(customer_name) FROM customers;
a. Data Fields
b. Data Record
c. Menu
d. Bank
e. None of above
a. DML statement
b. DDL statement
c. DCL statement
d. None of above
a. DD-MON-YY
b. DD-MM-YY
c. DD-MM-YYY
d. MM-DD-YY
34) For adding number of hours to a date, which of the following statement is used ?
a. Date + Number
b. Date + Number/24
c. Date + Number of Hours
d. None of above
37) A command that lets you change one or more fields of a record is
a. insert
b. Modify
c. Look-up
d. All of above
e. None of above
a. Spreadsheet program
b. Word processor program
c. Graphics programs
d. All of above
e. None of above
42) A trigger is
43) Manager's salary details are hidden from the employee. This is
44) A relation scheme is said to be in ...... form if the values in the domain of
each attribute of the relation are atomic
a. Unnormalized
b. First Normal
c. BoyceCODD
d. None of these
45) A second Normal form does not permit ...... dependency between a non
prime attribute and the relation key
a. Partial
b. Multi
c. Functional
d. Valued
46) A relation scheme is in ..... if it is in the 1NF and if all non prime attributes are fully
functionally dependent on the relation key
47) In a Third Normal Form relation, every ......attribute is non - transitively and fully
dependent on the every candidate key
a. Prime
b. Non Prime
c. Unique
d. None of these
a. Database
b. Data table
c. Data Dictionary
d. Data Document
51. You own a table called EMPLOYEES with this table structure:
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE
DELETE employees;
D. The data in the EMPLOYEES table is deleted but not the structure.
52. You need to create a table named ORDERS that contains four columns:
When a row is inserted into the table, if no value is provided for the status of the order, the value
order_id NUMBER(10),
customer_id NUMBER(8),
date_ordered VARCHAR2 );
order_id NUMBER(10),
customer_id NUMBER(8),
date_ordered DATE );
order_id NUMBER(10),
customer_id NUMBER(8),
date_ordered DATE );
order_id NUMBER(10),
customer_id NUMBER(8),
date_ordered DATE );
53. Which SELECT statement should you use if you want to display unique combinations of the
FROM employee;
FROM employee;
FROM employee;
FROM employee;
54. You need to produce a report for mailing labels for all customers. The mailing label must have
only the customer name and address. The CUSTOMERS table has these columns:
CUST_ID NUMBER(4) NOT NULL
CUST_NAME VARCHAR2(100)
CUST_ADDRESS VARCHAR2(150)
CUST_PHONE VARCHAR2(20)
56. Which SQL statement generates the alias Annual Salary for the calculated column SALARY*12?
58. You need to modify the STUDENTS table to add a primary key on the STUDENT_ID column. The
59. You want to create a report displaying employee last names, department names, and locations.
60. You need to display the employees who have not been assigned to any department. You write the
SELECT statement:
SELECT LAST_NAME, SALARY, DEPARTMENT_ID
FROM EMP
A. The column in the WHERE clause should be changed to display the desired results.
B. The operator in the WHERE clause should be changed to display the desired results.
C. The WHERE clause should be changed to use an outer join to display the desired results.
STUDENT_ID NUMBER(12)
SEMESTER_END DATE
GPA NUMBER(4,3)
The registrar has requested a report listing the students' grade point averages (GPA), sorted from
highest grade point average to lowest within each semester, starting from the earliest date. Which
B. SELECT student_id, semester_end, gpa FROM student_grades ORDER BY semester_end ASC, gpa
ASC;
62. Which two statements are true about WHERE and HAVING clauses? (Choose two)
E. A WHERE clause CANNOT be used in a query of the query uses a HAVING clause.
63. You are sorting data in a table in you SELECT statement in descending order. The column you are
sorting on contains NULL records, where will the NULL record appears?
64. Which two aggregate functions are valid on the START_DATE column? (Choose two)
A. SUM(start_date)
B. AVG(start_date)
C. COUNT(start_date)
D. AVG(start_date, end_date)
E. MIN(start_date)
F. MAXIMUM(start_date)
A. WHERE
B. HAVING
C. RESTRICT
D. GROUP BY
E. ORDER BY
66.
In a SELECT statement that includes a WHERE clause, where is the GROUP BY clause placed
67.
In which two cases would you use an outer join? (Choose two.)
C. The tables being joined have both matched and unmatched data.
68.
The SAL column stores the monthly salary of the employee. Which change must be made to the
above syntax to calculate the annual compensation as "monthly salary plus a monthly bonus of
69.
70.
C. You want all matched and unmatched data from only one table.
71.
A. descending alphabetically
B. descending by date
C. randomly
D. ascending by date
E. ascending alphabetically
72.
73.
What is true regarding subqueries?
A. The inner query must always return a value or the outer query will give an error.
C. The inner query always sorts the results of the outer query.
E. The outer query always sorts the results of the inner query.
74.
ROLLBACK;
DESCRIBE DEPT
A. The DESCRIBE DEPT statement returns an error ORA-04043: object DEPT does not exist.
B. The DESCRIBE DEPT statement displays the structure of the DEPT table.
C. The DESCRIBE DEPT statement displays the structure of the DEPT table only if there is a
D. The ROLLBACK statement frees the storage space occupied by the DEPT table.
75.