Complete the code to select all columns from the table named 'students'.
SELECT [1] FROM students;The asterisk (*) selects all columns from the table.
Complete the code to select the 'name' and 'phone_numbers' columns from the 'contacts' table.
SELECT name, [1] FROM contacts;The column name is 'phone_numbers' which may contain multiple phone numbers, but in 1NF, each value should be atomic.
Fix the error in the query that tries to select rows where the 'phone_numbers' column contains multiple values, which violates 1NF.
SELECT * FROM contacts WHERE phone_numbers [1] '%,%';
The LIKE operator checks if the 'phone_numbers' string contains a comma, indicating multiple values in one field, which violates 1NF.
Fill both blanks to create a query that selects 'id' and 'phone' from 'contacts' where 'phone' is atomic (does not contain commas).
SELECT id, [1] FROM contacts WHERE [2] NOT LIKE '%,%';
We select the atomic 'phone' column and filter rows where 'phone' does not contain commas, ensuring 1NF compliance.
Fill all three blanks to create a query that creates a new table 'contacts_1nf' with atomic phone numbers by splitting 'phone_numbers' into single values.
CREATE TABLE contacts_1nf AS SELECT id, [1] AS phone FROM contacts, [2](phone_numbers) AS [3] WHERE phone IS NOT NULL;
The 'unnest' function is used to split array-like 'phone_numbers' into single 'phone' values, creating a 1NF-compliant table.