programming
beginner
10 sample questions
Data Modeling MCQ Practice Test
Creating abstract models that define data structures, relationships, and rules.
Q1. In a database schema, what is the primary difference between a "table" and a "view"?
-
A. A table is a physical storage location for data, while a view is a virtual table based on the result of a query. ✓
-
B. A table is a virtual table based on the result of a query, while a view is a physical storage location for data.
-
C. Both tables and views are physical storage locations for data.
-
D. Both tables and views are virtual tables based on the result of a query.
Explanation: In a database schema, a table is a physical storage location for data, whereas a view is a virtual table that is based on the result of a query. This means that when data is retrieved from a view, it is not stored in a physical location, but rather generated on the fly from the underlying data sources.
Q2. In a database, what is the primary function of a candidate key in a table?
-
A. To ensure data consistency and integrity by uniquely identifying each row ✓
-
B. To improve query performance by reducing the number of joins required
-
C. To increase storage capacity by allowing duplicate values in the primary key
-
D. To enforce referential integrity by linking tables through a common column
Explanation: A candidate key is a set of attributes in a table that uniquely identifies each row. It is the primary function of a candidate key to ensure data consistency and integrity by preventing duplicate rows and ensuring that each row can be uniquely identified.
Q3. In a database with multiple inheritance, what is the purpose of the "discriminator column" in a class table inheritance (CTI) schema?
-
A. It stores the primary key of the parent table
-
B. It stores the foreign key of the child table
-
C. It distinguishes between different classes of a single table ✓
-
D. It stores the result of a complex SQL query
Explanation: In a class table inheritance (CTI) schema, the discriminator column is used to distinguish between different classes of a single table. It is a column that contains a value that indicates which class a row belongs to. This allows for the storage of multiple classes in a single table, while still maintaining the benefits of a relational database.
Q4. In a database schema, what is the primary difference between a Weak Entity and a Strong Entity?
-
A. It has a composite primary key.
-
B. It has an independent existence.
-
C. It relies on another entity for its existence. ✓
-
D. It has a one-to-one relationship with another entity.
Explanation: A Weak Entity is one that cannot exist independently and relies on another entity for its existence, whereas a Strong Entity can exist independently and has its own primary key.
Q5. In a database schema, what is the main purpose of a nullability constraint on a column?
-
A. To ensure data integrity by enforcing a default value for missing data
-
B. To restrict data entry to only a specific set of values
-
C. To indicate that a value is unknown or inapplicable ✓
-
D. To optimize query performance by indexing the column
Explanation: A nullability constraint specifies whether a column can contain null values. In many cases, null values indicate that a value is unknown or inapplicable, rather than missing.
Q6. A database designer wants to create a table to store information about books in a library. Which of the following data types is most suitable for storing the book's title?
-
A. A variable-length string to allow for titles with varying lengths ✓
-
B. A fixed-length string to ensure all titles have the same number of characters
-
C. An integer to store a unique identifier for the book
-
D. A date to store the publication date of the book
Explanation: In a database, the title of a book can have any length, so a variable-length string data type is the most suitable choice. This allows for titles such as "The Great Gatsby" or "The Lord of the Rings" to be stored without truncation.
Q7. A database designer wants to model a many-to-many relationship between "Books" and "Authors". However, the designer wants to store additional information about the relationship, such as the publication year. Which data modeling approach would be most suitable?
-
A. Create a separate table with foreign keys to both "Books" and "Authors", and add a column for the publication year. ✓
-
B. Create a bridge table with foreign keys to both "Books" and "Authors", and add a column for the publication year in the "Books" table.
-
C. Create a composite key in the "Books" table that combines the book ID and author ID, and add a column for the publication year.
-
D. Create a separate table for the publication year and use triggers to update the table whenever a new book-author relationship is added.
Explanation: This approach is suitable because it allows for the storage of additional information about the many-to-many relationship, while also maintaining data normalization and avoiding data redundancy.
Q8. In a database schema, a relationship between two entities can be represented using a "bridge table" when one entity has a many-to-many relationship with another entity. Which of the following best describes the purpose of the bridge table?
-
A. To establish a one-to-one relationship between the two entities
-
B. To create a hierarchical structure by enforcing a parent-child relationship
-
C. To resolve the many-to-many relationship by introducing a third entity with foreign keys to both original entities ✓
-
D. To normalize the schema by eliminating redundant data
Explanation: A bridge table, also known as a junction table, is used to resolve many-to-many relationships between two entities. It contains foreign keys to both entities, effectively creating a new entity that acts as a bridge between the two.
Q9. In a database schema, what is the primary purpose of a "bridge table" in a many-to-many relationship?
-
A. to reduce data redundancy
-
B. to increase data redundancy
-
C. to resolve the many-to-many relationship between two tables ✓
-
D. to simplify the database schema
Explanation: A bridge table, also known as a junction table, is used to resolve many-to-many relationships between two tables by creating a new table that contains foreign keys to both tables involved in the relationship.
Q10. In a database schema, what is the primary difference between a many-to-many relationship and a self-referential relationship?
-
A. Many-to-many relationships involve two separate tables, while self-referential relationships involve a single table with a foreign key referencing the same table. ✓
-
B. Self-referential relationships always involve a composite primary key, whereas many-to-many relationships do not.
-
C. Many-to-many relationships are typically represented using a junction table, whereas self-referential relationships use a single table.
-
D. Self-referential relationships are used to represent hierarchical data, whereas many-to-many relationships are used to represent non-hierarchical data.
Explanation: In a many-to-many relationship, two separate tables are used to establish the relationship between them. On the other hand, a self-referential relationship involves a single table with a foreign key referencing the same table, allowing the table to represent a hierarchical or tree-like structure.
That was just a sample. Sign up to unlock the full question bank with timed tests and certificates.
Sign Up Free