PostgreSQL Database Quiz Questions

Course Name:PostgreSQL
Chapter Name:Chapter 8 - RDBMS Concepts
Lesson Content Link:Third Normal Form
Current Quiz Count:30
Progress
0%
Q1
True / False

In PostgreSQL, a table must be in Second Normal Form (2NF) before it can be in Third Normal Form (3NF).

Q2
True / False

In PostgreSQL, a table is in Third Normal Form (3NF) if it has no transitive dependencies.

Q3
True / False

In PostgreSQL, a table with a single-column primary key and no transitive dependencies is automatically in Third Normal Form (3NF).

Q4
True / False

In PostgreSQL, achieving Third Normal Form (3NF) often involves moving columns to new tables to eliminate transitive dependencies.

Q5
True / False

In PostgreSQL, a table in Third Normal Form (3NF) cannot have any redundant data.

Q6
True / False

In PostgreSQL, if a non-key attribute depends on another non-key attribute, the table is not in Third Normal Form (3NF).

Q7
True / False

In PostgreSQL, a table that meets the requirements of Boyce-Codd Normal Form (BCNF) is also in Third Normal Form (3NF).

Q8
True / False

In PostgreSQL, a table with a composite primary key can be in Third Normal Form (3NF) even if some non-key attributes are partially dependent on the primary key.

Q9
True / False

In PostgreSQL, achieving Third Normal Form (3NF) ensures that all non-key attributes are only dependent on the primary key.

Q10
True / False

In PostgreSQL, a table in Third Normal Form (3NF) can still have multi-valued attributes as long as they do not create transitive dependencies.

Q11
Single Choice

Which of the following is a requirement for a table to be in Third Normal Form (3NF) in PostgreSQL?

Q12
Single Choice

A table in PostgreSQL is in 3NF if it is in 2NF and:

Q13
Single Choice

In PostgreSQL, what is eliminated in a table to achieve 3NF?

Q14
Single Choice

Consider the following PostgreSQL table schema:

SQL Code
CREATE TABLE Orders (
 OrderID INT PRIMARY KEY,
 CustomerID INT,
 OrderDate DATE,
 CustomerAddress VARCHAR(255)
);
Which of the following issues would prevent this table from being in 3NF?
Q15
Single Choice

Given a PostgreSQL table Employees defined as:

SQL Code
CREATE TABLE Employees (
 EmployeeID SERIAL PRIMARY KEY,
 DepartmentID INT,
 DepartmentName VARCHAR(100),
 ManagerID INT
);
How can this table be brought into 3NF?
Q16
Single Choice

A PostgreSQL table Books contains columns BookID, AuthorID, AuthorName, and Title. To convert this table to 3NF, what step should be taken?

Q17
Single Choice

Given the following PostgreSQL schema, which is NOT in 3NF:

SQL Code
CREATE TABLE Courses (
 CourseID INT PRIMARY KEY,
 InstructorID INT,
 InstructorName VARCHAR(100),
 CourseName VARCHAR(100)
);
How would you normalize this schema to meet 3NF requirements?
Q18
Single Choice

Which of the following PostgreSQL table designs conforms to 3NF?

Q19
Single Choice

In a PostgreSQL database, if you have a table with columns ProductID, ProductName, CategoryID, and CategoryName, what would be the correct approach to achieve 3NF?

Q20
Single Choice

In PostgreSQL, a table is in 3NF if:

Q21
Multiple Choice

Which of the following best describes Third Normal Form (3NF) in PostgreSQL?

SQL Code
Consider a table 'employee_details' with columns 'employee_id', 'employee_name', 'department_id', 'department_name', and 'location'. Normalize it to 3NF by ensuring that all non-key attributes are non-transitively dependent on the primary key.

```sql
CREATE TABLE departments (
 department_id SERIAL PRIMARY KEY,
 department_name VARCHAR(100),
 location VARCHAR(100)
);

CREATE TABLE employees (
 employee_id SERIAL PRIMARY KEY,
 employee_name VARCHAR(100),
 department_id INT REFERENCES departments(department_id)
);
```
Q22
Multiple Choice

Which scenario violates Third Normal Form (3NF) in PostgreSQL?

SQL Code
Consider a table 'student_records' with columns 'student_id', 'student_name', 'advisor_id', 'advisor_name', and 'department_name'. Normalize it to 3NF by ensuring non-key attributes do not depend on other non-key attributes.

```sql
CREATE TABLE advisors (
 advisor_id SERIAL PRIMARY KEY,
 advisor_name VARCHAR(100),
 department_name VARCHAR(100)
);

CREATE TABLE students (
 student_id SERIAL PRIMARY KEY,
 student_name VARCHAR(100),
 advisor_id INT REFERENCES advisors(advisor_id)
);
```
Q23
Multiple Choice

How would you convert a table from 2NF to 3NF in PostgreSQL?

SQL Code
Given a table 'project_assignments' with columns 'project_id', 'employee_id', 'employee_name', and 'department_name', normalize it to 3NF by removing any transitive dependencies.

```sql
CREATE TABLE departments (
 department_id SERIAL PRIMARY KEY,
 department_name VARCHAR(100)
);

CREATE TABLE employees (
 employee_id SERIAL PRIMARY KEY,
 employee_name VARCHAR(100),
 department_id INT REFERENCES departments(department_id)
);

CREATE TABLE projects (
 project_id SERIAL PRIMARY KEY
);

CREATE TABLE project_assignments (
 project_id INT REFERENCES projects(project_id),
 employee_id INT REFERENCES employees(employee_id),
 PRIMARY KEY (project_id, employee_id)
);
```
Q24
Multiple Choice

Which of the following is a characteristic of a table in 3NF in PostgreSQL?

SQL Code
Consider a table 'supplier_orders' with columns 'order_id', 'supplier_id', 'supplier_name', and 'order_date'. Normalize it to 3NF by ensuring all non-key attributes are non-transitively dependent on the primary key.

```sql
CREATE TABLE suppliers (
 supplier_id SERIAL PRIMARY KEY,
 supplier_name VARCHAR(100)
);

CREATE TABLE orders (
 order_id SERIAL PRIMARY KEY,
 supplier_id INT REFERENCES suppliers(supplier_id),
 order_date DATE
);
```
Q25
Multiple Choice

What are the steps to achieve Third Normal Form (3NF) in a PostgreSQL database?

SQL Code
Normalize a table 'customer_orders' with columns 'order_id', 'customer_id', 'customer_address', and 'order_total' to 3NF by eliminating transitive dependencies.

```sql
CREATE TABLE customers (
 customer_id SERIAL PRIMARY KEY,
 customer_address TEXT
);

CREATE TABLE orders (
 order_id SERIAL PRIMARY KEY,
 customer_id INT REFERENCES customers(customer_id),
 order_total NUMERIC(10, 2)
);
```
Q26
Multiple Choice

How does 3NF improve data integrity in PostgreSQL?

SQL Code
Normalize a table 'product_sales' with columns 'sale_id', 'product_id', 'product_name', and 'salesperson_name' to 3NF by removing any transitive dependencies.

```sql
CREATE TABLE products (
 product_id SERIAL PRIMARY KEY,
 product_name VARCHAR(100)
);

CREATE TABLE salespersons (
 salesperson_id SERIAL PRIMARY KEY,
 salesperson_name VARCHAR(100)
);

CREATE TABLE product_sales (
 sale_id SERIAL PRIMARY KEY,
 product_id INT REFERENCES products(product_id),
 salesperson_id INT REFERENCES salespersons(salesperson_id)
);
```
Q27
Multiple Choice

What is a potential drawback of applying 3NF in PostgreSQL?

SQL Code
Consider a table 'invoice_details' with columns 'invoice_id', 'product_id', 'product_description', and 'supplier_name'. Normalize it to 3NF by removing transitive dependencies, but consider the potential increase in table joins.

```sql
CREATE TABLE products (
 product_id SERIAL PRIMARY KEY,
 product_description TEXT
);

CREATE TABLE suppliers (
 supplier_id SERIAL PRIMARY KEY,
 supplier_name VARCHAR(100)
);

CREATE TABLE invoices (
 invoice_id SERIAL PRIMARY KEY,
 product_id INT REFERENCES products(product_id),
 supplier_id INT REFERENCES suppliers(supplier_id)
);
```
Q28
Multiple Choice

Which of the following is an example of a table that is not in 3NF?

SQL Code
Consider a table 'book_inventory' with columns 'book_id', 'book_title', 'publisher_name', and 'publisher_address'. Identify the transitive dependency and normalize it to 3NF.

```sql
CREATE TABLE books (
 book_id SERIAL PRIMARY KEY,
 book_title VARCHAR(100)
);

CREATE TABLE publishers (
 publisher_id SERIAL PRIMARY KEY,
 publisher_name VARCHAR(100),
 publisher_address TEXT
);

CREATE TABLE book_inventory (
 book_id INT REFERENCES books(book_id),
 publisher_id INT REFERENCES publishers(publisher_id),
 PRIMARY KEY (book_id, publisher_id)
);
```
Q29
Multiple Choice

What is the impact of not applying 3NF in a PostgreSQL database?

SQL Code
Normalize a table 'course_enrollments' with columns 'course_id', 'student_id', 'course_name', and 'instructor_name' to 3NF to eliminate transitive dependencies.

```sql
CREATE TABLE courses (
 course_id SERIAL PRIMARY KEY,
 course_name VARCHAR(100)
);

CREATE TABLE instructors (
 instructor_id SERIAL PRIMARY KEY,
 instructor_name VARCHAR(100)
);

CREATE TABLE course_enrollments (
 course_id INT REFERENCES courses(course_id),
 student_id INT REFERENCES students(student_id),
 instructor_id INT REFERENCES instructors(instructor_id),
 PRIMARY KEY (course_id, student_id)
);
```
Q30
Multiple Choice

How can a table in 3NF improve database performance in PostgreSQL?

SQL Code
Normalize a table 'employee_salaries' with columns 'employee_id', 'salary', 'department_name', and 'manager_name' to 3NF by removing transitive dependencies.

```sql
CREATE TABLE employees (
 employee_id SERIAL PRIMARY KEY,
 salary NUMERIC(10, 2)
);

CREATE TABLE departments (
 department_id SERIAL PRIMARY KEY,
 department_name VARCHAR(100)
);

CREATE TABLE managers (
 manager_id SERIAL PRIMARY KEY,
 manager_name VARCHAR(100)
);

CREATE TABLE employee_salaries (
 employee_id INT REFERENCES employees(employee_id),
 department_id INT REFERENCES departments(department_id),
 manager_id INT REFERENCES managers(manager_id),
 PRIMARY KEY (employee_id, department_id)
);
```