PostgreSQL Flashcards
What is PostgreSQL also commonly referred to as?
a) PostSQL
b) Postgres
c) PostRelational
d) PGSQL
b) Postgres
What is the primary function of a database schema?
a) To store the entire database data
b) To define constraints for organizing and storing data
c) To run queries efficiently
d) To manage user permissions
b) To define constraints for organizing and storing data
What is the purpose of the id
column in the university
table?
a) To store the university’s name
b) To serve as the primary key
c) To manage foreign key relationships
d) To store timestamp data
b) To serve as the primary key
Which of the following is an example of a surrogate key?
a) A university name
b) A uniquely generated numeric ID
c) A natural column like ‘email’
d) A timestamp value
b) A uniquely generated numeric ID
What type of relationship exists between the nasa_group
table and the astronauts
table?
a) One-to-many
b) Many-to-one
c) Many-to-many
d) One-to-one
b) Many-to-one
Which SQL statement is used to insert data into a table?
a) ADD
b) INSERT
c) UPDATE
d) INCLUDE
b) INSERT
What does the FOREIGN KEY
constraint ensure in a relational database?
a) It prevents duplicate data entries
b) It ensures data integrity by referencing another table’s column
c) It acts as a unique identifier for a table
d) It improves query performance
b) It ensures data integrity by referencing another table’s column
In the missions
table, what is the purpose of the start_date
and end_date
columns?
a) To track mission durations using the timestamp data type
b) To count the number of missions
c) To define relationships between tables
d) To store integer values of mission durations
a) To track mission durations using the timestamp data type
What is the primary purpose of the astronaut_missions
table?
a) To store duplicate mission data
b) To create a bridge table for many-to-many relationships
c) To hold all data about astronauts
d) To store primary keys for both tables
b) To create a bridge table for many-to-many relationships
What is the first normal form (1NF) in database normalization?
a) Eliminating redundant data
b) Eliminating partial dependencies
c) Ensuring schema is in 3NF
d) Adding foreign key constraints
a) Eliminating redundant data
What is one benefit of storing university data in its own table?
a) It increases the size of the database
b) It reduces redundancy and errors
c) It simplifies the astronaut data
d) It creates duplicate data
b) It reduces redundancy and errors
Which SQL keyword is used to combine rows from two or more tables based on a related column?
a) SELECT
b) JOIN
c) UNION
d) INTERSECT
b) JOIN
What is the result of a SELECT query without a WHERE clause on a large database?
a) Improved query performance
b) Unrestricted retrieval of all data
c) Data filtering based on conditions
d) Reduced query execution time
b) Unrestricted retrieval of all data
Why is it important to use a WHERE clause in SQL queries?
a) To improve JOIN syntax
b) To specify the output table
c) To restrict the amount of data returned
d) To eliminate foreign keys
c) To restrict the amount of data returned
In SQL, what does the LIMIT clause do?
a) Limits the number of database connections
b) Restricts the number of rows returned in a result set
c) Filters rows based on conditions
d) Specifies the columns to be displayed
b) Restricts the number of rows returned in a result set
What is the function of an alias in SQL queries?
a) To delete duplicate rows
b) To rename tables or columns for easier referencing
c) To enforce primary key constraints
d) To modify the database schema
b) To rename tables or columns for easier referencing
What kind of key is used in the astronauts
table for name
?
a) Surrogate key
b) Natural key
c) Foreign key
d) Composite key
b) Natural key
What would happen if a row in the astronauts
table references a non-existent university_id in the university
table?
a) The row would be added without error
b) An error would occur due to foreign key constraints
c) The data would be ignored
d) The university_id would be updated automatically
b) An error would occur due to foreign key constraints
What does the INNER JOIN
keyword do in a SQL query?
a) Returns all rows from both tables
b) Returns rows where there is a match in both tables
c) Returns only unique rows from a table
d) Returns rows from one table only
b) Returns rows where there is a match in both tables
Which column type is best for storing precise date and time information?
a) VARCHAR
b) TIMESTAMP
c) INT
d) DATE
b) TIMESTAMP