A payment may be applied to several invoices, and an invoice may be settled through several payments. The PaymentApplication table contains PaymentID, InvoiceID, and AmountApplied. Which database constraint would best prevent the same payment from being applied twice to the same invoice while permitting both types of multiple relationships?
Answer: A. A unique composite constraint on PaymentID and InvoiceID
***A unique composite constraint on PaymentID and InvoiceID***
- The **PaymentID–InvoiceID pair** identifies one application, so a duplicate pair cannot record the same payment against the same invoice twice.
- Either ID can still appear in multiple rows when paired with different IDs, permitting payments across invoices and multiple payments toward an invoice.
*A unique constraint on PaymentID only*
- Requiring **PaymentID** to be unique would prevent one payment from being applied to several invoices.
- It would block valid applications even when their InvoiceID values differ.
*A unique constraint on InvoiceID only*
- Requiring **InvoiceID** to be unique would prevent an invoice from being settled through several payments.
- It would block valid applications even when their PaymentID values differ.
*A unique constraint on AmountApplied only*
- **AmountApplied** is an amount, not an identifier for a payment–invoice relationship, so its uniqueness would not prevent duplicate ID pairs with different amounts.
- It would also reject legitimate applications to different invoices or from different payments that happen to have the same amount.
Explanation locked
Q2Medium
An accounting database stores products in a Product table and historical invoice lines in an InvoiceLine table. Management must retain all invoice lines, prevent them from referring to nonexistent products, and stop users from selecting discontinued products on new invoices. Which design best meets these requirements?
Answer: D. Restrict deletion of referenced products and use an inactive-product flag that invoice entry validates.
***Restrict deletion of referenced products and use an inactive-product flag that invoice entry validates.***
- **Restricting deletion** of referenced products preserves historical InvoiceLine records and prevents their product identifiers from pointing to nonexistent Product records.
- An **inactive-product flag** lets the products remain in the database while invoice entry blocks users from selecting them on new invoices.
*Cascade product deletions to invoice lines and retain an active-status field on each invoice.*
- **Cascading deletion** would erase historical invoice lines when a referenced product is deleted, violating the retention requirement.
- An active-status field on each invoice does not identify which **products** have been discontinued.
*Set product identifiers on invoice lines to null when products are deleted and apply a unique index.*
- Setting product identifiers to **null** would sever historical invoice lines from the products they record.
- A **unique index** does not preserve those relationships or prevent discontinued products from being selected on new invoices.
*Remove the foreign-key constraint and rely on the invoice-entry application to validate product identifiers.*
- Without the **foreign-key constraint**, the database could accept an InvoiceLine that refers to a nonexistent Product through another process.
- Application validation alone does not protect database-level integrity or provide a way to distinguish **discontinued products** during invoice entry.
Explanation locked
Q3Medium
A normalized purchasing database must record that each product may be supplied by several suppliers and each supplier may provide several products. The database must also store the negotiated unit price for each product-supplier combination. Which table design is most appropriate?
Answer: A. A ProductSupplier table keyed by ProductID and SupplierID, with negotiated unit price
***A ProductSupplier table keyed by ProductID and SupplierID, with negotiated unit price***
- The **ProductID–SupplierID** key uniquely identifies each pairing in the many-to-many relationship.
- Negotiated unit price belongs in that table because it depends on the **combination**, not on either product or supplier alone.
*A Product table keyed by ProductID, with one SupplierID and negotiated unit price*
- One SupplierID per product cannot represent a product supplied by **several suppliers**.
- The price could differ by supplier, so storing it on the Product row would not represent each negotiated pairing.
*A Supplier table keyed by SupplierID, with one ProductID and negotiated unit price*
- One ProductID per supplier cannot represent a supplier providing **several products**.
- The price could differ by product, so storing it on the Supplier row would not represent each negotiated pairing.
*A PurchaseOrder table keyed by PurchaseOrderID, with the current negotiated unit price*
- **PurchaseOrderID** identifies a transaction, not a unique product-supplier pairing.
- A purchase order may record a transaction price, but it is not the appropriate table for maintaining the negotiated price for **each pairing**.
Explanation locked
Q4Medium
An employee training table stores EmployeeID, CourseID, CourseTitle, CourseInstructor, CompletionDate, and Score. A course's instructor name therefore appears on hundreds of training rows, and recent updates changed only some of those rows. Which redesign would best prevent this update anomaly while preserving the relationship between courses and training records?
Answer: A. Store course attributes once in a Course table and retain CourseID as a foreign key in Training
***Store course attributes once in a Course table and retain CourseID as a foreign key in Training***
- CourseTitle and CourseInstructor depend on **CourseID**, so storing them once in Course prevents inconsistent updates across hundreds of training rows.
- Keeping CourseID as a **foreign key** in Training preserves the link between each training record and its course.
*Move CourseInstructor to each training-detail row and retain CourseID in both training tables*
- Putting CourseInstructor on each training-detail row **repeats** the value rather than storing it once per course.
- Retaining CourseID in both training tables does not prevent some instructor names from being updated while others remain unchanged.
*Use EmployeeID and CourseID as a composite primary key while retaining all course attributes*
- A composite key may identify a training row, but CourseInstructor still depends on **CourseID alone**.
- Retaining course attributes on training rows leaves the same instructor name duplicated and vulnerable to inconsistent updates.
*Create a view that returns the maximum instructor name found for each course's training records*
- A view displaying the **maximum** instructor name does not change the conflicting values stored in the training table.
- Choosing one name for reporting does not establish which instructor name is authoritative or prevent future inconsistent updates.
Explanation locked
Q5Medium
An ERP permits each general ledger account to be assigned to several management-reporting categories, and each reporting category may contain several accounts. Which relational design most appropriately represents these assignments without storing repeating category values in the account table?
Answer: A. Create an AccountCategory table with AccountID and CategoryID as a composite primary key and as foreign keys to their respective tables.
***Create an AccountCategory table with AccountID and CategoryID as a composite primary key and as foreign keys to their respective tables.***
- The ERP’s **many-to-many** relationship requires a separate row for each account–category assignment, rather than repeating categories in the Account table.
- The composite primary key prevents duplicate assignments, while the two foreign keys link each row to an existing account and category.
*Add CategoryID to the Account table as its primary key and retain AccountID as a nonkey descriptive attribute.*
- Making **CategoryID** the Account table’s primary key would identify accounts by category, not by AccountID.
- A single CategoryID in an account row also cannot represent that account’s assignments to several categories.
*Add AccountID to the Category table as a single foreign key so each category identifies one participating account.*
- One **AccountID** in each Category row permits that category to reference only one account.
- The stem requires each reporting category to contain several accounts, so this design does not represent the stated relationship.
*Store all applicable CategoryID values in one delimited field within each row of the Account table.*
- A delimited field stores **repeating category values** in one Account column, contrary to the design requirement.
- It also prevents ordinary foreign-key enforcement for each CategoryID and complicates joins and updates to assignments.
Explanation locked
Q6Medium
An entity must be able to determine which approved vendor bank account was in effect when each electronic payment was released. The current vendor table overwrites the prior bank account whenever a change is approved. Which database design best supports this requirement?
Answer: A. Store immutable bank-account history records with effective dates and reference the applicable record from each payment
***Store immutable bank-account history records with effective dates and reference the applicable record from each payment***
- **Effective-dated history** preserves each approved bank account instead of overwriting prior values.
- A payment’s reference to the applicable **immutable record** identifies the approved account in effect when that payment was released.
*Continue overwriting the vendor record and retain monthly copies of the entire vendor table*
- **Monthly copies** can miss bank-account changes approved between snapshots.
- Because the live vendor record still overwrites prior values, a snapshot may not identify the account in effect at a particular payment’s release.
*Store the current bank-account number in each invoice record when the invoice is entered*
- **Invoice entry** may precede a bank-account change approved before payment release.
- The invoice’s stored number therefore does not establish which approved account was in effect when the payment was released.
*Add an index to the bank-account field in the existing vendor master table*
- An **index** speeds access to stored bank-account values but does not retain values the vendor table overwrites.
- Without historical account records, the indexed table cannot establish which approved account was in effect at payment release.
Explanation locked
Q7Medium
A relational accounting database stores an Account table and a JournalEntryLine table whose AccountID field references the Account table. Management wants users to deactivate obsolete accounts while preserving historical journal-entry relationships. Which database design best satisfies this objective?
Answer: B. Add an active-status field and restrict deletion of referenced accounts
***Add an active-status field and restrict deletion of referenced accounts***
- An **active-status field** lets users deactivate obsolete accounts without removing them from the Account table.
- Restricting deletion of referenced accounts preserves the **AccountID relationship** to historical JournalEntryLine records.
*Delete obsolete accounts and set related journal AccountID values to null*
- Setting historical journal lines’ **AccountID to null** severs their link to the accounts used when the entries were recorded.
- Although the lines remain, users can no longer identify their accounts through the database relationship.
*Delete obsolete accounts and cascade the deletion to journal-entry lines*
- **Cascading deletion** removes the JournalEntryLine records that reference each deleted account.
- That destroys historical transaction detail rather than preserving the journal-entry relationships management requires.
*Move obsolete accounts to a spreadsheet and reuse their AccountID values*
- Moving accounts to a spreadsheet takes their records outside the relational database that holds the journal lines.
- Reusing an **AccountID** could make historical entries appear to belong to a different account.
Explanation locked
Q8Hard
An employee-assignment table contains EmployeeID, EmployeeName, ProjectID, ProjectName, and ProjectManager. ProjectName and ProjectManager depend on ProjectID rather than on EmployeeID. If the last employee assigned to a project is removed from the table, all information about that project's name and manager is lost. Which redesign best reduces this deletion-anomaly risk?
Answer: A. Create a project table keyed by ProjectID and retain ProjectID as a foreign key in the employee table.
***Create a project table keyed by ProjectID and retain ProjectID as a foreign key in the employee table.***
- ProjectName and ProjectManager depend on **ProjectID**, so a project table stores those attributes independently of employee assignments.
- Deleting the last employee assigned to a project then leaves its project record, name, and manager intact.
*Create a separate employee-name table keyed by EmployeeName and remove EmployeeID from the employee table.*
- **EmployeeName** is not established as a unique, stable identifier, so it is not a sound replacement for EmployeeID.
- Separating names leaves project information tied to employee rows and does not prevent its loss when the last assignment is deleted.
*Retain one table but add ProjectName and ProjectManager to a composite primary key.*
- Adding project attributes to the **primary key** does not change the fact that they depend on ProjectID.
- Their values would still be lost if the last row for a project were deleted.
*Retain one table and create indexes on ProjectName and ProjectManager.*
- **Indexes** can speed searches but do not store project information independently of employee rows.
- Deleting the last employee assigned to a project would still delete the only remaining record of its name and manager.