Q1
True / FalseIn MySQL, an ERD (Entity-Relationship Diagram) is used to visually represent the relationships between different tables in a database.
An ERD helps to understand the structure of a MySQL database by illustrating tables and the relationships between them.
Q2
True / FalseIn MySQL, an ERD can be used to generate SQL statements to create database tables and relationships.
Many database design tools allow you to generate SQL scripts from an ERD to create tables and relationships in MySQL.
Q3
True / FalseIn MySQL, an ERD cannot include attributes that are not directly stored in the database tables.
ERDs can include derived attributes that are calculated from other attributes, though they are not directly stored in MySQL tables.
Q4
True / FalseIn 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.
Foreign key constraints enforce referential integrity between tables in MySQL.
Q5
True / FalseIn MySQL, a primary key in an ERD can have multiple columns.
A primary key in MySQL can be a composite key, which consists of multiple columns.
Q6
True / FalseIn 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.
Unique key constraints ensure that all values in the specified columns are unique in MySQL.
Q7
True / FalseIn MySQL, an ERD can be directly modified using DML (Data Manipulation Language) statements.
ERDs are not directly modified using DML statements; they are conceptual models. DML is used to manipulate data in the database tables, not the ERD itself.
Q8
True / FalseIn MySQL, a one-to-many relationship in an ERD is implemented using a join table.
A one-to-many relationship in MySQL is typically implemented using a foreign key in the table on the "many" side that references the primary key on the "one" side. Join tables are used for many-to-many relationships.
Q9
True / FalseIn MySQL, an ERD can include supertype and subtype relationships to represent inheritance in database tables.
ERDs can model supertype and subtype relationships, where a supertype can have one or more subtypes, and this can be implemented in MySQL using separate tables for the supertype and subtypes.
Q10
True / FalseIn MySQL, an ERD must always represent all possible relationships and constraints present in the database schema.
While an ERD aims to represent the database schema accurately, it may not always capture every detail or constraint, especially in complex schemas or during the early stages of design.
Q21
Multiple ChoiceIdentify 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
);
This SQL statement creates a table for the customers entity, including an auto-incrementing primary key, a unique email field, and a timestamp for when each record was created.
Q22
Multiple ChoiceChoose 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)
);
This SQL statement creates an orders table with a foreign key that references the id column in the customers table, establishing a relationship between the two entities.
Q23
Multiple ChoiceDetermine 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)
);
This SQL statement creates a junction table named order_products to represent the many-to-many relationship between orders and products. It includes foreign keys that reference the orders and products tables.
Q24
Multiple ChoiceWhich 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)
);
This SQL statement creates a student_courses table with a composite primary key consisting of student_id and course_id, representing a many-to-many relationship between students and courses.
Q26
Multiple ChoiceDetermine 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)
);
This SQL statement creates an employees table where the manager_id column is a self-referencing foreign key, establishing a relationship within the same entity to represent hierarchical data.
Q28
Multiple ChoiceIdentify 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)
);
This SQL statement creates a products table with a CHECK constraint on the price column, ensuring that the price is always greater than zero.
Q29
Multiple ChoiceDetermine 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
);
This SQL statement creates an accounts table where the balance column has a default value of 0.00, ensuring that new accounts start with a zero balance unless otherwise specified.
Q30
Multiple ChoiceWhich 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
);
This SQL statement creates a users table with a UNIQUE constraint on the email column, ensuring that no two users can have the same email address.