Database Basics

Practice questions

The property that says a transaction happens completely or not at all is

  1. Isolation
  2. Atomicity
  3. Durability
  4. Indexing
Answer and explanation

Answer: B

Atomicity means all of the transaction is done or none of it is.

Which data type is best for a telephone STD code such as 0471?

  1. Text
  2. Integer
  3. Date
  4. Decimal
Answer and explanation

Answer: A

Treated as a number, the leading zero would be lost. Text keeps it.

COMMIT is a command of

  1. DDL
  2. DML
  3. TCL
  4. DCL
Answer and explanation

Answer: C

COMMIT ends a transaction and saves its changes, so it is a transaction control command.

Which object is used mainly to print a formatted summary?

  1. Form
  2. Query
  3. Index
  4. Report
Answer and explanation

Answer: D

A report presents data in a layout suitable for printing.

CREATE, ALTER and DROP belong to

  1. DML
  2. DDL
  3. DCL
  4. TCL
Answer and explanation

Answer: B

These commands define or change structure, so they are in Data Definition Language.

A foreign key

  1. Must stay unique in its table
  2. Is always left as NULL
  3. Is the same as the degree
  4. Points to another table's key
Answer and explanation

Answer: D

A foreign key stores values that match the primary key of a related table.

Table R(A, B, C) has A as its only candidate key. How many superkeys does it have?

  1. 4
  2. 1
  3. 2
  4. 8
Answer and explanation

Answer: A

A superkey must contain A; B and C are each optional, giving 2 x 2 = 4 sets.

In ENROL(StudentID, CourseID, Grade), the primary key is

  1. StudentID, taken alone
  2. Grade, taken alone
  3. CourseID, taken alone
  4. StudentID with CourseID
Answer and explanation

Answer: D

Only the combination is unique for each row, so a composite key is needed.

A candidate key not chosen as primary key is called

  1. Foreign key
  2. Alternate key
  3. Composite key
  4. Super table
Answer and explanation

Answer: B

Candidate keys that are not made primary are alternate keys.

A table has 12 rows and 5 columns. Its cardinality is

  1. 5
  2. 17
  3. 12
  4. 60
Answer and explanation

Answer: C

Cardinality means the number of rows, which is 12. The degree is 5.

How many rows does SELECT Cat, COUNT(*) FROM SALES GROUP BY Cat return?

  1. 6
  2. 3
  3. 1
  4. 2
Answer and explanation

Answer: D

There are two categories, so there are two output rows.

The AVG(Rate) for Accessories is

  1. 110
  2. 220
  3. 150
  4. 450
Answer and explanation

Answer: B

(450 + 120 + 90) / 3 = 660 / 3 = 220.

Which clause can use the condition SUM(Qty) > 60?

  1. WHERE
  2. ORDER BY only
  3. FROM
  4. HAVING
Answer and explanation

Answer: D

A condition on an aggregate belongs in HAVING, which filters groups.

What is the value of SUM(Qty * Rate) for Accessories?

  1. 2250
  2. 3600
  3. 4410
  4. 1440
Answer and explanation

Answer: C

2250 + 1440 + 720 = 4410.

In the SALES table, what is SUM(Qty) for the Stationery group?

  1. 120
  2. 90
  3. 100
  4. 80
Answer and explanation

Answer: A

50 + 30 + 40 = 120.

What does SELECT EName, Salary + 2000 FROM EMP WHERE Job = 'Manager' do to the stored salaries?

  1. Raises them by 2000 in the table
  2. Deletes the managers' rows
  3. Only displays higher values
  4. Adds a new column for good
Answer and explanation

Answer: C

SELECT only displays results. To change stored values you would need UPDATE.

SELECT DISTINCT DeptNo FROM EMP returns

  1. 8 rows
  2. 3 rows
  3. 2 rows
  4. 1 row
Answer and explanation

Answer: B

The department numbers are 10, 20 and 30, so three different values appear.

Which employee has the second-highest salary in EMP?

  1. Bela
  2. Fatima
  3. Dolly
  4. Gopal
Answer and explanation

Answer: A

Fatima earns 52000 and Bela 45000, which is second. Dolly earns 38000.

SELECT EName FROM EMP WHERE EName LIKE '%a'; returns how many rows?

  1. 2
  2. 4
  3. 5
  4. 3
Answer and explanation

Answer: D

Bela, Fatima and Hema end with a. Dolly, Gopal and the rest do not.

How many employees in the table have Job = 'Clerk'?

  1. 3
  2. 5
  3. 2
  4. 4
Answer and explanation

Answer: D

The clerks are Aman, Chirag, Eshan and Hema, so there are four.

Privacy · Terms · Refunds · Delivery