PostgreSQL Database Quiz Questions

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

In PostgreSQL, structured data is typically stored in tables with rows and columns.

Q2
True / False

Unstructured data cannot be stored in PostgreSQL.

Q3
True / False

Structured data in PostgreSQL must conform to a predefined schema.

Q4
True / False

In PostgreSQL, JSONB is used to store unstructured data efficiently.

Q5
True / False

Structured data is generally more flexible than unstructured data in PostgreSQL.

Q6
True / False

In PostgreSQL, full-text search capabilities are available for unstructured data stored in text columns.

Q7
True / False

In PostgreSQL, indexing unstructured data like JSONB can improve query performance.

Q8
True / False

PostgreSQL does not support relational operations on unstructured data.

Q9
True / False

In PostgreSQL, using structured data ensures data integrity better than using unstructured data.

Q10
True / False

In PostgreSQL, combining structured and unstructured data within the same table is not recommended due to performance issues.

Q11
Single Choice

Which of the following is an example of structured data in PostgreSQL?

Q12
Single Choice

What PostgreSQL feature is used to store unstructured data?

Q13
Single Choice

Which of the following is NOT typically considered structured data in PostgreSQL?

Q14
Single Choice

How does PostgreSQL handle queries on unstructured JSONB data?

Q15
Single Choice

Given the PostgreSQL table documents with a column content JSONB, how would you query for documents containing a specific key-value pair?

Q16
Single Choice

Which PostgreSQL data type is best suited for storing semi-structured data such as JSON?

Q17
Single Choice

What is a key difference between structured data stored in relational tables and unstructured data stored in JSONB columns in PostgreSQL?

Q18
Single Choice

In PostgreSQL, how would you create an index on a JSONB column to optimize queries?

Q19
Single Choice

How can you convert structured data into a JSON format in PostgreSQL?

Q20
Single Choice

Which of the following scenarios demonstrates the use of structured and unstructured data together in PostgreSQL?

Q21
Multiple Choice

What is a key difference between structured and unstructured data in the context of PostgreSQL?

SQL Code
You have a 'products' table with structured data and a 'metadata' column storing unstructured JSON data. Write a query to extract the 'category' from the 'metadata' column for each product.

```sql
SELECT product_id, metadata->>'category' AS category
FROM products;
```
Q22
Multiple Choice

How can you query unstructured JSON data stored in a PostgreSQL table?

SQL Code
Given a 'users' table with a 'profile' column storing JSON data, write a query to extract the 'email' field from the 'profile' column.

```sql
SELECT user_id, profile->>'email' AS email
FROM users;
```
Q23
Multiple Choice

What is the advantage of storing unstructured data in JSON format in PostgreSQL?

SQL Code
Given a 'logs' table with a 'details' column storing JSON data, write a query to filter logs where the 'severity' is 'high'.

```sql
SELECT *
FROM logs
WHERE details->>'severity' = 'high';
```
Q24
Multiple Choice

Which PostgreSQL data types are typically used for unstructured data?

SQL Code
In a 'documents' table, create a column to store unstructured text data and another column to store unstructured JSON data.

```sql
CREATE TABLE documents (
 doc_id SERIAL PRIMARY KEY,
 content TEXT,
 metadata JSONB
);
```
Q25
Multiple Choice

How does indexing work for structured vs. unstructured data in PostgreSQL?

SQL Code
Create an index on the 'metadata' JSONB column of a 'products' table to optimize queries filtering by the 'category' key.

```sql
CREATE INDEX idx_metadata_category
ON products
USING gin ((metadata->>'category'));
```
Q26
Multiple Choice

What is a scenario where structured data is more beneficial than unstructured data?

SQL Code
Given a 'sales' table, write a query to calculate the total sales amount grouped by 'region'.

```sql
SELECT region, SUM(amount) AS total_sales
FROM sales
GROUP BY region;
```
Q27
Multiple Choice

What are the challenges of storing unstructured data in PostgreSQL?

SQL Code
Given a 'customer_feedback' table with a 'comments' JSONB column, write a query to find feedback entries containing the word 'improve'.

```sql
SELECT *
FROM customer_feedback
WHERE comments @> '{"text": "improve"}';
```
Q28
Multiple Choice

How can PostgreSQL's JSONB type be used to store both structured and unstructured data?

SQL Code
Create a 'users' table where the 'profile' column can store JSONB data, which may include both structured (e.g., 'name', 'age') and unstructured (e.g., 'preferences') data.

```sql
CREATE TABLE users (
 user_id SERIAL PRIMARY KEY,
 profile JSONB
);
```
Q29
Multiple Choice

What are the benefits of using structured data over unstructured data in PostgreSQL?

SQL Code
Write a query to join two structured tables, 'orders' and 'customers', based on 'customer_id'.

```sql
SELECT o.order_id, c.customer_name
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id;
```
Q30
Multiple Choice

What considerations should be made when choosing between structured and unstructured data storage in PostgreSQL?

SQL Code
Given a 'media_library' table, write a query to extract metadata from a JSONB column and filter based on the 'type' field.

```sql
SELECT media_id, metadata->>'title' AS title
FROM media_library
WHERE metadata->>'type' = 'video';
```