Recall & Review
beginner
What is the public schema in PostgreSQL?
The public schema is the default schema created in every new PostgreSQL database. It is a shared space where database objects like tables and functions are stored if no other schema is specified.
Click to reveal answer
beginner
Why would you create a custom schema in PostgreSQL?
Custom schemas help organize database objects into separate namespaces. This improves clarity, security, and management by grouping related objects and avoiding name conflicts.
Click to reveal answer
intermediate
How does PostgreSQL find a table when you run a query without specifying a schema?
PostgreSQL searches schemas in the order listed in the search_path setting. By default, it looks in the public schema first, then others if configured.
Click to reveal answer
intermediate
Can multiple schemas have tables with the same name in PostgreSQL?
Yes. Schemas act like folders. Different schemas can have tables with the same name without conflict because the full name includes the schema name.
Click to reveal answer
beginner
How do you specify a table in a custom schema in a SQL query?
Use the format
schema_name.table_name. For example, sales.orders refers to the orders table in the sales schema.Click to reveal answer
What is the default schema in a new PostgreSQL database?
✗ Incorrect
The default schema created in every new PostgreSQL database is called 'public'.
Why use custom schemas instead of only the public schema?
✗ Incorrect
Custom schemas help organize database objects and prevent name conflicts by grouping related objects.
If two schemas have a table named 'users', how does PostgreSQL know which one to use?
✗ Incorrect
PostgreSQL uses the search_path order or requires you to specify the schema explicitly to know which table to use.
How do you write a query to select from a table named 'orders' in a schema named 'sales'?
✗ Incorrect
The correct format is schema_name.table_name, so 'sales.orders' selects the orders table in the sales schema.
What happens if you create a table without specifying a schema in PostgreSQL?
✗ Incorrect
If no schema is specified, PostgreSQL creates the table in the public schema by default.
Explain the difference between the public schema and custom schemas in PostgreSQL.
Think about why you might want to separate tables into different groups.
You got /4 concepts.
Describe how PostgreSQL uses the search_path to find tables when no schema is specified.
Imagine looking for a file in folders one by one.
You got /4 concepts.