In collection semantics used with object databases and OQL, which structure is an unordered collection that may contain duplicate elements? Pick the most accurate term.

Difficulty: Easy

Correct Answer: Bag

Explanation:


Introduction / Context:
Understanding collection semantics is essential when modeling associations and query results. Different collection types offer different guarantees about order and uniqueness, which affect both correctness and performance in queries and methods.



Given Data / Assumptions:

  • Unordered vs. ordered distinctions matter.
  • Allowance of duplicates is the deciding characteristic here.
  • Standard types: set, bag (multiset), list, dictionary (map).


Concept / Approach:

A bag (multiset) is unordered and allows duplicates. A set is unordered and forbids duplicates. A list preserves order and allows duplicates. A dictionary (map) stores key–value pairs with unique keys rather than allowing duplicate elements freely.



Step-by-Step Solution:

Check “unordered” → narrows to set or bag.Check “may contain duplicates” → eliminates set; bag qualifies.Answer: Bag.


Verification / Alternative check:

OQL/ODMG documentation and many programming languages’ collection libraries (e.g., multiset) match the same definitions.



Why Other Options Are Wrong:

Set: no duplicates allowed.

List: ordered sequence.

Dictionary: keyed collection; duplicates governed by keys, not elements.



Common Pitfalls:

Assuming list-without-sorting is “unordered”; lists still maintain insertion/positional order. Confusing bag with set.



Final Answer:

Bag

More Questions from Object-Oriented Database

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion