Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Data Structure Review

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Data Structure Review. Start with the requirements and the three tables on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Tell me about how you would review SQL data structures for correctness and performance.

Using the supplied PostgreSQL metadata snapshot, identify tables that need structural or performance review. Include key metadata and scan statistics so the findings can be investigated.

Output

  1. One row per table requiring review.
  2. Include table_name, correctness and performance statuses, primary-key counts, and scan counts.
  3. Sort alphabetically by table_name.

Schema

schema_tables
ColumnTypeDescription
table_idPKINTMetadata table identifier
table_nameVARCHAR(100)Name of the reviewed table
row_countBIGINTEstimated number of rows
requires_primary_keyBOOLEANWhether the table is expected to have a primary key
schema_columns
ColumnTypeDescription
column_idPKINTMetadata column identifier
table_idINTReferenced table metadata identifier
column_nameVARCHAR(100)Reviewed column name
is_primary_keyBOOLEANWhether the column belongs to the primary key
is_nullableBOOLEANWhether the column permits null values
query_scan_stats
ColumnTypeDescription
stat_idPKINTScan-statistics record identifier
table_idINTReferenced table metadata identifier
sequential_scansBIGINTObserved sequential scan count
index_scansBIGINTObserved index scan count
Tablesschema_tablesschema_columnsquery_scan_stats
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results