MySQL Database Quiz Questions

Course Name:MySQL
Chapter Name:Chapter 8 - RDBMS Concepts
Lesson Content Link:ERD (Data Model)
Current Quiz Count:30
Progress
0%
Q1
True / False

In MySQL, an ERD (Entity-Relationship Diagram) is used to visually represent the relationships between different tables in a database.

Q2
True / False

In MySQL, an ERD can be used to generate SQL statements to create database tables and relationships.

Q3
True / False

In MySQL, an ERD cannot include attributes that are not directly stored in the database tables.

Q4
True / False

In MySQL, a foreign key constraint in an ERD ensures that the values in a column or group of columns match the values in a primary key column in another table.

Q5
True / False

In MySQL, a primary key in an ERD can have multiple columns.

Q6
True / False

In MySQL, a unique key constraint in an ERD indicates that the values in the constrained columns must be distinct across all rows in the table.

Q7
True / False

In MySQL, an ERD can be directly modified using DML (Data Manipulation Language) statements.

Q8
True / False

In MySQL, a one-to-many relationship in an ERD is implemented using a join table.

Q9
True / False

In MySQL, an ERD can include supertype and subtype relationships to represent inheritance in database tables.

Q10
True / False

In MySQL, an ERD must always represent all possible relationships and constraints present in the database schema.

Q11
Single Choice

Which of the following is a primary purpose of an Entity-Relationship Diagram (ERD) in MySQL?

Q12
Single Choice

In an ERD, what does a rectangle symbolize?

Q13
Single Choice

What is the significance of a foreign key in a MySQL ERD?

Q14
Single Choice

In MySQL, what does a diamond shape in an ERD represent?

Q15
Single Choice

Which type of relationship in an ERD indicates that one entity can be associated with multiple instances of another entity in MySQL?

Q16
Single Choice

What is a composite key in the context of a MySQL ERD?

Q17
Single Choice

In a MySQL ERD, which notation is typically used to represent cardinality constraints?

Q18
Single Choice

Which of the following best describes a weak entity in a MySQL ERD?

Q19
Single Choice

In MySQL, what is the purpose of a bridge table in an ERD?

Q20
Single Choice

Which MySQL feature can automatically create an ERD for an existing database schema?

Q21
Multiple Choice

Identify the correct SQL statement to create a table for an entity in an ERD representing customers.

SQL Code
CREATE TABLE customers (
 id INT AUTO_INCREMENT PRIMARY KEY,
 name VARCHAR(100) NOT NULL,
 email VARCHAR(100) UNIQUE,
 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Q22
Multiple Choice

Choose the correct SQL statement to establish a foreign key relationship in an ERD between orders and customers.

SQL Code
CREATE TABLE orders (
 id INT AUTO_INCREMENT PRIMARY KEY,
 customer_id INT,
 order_date DATE,
 FOREIGN KEY (customer_id) REFERENCES customers(id)
);
Q23
Multiple Choice

Determine the correct SQL statement to represent a many-to-many relationship in an ERD using a junction table.

SQL Code
CREATE TABLE order_products (
 order_id INT,
 product_id INT,
 quantity INT,
 PRIMARY KEY (order_id, product_id),
 FOREIGN KEY (order_id) REFERENCES orders(id),
 FOREIGN KEY (product_id) REFERENCES products(id)
);
Q24
Multiple Choice

Which SQL statement correctly creates an entity with a composite primary key in an ERD?

SQL Code
CREATE TABLE student_courses (
 student_id INT,
 course_id INT,
 enrollment_date DATE,
 PRIMARY KEY (student_id, course_id)
);
Q25
Multiple Choice

Select the correct SQL statement to add a new column to an existing table that represents an attribute in an ERD.

SQL Code
ALTER TABLE customers
ADD COLUMN phone_number VARCHAR(15);
Q26
Multiple Choice

Determine the correct SQL statement to create an entity with a self-referencing foreign key in an ERD.

SQL Code
CREATE TABLE employees (
 id INT AUTO_INCREMENT PRIMARY KEY,
 name VARCHAR(100) NOT NULL,
 manager_id INT,
 FOREIGN KEY (manager_id) REFERENCES employees(id)
);
Q27
Multiple Choice

Which SQL statement correctly modifies an existing table to enforce a NOT NULL constraint on a column?

SQL Code
ALTER TABLE orders
MODIFY COLUMN order_date DATE NOT NULL;
Q28
Multiple Choice

Identify the correct SQL statement to create a table with a CHECK constraint in an ERD to validate an attribute.

SQL Code
CREATE TABLE products (
 id INT AUTO_INCREMENT PRIMARY KEY,
 product_name VARCHAR(100) NOT NULL,
 price DECIMAL(10,2) CHECK (price > 0)
);
Q29
Multiple Choice

Determine the correct SQL statement to create a table with a default value for an attribute in an ERD.

SQL Code
CREATE TABLE accounts (
 id INT AUTO_INCREMENT PRIMARY KEY,
 account_name VARCHAR(100) NOT NULL,
 balance DECIMAL(10,2) DEFAULT 0.00
);
Q30
Multiple Choice

Which SQL statement correctly creates a table with a UNIQUE constraint to enforce an attribute's uniqueness in an ERD?

SQL Code
CREATE TABLE users (
 id INT AUTO_INCREMENT PRIMARY KEY,
 username VARCHAR(50) NOT NULL,
 email VARCHAR(100) UNIQUE
);