mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-14 01:00:36 -04:00
feat(curriculum): Add relational database quiz (#56561)
This commit is contained in:
@@ -17,439 +17,439 @@ Answer all of the questions below correctly to pass the quiz.
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is a relational database?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
A database structured to recognize non-relation between stored items.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
A database that stores unstructured data.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
A flat file-based system.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
A database structured to recognize relations between stored items.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
How does a non-relational database differ from a relational database?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Non-relational databases use tables, while relational databases do not.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Relational databases can store unstructured data.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Non-relational databases are slower than relational databases.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Non-relational databases can store unstructured data.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What does the `\l` command do when executed in the PostgreSQL interactive terminal (`psql`)?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Lists all schemas
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Lists all tables
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Connects to a database
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Lists all databases
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which of the following commands creates a new table in SQL?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`ADD TABLE`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`NEW TABLE`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`ALTER TABLE`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`CREATE TABLE`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is the purpose of a foreign key in a relational database?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
To allow duplication of data.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
To uniquely identify a row in the table.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
To store large amounts of text data.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
To create a relationship between two tables.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which command will add a new column to an existing table?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`ADD COLUMN column_name TO table_name data_type;`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`INSERT COLUMN column_name INTO table_name data_type;`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`MODIFY TABLE table_name ADD COLUMN column_name data_type;`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`ALTER TABLE table_name ADD COLUMN column_name data_type;`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What type of relationship exists when one record in Table A corresponds to one or more records in Table B?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
One-to-One (1-1)
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Many-to-Many (m-m)
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Many-to-one(m-1)
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
One-to-Many (1-m)
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is the primary purpose of normalization in a relational database?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
To increase the speed of data retrieval.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
To enforce security measures.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
To simplify the database schema.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
To eliminate data redundancy and ensure data integrity.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
How do you delete a column from a table in SQL?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`REMOVE COLUMN column_name FROM table_name;`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`DELETE COLUMN column_name FROM table_name;`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`MODIFY TABLE table_name DELETE column_name;`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`ALTER TABLE table_name DROP COLUMN column_name;`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is the function of the `PRIMARY KEY` constraint in SQL?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
To link two tables together.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
To define the default value for a column.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
To allow null values in the column.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
To ensure that the column contains unique values.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What does the command `\c` do in the PostgreSQL interactive terminal (`psql`)?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Lists all tables in the current database.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Displays the current database connection details.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Exits the `psql` shell.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Connects to the specified database.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is a composite key in a relational database?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
A key that is derived from another key.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
A key that changes frequently based on data updates.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
A key used exclusively for foreign key relationships.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
A key that is composed of multiple columns to uniquely identify a record.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which command inserts data into a table?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`PUT VALUES`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`UPDATE INTO`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`ADD DATA`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`INSERT INTO`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
How do you rename a column in SQL?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`MODIFY COLUMN`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`CHANGE COLUMN`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`ALTER COLUMN`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`RENAME COLUMN`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which query will delete all records from the employees table?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`REMOVE ALL`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`TRUNCATE employees`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`DROP RECORDS`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`DELETE FROM employees`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
Which SQL constraint specifically ensures that a column can contain only unique values, allowing nulls?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`NOT NULL`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`FOREIGN KEY`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`PRIMARY KEY`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`UNIQUE`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
In a relational database, what is an index used for?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
To store additional metadata about tables.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
To ensure unique values in a column.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
To enforce data integrity.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
To speed up data retrieval.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What does a one-to-one (1-1) relationship represent in a relational database?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
Each record in Table A corresponds to one or more records in Table B.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
Each record in Table A corresponds to no records in Table B.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
Each record in Table A corresponds to multiple records in Table B and vice versa.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
Each record in Table A corresponds to exactly one record in Table B.
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What command will list all tables in the current PostgreSQL database?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
`\l`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
`SHOW TABLES`
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
`\t`
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
`\d`
|
||||
|
||||
### --question--
|
||||
|
||||
#### --text--
|
||||
|
||||
Placeholder question
|
||||
What is a composite key in a relational database?
|
||||
|
||||
#### --distractors--
|
||||
|
||||
Placeholder distractor 1
|
||||
A key that is derived from another key.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 2
|
||||
A key that changes frequently based on data updates.
|
||||
|
||||
---
|
||||
|
||||
Placeholder distractor 3
|
||||
A key used exclusively for foreign key relationships.
|
||||
|
||||
#### --answer--
|
||||
|
||||
Placeholder answer
|
||||
A key that is composed of multiple columns to uniquely identify a record.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user