Presentation is loading. Please wait.

Presentation is loading. Please wait.

13.5 Representing Data Elements Fields, Records, Blocks Variable-length Data Modifying Records.

Similar presentations


Presentation on theme: "13.5 Representing Data Elements Fields, Records, Blocks Variable-length Data Modifying Records."— Presentation transcript:

1 13.5 Representing Data Elements Fields, Records, Blocks Variable-length Data Modifying Records

2 Overview Attributes are represented by sequences of bytes, called fields Tuples are represented by collections of fields, called records Relations are represented by collections of records, called files Files are stored in blocks, using specialized data structures to support efficient modification and querying

3 Representing SQL Data Types integers and reals: built-in CHAR(n): array of n bytes VARCHAR(n): array of n+1 bytes (extra byte is either string length or null char) dates and times: fixed length strings

4 Representing Tuples For now, assume all attributes (fields) are fixed length. Concatenate the fields Store the offset of each field in schema 0 30286287297 name CHAR(30) 30 bytes address VARCHAR(255) 256 bytes gender CHAR(1) 1 byte birthdate DATE 10 bytes

5 More on Tuples Due to hardware considerations, certain types of data need to start at addresses that are multiples of 4 or 8 Previous example becomes: 0 32288292304 name CHAR(30) 30 bytes + 2 address VARCHAR(255) 256 bytes gender CHAR(1) 1 byte + 3 birthdate DATE 10 bytes + 2

6 Record Headers Often it is convenient to keep some "header" information in each record: –a pointer to schema information (attributes/fields, types, their order in the tuple, constraints) –length of the record/tuple –timestamp of last modification

7 Packing Records into Blocks Start with block header: –timestamp of last modification/access –offset of each record in the block, etc. Follow with sequence of records May end with some unused space header record 1record 2 … record n-1record n


Download ppt "13.5 Representing Data Elements Fields, Records, Blocks Variable-length Data Modifying Records."

Similar presentations


Ads by Google