Business Objects Design
Business Objects Design
Basics:
- A database is a collection of files, file is a collection of records, record (tuple) is a collection of fields
(attributes).
- Files are stored on Disks (that use blocks to read and write).
- Two types of records.
1. Fixed Length Record
2. Variable Length Record.
Two important issues:
1.Representation of each record
2.Grouping/Ordering of records and storage in blocks.
Goal and considerations:
- Compactness
- Overhead of insertion/deletion
Retrieval Speed: Sometime we prefer to bring more records/tuples than necessary in MM(Memory
Management) and use CPU to filter out the unnecessary ones
Fixed Length Record: Example
Account( acc-number char(10), branch-name char(20), balance real)
Each record is 38 bytes.
Store them sequentially, one after the other.
Record 0 at position 0, record 1 at position 38, record 2 at position 76 etc.
Simple approach:
- Store record i starting from byte n * (i – 1), where n is the size of each record.
- Record access is simple, but records may cross blocks
Modification: do not allow records to cross block boundaries
Insertion of record i: Add at the end.
Deletion of record I : Two alternatives:
- move records:
- do not move records but link all free records on a free list.
- Records can be moved around within a page to keep them contiguous with no empty space
between
them; entry in the header must be updated.
- Pointers should not point directly to record — instead they should point to the entry for the record
in
header.
Pointer method:
- A variable-length record is represented by a list of fixed-length records, chained together via pointers.
- Can be used even if the maximum record length is not known.
Solution is to allow two kinds of block in file:
–Anchor block – contains the first records of chain
–Overflow block – contains records other than those that are the first records of chains.