SOL-C01 · Question #22
A data engineer is tasked with creating a hierarchical structure for managing data access. They need to create a database named 'analytics db', a schema named 'reporting schema', and several views wit
The correct answer is D. CREATE DATABASE analytics_db; CREATE SCHEMA reporting_schema IN DATABASE. Option D is correct because Snowflake enforces a strict object hierarchy: Database → Schema → View. You must create the database first, then create the schema within that database (using IN DATABASE analytics_db), and only then can you create views inside the schema - each object
Question
A data engineer is tasked with creating a hierarchical structure for managing data access. They need to create a database named 'analytics db', a schema named 'reporting schema', and several views within the schema. These views will be used by different teams with varying levels of access. Which of the following SQL statements demonstrates the correct order and structure for creating these Snowflake objects, considering the object hierarchy?
Options
- ACREATE SCHEMA reporting_schema; CREATE DATABASE analytics_db; CREATE VIEW
- BCREATE VIEW AS SELECT FROM tablel ; CREATE SCHEMA reporting_schema; CREATE
- CCREATE DATABASE analytics_db; CREATE SCHEMA CREATE VIEW AS SELECT FROM
- DCREATE DATABASE analytics_db; CREATE SCHEMA reporting_schema IN DATABASE
- ECREATE SCHEMA reporting_schema; CREATE DATABASE analytics_db; CREATE VIEW AS
How the community answered
(49 responses)- A2% (1)
- B2% (1)
- C4% (2)
- D82% (40)
- E10% (5)
Explanation
Option D is correct because Snowflake enforces a strict object hierarchy: Database → Schema → View. You must create the database first, then create the schema within that database (using IN DATABASE analytics_db), and only then can you create views inside the schema - each object depends on its parent existing first.
Why the distractors fail:
- A & E both create the schema before the database - the schema has no parent to live in yet, so this would fail.
- B attempts to create a view first, before either the database or schema exist - views require a schema, which requires a database.
- C appears to follow the right order but uses malformed syntax (no schema name, no
IN DATABASEclause), making it structurally invalid even if the sequence were right.
Memory tip: Think of it like a filing system - you build the cabinet (database) before the drawer (schema) before the folder (view/table). You can never put something inside a container that doesn't exist yet.
Topics
Community Discussion
No community discussion yet for this question.