Computer Science – 13.2 File organisation and access | e-Consult
13.2 File organisation and access (1 questions)
Login to see all questions.
Click on a question to view the answer
B+Tree File Organisation: B+Tree file organisation is the most suitable method for this inventory system. It offers an excellent balance between efficient retrieval of items by item code and efficient retrieval of items based on a range of quantities.
- Item Code (Primary Key): The item code should be used as the primary key for the B+Tree. This allows for very fast retrieval of a specific item using a binary search on the tree.
- Data in Leaf Nodes: The actual inventory data (description, quantity, price) should be stored in the leaf nodes of the B+Tree. This avoids the need for extra disk accesses to retrieve the data associated with an item code.
- Range Queries (Quantity < Threshold): B+Trees are highly efficient for range queries. By traversing the tree from the root to the leaf nodes, the system can quickly identify all items with quantities below the specified threshold. The leaf nodes are linked together in a sorted order, which facilitates this range traversal.
- Trade-offs: B+Tree organisation requires more storage space than some other methods (e.g., sequential file organisation) due to the overhead of the tree structure. However, the improved retrieval performance generally outweighs this cost. Maintaining the B+Tree requires some overhead during insertions and deletions, but this is typically managed efficiently.
Alternative Methods and Why They Are Less Suitable:
- Sequential File Organisation: Would be extremely inefficient for retrieving items by item code. The entire file would need to be scanned sequentially.
- Hash File Organisation: While fast for retrieval by item code, hash file organisation is not suitable for range queries. It would be difficult to efficiently find all items with quantities below a certain threshold.