curriculum/challenges/english/blocks/quiz-sql-and-postgresql/66f1af82732957c895f0b21a.md
To pass the quiz, you must correctly answer at least 18 of the 20 questions below.
What is a relational database?
A database structured to recognize non-relation between stored items.
A database that stores unstructured data.
A flat file-based system.
A database structured to recognize and manage relationships between data in tables.
How does a non-relational database differ from a relational database?
Non-relational databases use tables, while relational databases do not.
Relational databases can store unstructured data.
Non-relational databases are slower than relational databases.
Non-relational databases can store unstructured data.
What does the \l command do when executed in the PostgreSQL interactive terminal (psql)?
Lists all schemas.
Lists all tables.
Connects to a database.
Lists all databases.
Which of the following commands creates a new table in SQL?
ADD TABLE
NEW TABLE
ALTER TABLE
CREATE TABLE
What is the purpose of a foreign key in a relational database?
To allow duplication of data.
To uniquely identify a row in the table.
To store large amounts of text data.
To create a relationship between two tables.
Which command will add a new column to an existing table?
ADD COLUMN column_name TO table_name data_type;
INSERT COLUMN column_name INTO table_name data_type;
MODIFY TABLE table_name ADD COLUMN column_name data_type;
ALTER TABLE table_name ADD COLUMN column_name data_type;
What type of relationship exists when one record in Table A corresponds to one or more records in Table B?
One-to-One (1-1)
Many-to-Many (m-m)
Many-to-one(m-1)
One-to-Many (1-m)
What is a query?
A request to remove all data from the database.
A special row for unique values in a database.
A special column for unique values in a database.
A request for specific data from the database.
How do you delete a column from a table in SQL?
REMOVE COLUMN column_name FROM table_name;
DELETE COLUMN column_name FROM table_name;
MODIFY TABLE table_name DELETE column_name;
ALTER TABLE table_name DROP COLUMN column_name;
What is the function of the PRIMARY KEY constraint in SQL?
To link two tables together.
To define the default value for a column.
To allow null values in the column.
To ensure that the column contains unique values.
What does the command \c do in the PostgreSQL interactive terminal (psql)?
Lists all tables in the current database.
Displays the current database connection details.
Exits the psql shell.
Connects to the specified database.
What is a composite key in a relational database?
A key that is derived from another key.
A key that changes frequently based on data updates.
A key used exclusively for foreign key relationships.
A key that is composed of multiple columns to uniquely identify a record.
Which command inserts data into a table?
PUT VALUES
UPDATE INTO
ADD DATA
INSERT INTO
How do you rename a column in SQL?
MODIFY COLUMN
CHANGE COLUMN
ALTER COLUMN
RENAME COLUMN
Which query will delete all records from the employees table?
REMOVE ALL
TRUNCATE employees
DROP RECORDS
DELETE FROM employees
Which SQL constraint specifically ensures that a column can contain only unique values, allowing nulls?
NOT NULL
FOREIGN KEY
PRIMARY KEY
UNIQUE
Which of the following is NOT an example of a commonly used relational database in the industry?
MySQL
SQLite
PostgreSQL
SQLQuery
What does a one-to-one (1-1) relationship represent in a relational database?
Each record in Table A corresponds to one or more records in Table B.
Each record in Table A corresponds to no records in Table B.
Each record in Table A corresponds to multiple records in Table B and vice versa.
Each record in Table A corresponds to exactly one record in Table B.
What command will list all tables in the current PostgreSQL database?
\l
SHOW TABLES
\t
\d
Which of the following allows you to join a table with itself?
LEFT OUTER JOIN
CROSS JOIN
RIGHT OUTER JOIN
SELF JOIN