PostgreSQL Database Quiz Questions

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

In PostgreSQL, a table is in First Normal Form (1NF) if it contains duplicate rows.

Q2
True / False

In PostgreSQL, a table must have a primary key to be in First Normal Form (1NF).

Q3
True / False

In PostgreSQL, a table is in First Normal Form (1NF) if it contains only atomic (indivisible) values.

Q4
True / False

In PostgreSQL, a table with repeating groups or arrays in a column is not in First Normal Form (1NF).

Q5
True / False

In PostgreSQL, a table with multi-valued attributes in a single column is considered normalized to First Normal Form (1NF).

Q6
True / False

In PostgreSQL, a table that meets the requirements of First Normal Form (1NF) can still have redundancy issues.

Q7
True / False

In PostgreSQL, converting a table to First Normal Form (1NF) may require splitting a column into multiple columns.

Q8
True / False

In PostgreSQL, tables that are not in First Normal Form (1NF) can still be used efficiently in certain applications.

Q9
True / False

In PostgreSQL, a composite key can violate the First Normal Form (1NF).

Q10
True / False

In PostgreSQL, ensuring a table is in First Normal Form (1NF) includes making sure that each column contains only scalar values, such as integers or strings, but not arrays or records.

Q11
Single Choice

What is the primary purpose of database normalization in PostgreSQL?

Q12
Single Choice

Which of the following is the first step in the normalization process?

Q13
Single Choice

Which of the following conditions must a table satisfy to be in the Second Normal Form (2NF) in PostgreSQL?

Q14
Single Choice

Consider the following PostgreSQL table orders:

SQL Code
CREATE TABLE orders (
 order_id SERIAL PRIMARY KEY,
 customer_id INT,
 product_id INT,
 order_date DATE,
 customer_name VARCHAR(255)
);
Which normal form is this table violating, assuming customer_name should be part of a separate table?
Q15
Single Choice

Which of the following PostgreSQL SQL queries demonstrates converting a table to Second Normal Form (2NF)?

Q16
Single Choice

In PostgreSQL, which normalization form requires that a table should not have any partial dependency on a composite primary key?

Q17
Single Choice

Given the following PostgreSQL table students:

SQL Code
CREATE TABLE students (
 student_id SERIAL PRIMARY KEY,
 student_name VARCHAR(255),
 course_id INT,
 course_name VARCHAR(255),
 instructor_name VARCHAR(255)
);
What is the highest normal form this table can be converted to, without any changes?
Q18
Single Choice

Which SQL code snippet would convert the students table above into Third Normal Form (3NF) in PostgreSQL

Q19
Single Choice

Which of the following is true about Boyce-Codd Normal Form (BCNF) in PostgreSQL?

Q20
Single Choice

In PostgreSQL, if a table is in Third Normal Form (3NF) but not in Boyce-Codd Normal Form (BCNF), which scenario is likely to occur?

Q21
Multiple Choice

What is the purpose of normalization in a PostgreSQL database?

SQL Code
Given a table 'orders' with redundant customer data, normalize it into separate tables for customers and orders.

CREATE TABLE customers (
 customer_id SERIAL PRIMARY KEY,
 customer_name VARCHAR(100),
 customer_email VARCHAR(100)
);

CREATE TABLE orders (
 order_id SERIAL PRIMARY KEY,
 order_date DATE,
 customer_id INT REFERENCES customers(customer_id)
);

INSERT INTO customers (customer_name, customer_email) VALUES ('John Doe', 'john.doe@example.com');
INSERT INTO orders (order_date, customer_id) VALUES ('2024-08-20', 1);
Q22
Multiple Choice

Which normalization form eliminates partial dependency in a PostgreSQL table?

SQL Code
Given a table 'order_details' with columns 'order_id', 'product_id', and 'product_price', normalize it to 2NF by creating separate tables for orders and products.

CREATE TABLE orders (
 order_id SERIAL PRIMARY KEY,
 order_date DATE
);

CREATE TABLE products (
 product_id SERIAL PRIMARY KEY,
 product_name VARCHAR(100),
 product_price NUMERIC(10, 2)
);

CREATE TABLE order_details (
 order_detail_id SERIAL PRIMARY KEY,
 order_id INT REFERENCES orders(order_id),
 product_id INT REFERENCES products(product_id)
);
Q23
Multiple Choice

What is the main characteristic of a table in Third Normal Form (3NF) in PostgreSQL?

SQL Code
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)
);
Q24
Multiple Choice

What does Boyce-Codd Normal Form (BCNF) achieve that 3NF does not in PostgreSQL?

SQL Code
CREATE TABLE project_managers (
 project_manager_id SERIAL PRIMARY KEY,
 project_manager_name VARCHAR(100)
);

CREATE TABLE projects (
 project_id SERIAL PRIMARY KEY,
 project_manager_id INT REFERENCES project_managers(project_manager_id)
);
Q25
Multiple Choice

Which normalization form eliminates transitive dependency in PostgreSQL?

SQL Code
CREATE TABLE courses (
 course_id SERIAL PRIMARY KEY,
 course_name VARCHAR(100)
);

CREATE TABLE student_grades (
 grade_id SERIAL PRIMARY KEY,
 student_id INT,
 course_id INT REFERENCES courses(course_id),
 grade VARCHAR(2)
);
Q26
Multiple Choice

How would you normalize a table with repeating groups in PostgreSQL?

SQL Code
CREATE TABLE sales (
 sales_id SERIAL PRIMARY KEY,
 product_name VARCHAR(100)
);

INSERT INTO sales (sales_id, product_name) VALUES (1, 'Product A');
INSERT INTO sales (sales_id, product_name) VALUES (1, 'Product B');
INSERT INTO sales (sales_id, product_name) VALUES (1, 'Product C');
Q27
Multiple Choice

What does the process of denormalization involve in PostgreSQL?

SQL Code
CREATE TABLE order_summary (
 order_id SERIAL PRIMARY KEY,
 order_date DATE,
 customer_name VARCHAR(100),
 customer_email VARCHAR(100)
);

INSERT INTO order_summary (order_date, customer_name, customer_email)
SELECT o.order_date, c.customer_name, c.customer_email
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id;
Q28
Multiple Choice

In PostgreSQL, how would you address a normalization issue where an attribute depends on only part of a composite key?

SQL Code
Normalize a table 'employee_projects' with columns 'employee_id', 'project_id', and 'project_lead' to 2NF by ensuring each non-prime attribute is fully functionally dependent on the whole key.

```sql
CREATE TABLE projects (
 project_id SERIAL PRIMARY KEY,
 project_lead VARCHAR(100)
);

CREATE TABLE employee_projects (
 employee_project_id SERIAL PRIMARY KEY,
 employee_id INT,
 project_id INT REFERENCES projects(project_id)
);
```
Q29
Multiple Choice

What is the main goal of Fourth Normal Form (4NF) in PostgreSQL?

SQL Code
CREATE TABLE products (
 product_id SERIAL PRIMARY KEY,
 product_name VARCHAR(100)
);

CREATE TABLE stores (
 store_id SERIAL PRIMARY KEY,
 store_location VARCHAR(100)
);

CREATE TABLE product_sales (
 product_id INT REFERENCES products(product_id),
 store_id INT REFERENCES stores(store_id),
 sales_quantity INT,
 PRIMARY KEY (product_id, store_id)
);
Q30
Multiple Choice

What is a common trade-off when applying higher levels of normalization in PostgreSQL?

SQL Code
SELECT e.employee_name, d.department_name, s.salary_amount
FROM employees e
JOIN departments d ON e.department_id = d.department_id
JOIN salaries s ON e.employee_id = s.employee_id;