Q1
True / FalseA surrogate key in MySQL is an artificial key that is used as a unique identifier for each record in a table.
A surrogate key is indeed an artificial key, often an auto-incrementing integer, that uniquely identifies each record in a table.
Q2
True / FalseSurrogate keys in MySQL can be based on business logic.
Surrogate keys are artificial and not derived from business logic. They are typically auto-incrementing numbers.
Q3
True / FalseA surrogate key in MySQL can be a combination of multiple columns.
A surrogate key is usually a single column with unique, system-generated values, such as an auto-incrementing integer.
Q4
True / FalseIn MySQL, surrogate keys can improve query performance by serving as primary keys.
Surrogate keys, when used as primary keys, can improve query performance by providing a unique, indexed identifier for each row.
Q5
True / FalseA surrogate key in MySQL must always be an integer.
While surrogate keys are commonly integers, they can also be UUIDs or other unique, system-generated values.
Q6
True / FalseSurrogate keys in MySQL are ideal for maintaining relationships between tables in a database.
Surrogate keys are often used to maintain relationships between tables because they are unique and do not change.
Q7
True / FalseUsing a surrogate key in MySQL guarantees that the values will never have gaps (i.e., they will be consecutive).
Surrogate keys, especially auto-incrementing integers, can have gaps if rows are deleted or transactions are rolled back.
Q8
True / FalseSurrogate keys in MySQL eliminate the need for natural keys in database design.
Surrogate keys do not eliminate the need for natural keys; they simply provide a unique identifier. Natural keys are still important for ensuring data integrity and uniqueness based on real-world data.
Q9
True / FalseSurrogate keys in MySQL can be indexed for faster lookups and joins.
Surrogate keys can be indexed, which improves the performance of lookups and joins by providing a fast way to locate rows based on the unique identifier.
Q10
True / FalseIn MySQL, it is possible to create a surrogate key using the AUTO_INCREMENT attribute.
The AUTO_INCREMENT attribute in MySQL is commonly used to create surrogate keys, as it automatically generates a unique integer value for each new record.
Q23
Multiple ChoiceWhich SQL statement demonstrates the use of a surrogate key and a natural key in the same table?
SQL Code
CREATE TABLE orders (
order_id INT AUTO_INCREMENT PRIMARY KEY,
order_number VARCHAR(20) UNIQUE,
customer_id INT
);
In this example, 'order_id' is a surrogate key, while 'order_number' is a natural key. The surrogate key is generated automatically and serves as the primary key, while the natural key uniquely identifies orders.