Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 12.2: Records Kristen Mori CS 257 – Spring 2008 2/4/2008.

Similar presentations


Presentation on theme: "Chapter 12.2: Records Kristen Mori CS 257 – Spring 2008 2/4/2008."— Presentation transcript:

1 Chapter 12.2: Records Kristen Mori CS 257 – Spring 2008 2/4/2008

2 Terminology Data ElementRecordCollection Filesfieldrecordfile Cfieldstructarray, file SQLattributetuplerelation OQL attribute, relationship objectclass

3 Record A record is a collection of fields, or attributes  E.g. Employee record: name field, salary field, date-of-hire field,... Types of records:  FIXED vs VARIABLE FORMAT  FIXED vs VARIABLE LENGTH

4 Schema Each relation must have a schema Schema includes:  field name  data type of each field  offset within the record The schema is necessary to access components of a record

5 Fixed-Length Records All fields have fixed-length Concatenate fields to form record E.g.: Declaration of MovieStar relation CREATE TABLE MovieStar( name CHAR(30), address VARCHAR(255), gender CHAR(1), birthdate DATE);

6 Increase Efficiency Some machines increase efficiency of reading and writing data, if the data begins at a byte whose address is a multiple of 4 Certain datatypes have strict requirements  Integers begin at an address that is multiple of 4  Double-precision reals begin with a multiple of 8

7 Increase Efficiency Blocks read from disk to main memory (MM) are placed at an address that is a power of 2 If certain fields must have a MM address that is a multiple of 4 or 8, then the fields within the block must have an offset that has the same divisor

8 Offset Example The tuples of the MovieStar relation need to be represented so each field starts at a byte that is a multiple of 4 Each record consumes 304 bytes name 30 bytes address 256 bytes gender 1 byte birthdate 10 bytes 0 32288 292304

9 Record Headers Record headers store additional information about a record  pointer to the schema  length of the record  timestamp indicating the time the record was last modified or last read name 30 bytes address 256 bytes gender 1 byte birthdate 10 bytes 12 44300 304316 0 to schema length timestamp

10 Packing Fixed-Length Records into Blocks There is an optional block header that stores information such as:  Links to other blocks  Information about which relation the tuples belong to  A “directory” giving the offset of each record  A “block ID”  Timestamp headerrecord 1record 2…record n

11 Block Example Suppose we have fixed-length records of 316 bytes and we use 4096-byte blocks Assume a 12 byte block header, therefore we have 4084 bytes for data In this space we can fit 12 records, each 316 bytes long (12 * 316 = 3792) 292 bytes of unused space


Download ppt "Chapter 12.2: Records Kristen Mori CS 257 – Spring 2008 2/4/2008."

Similar presentations


Ads by Google