DataRepresenting_by_YueLu102

Download Report

Transcript DataRepresenting_by_YueLu102

Chapter 12
Representing Data Elements
By Yue Lu
CS257 Spring 2008
Instructor: Dr.Lin
Contents

Data Elements and Fields
– Representing Relational Database
Elements
– Representing Objects
– Representing Data Elements

Records
– Building Fixed-Length Records
– Record Headers
– Packing Fixed-Length Records into Blocks
Contents

Data Elements and Fields
– Representing Relational Database
Elements
– Representing Objects
– Representing Data Elements

Records
– Building Fixed-Length Records
– Record Headers
– Packing Fixed-Length Records into Blocks
Data Elements and Fields

Representing Relational Database Elements
– Consider the MovieStar relation below declared
in SQL
CREATE TABLE MovieStar (
name CHAR(30) PRIMARY KEY,
address VARCHAR(255),
gender CHAR(1),
birthdate DATE
);
– DBMS has to represent and store the relation
Data Elements and Fields

Issues in representing relational DB
elements
– How to represent SQL datatypes as fields
– How to represent tuples as records
– How to represent collections or records in blocks
of memory
– How to represent and store relations as
collections of blocks
– How to cope with record sizes
– What if the size of a record changes due to
updating
Contents

Data Elements and Fields
– Representing Relational Database
Elements
– Representing Objects
– Representing Data Elements

Records
– Building Fixed-Length Records
– Record Headers
– Packing Fixed-Length Records into Blocks
Data Elements and Fields

Representing Objects
– Objects can have methods or specialpurpose functions associated with them
– Objects may have an object
identifier(OID), which is an address that
refers uniquely to that object
Contents

Data Elements and Fields
– Representing Relational Database
Elements
– Representing Objects
– Representing Data Elements

Records
– Building Fixed-Length Records
– Record Headers
– Packing Fixed-Length Records into Blocks
Data Elements and Fields
Data Elements and Fields

Representing Data Elements
– Fixed-Length Character Strings
 CHAR(n): n bytes
– Pad characters are used if the actual value
is shorter than n
– Variable-Length Character Strings
 VARCHAR(n): n+1 bytes
– Length plus content: # of bytes in the
string + characters of the string
– Null-terminated string: characters of the
string + “null” character
Data Elements and Fields

Representing Data Elements (con.)
– Dates and Times
 Date: 10 bytes (YYYY-MM-DD)
 Time: 8 bytes (HH:MM:SS)
– May need more bytes to include fraction
of a second
– Bits
– Enumerated Types
Contents

Data Elements and Fields
– Representing Relational Database
Elements
– Representing Objects
– Representing Data Elements

Records
– Building Fixed-Length Records
– Record Headers
– Packing Fixed-Length Records into Blocks
Records

Building Fixed-Length Records
– All the fields of the record have a fixed
length
– E.g. A MovieStar record
Records

Building Fixed-Length Records
– Sometimes, it is more efficient to align
fields starting at a multiple of 4
Contents

Data Elements and Fields
– Representing Relational Database
Elements
– Representing Objects
– Representing Data Elements

Records
– Building Fixed-Length Records
– Record Headers
– Packing Fixed-Length Records into Blocks
Records

Record Headers
– Pointer to the record schema
– Length of the record
– Timestamp
Contents

Data Elements and Fields
– Representing Relational Database
Elements
– Representing Objects
– Representing Data Elements

Records
– Building Fixed-Length Records
– Record Headers
– Packing Fixed-Length Records into Blocks
Records

Packing Fixed-Length Records into
Blocks
Records

Header
– Links to other blocks
– Information about the role played by this block
in such a network
– Information about which relation the tuples of
this block belong to
– Directory giving the offset of each record in the
block
– Block ID
– Timestamp
References




Database Systems The Complete Book by Hector GarciaMolina, Jeffrey D.Ullman and Jennifer Widom Fundamentals of
Principles of Database Systems with Internet and Java
Applications by Greg Riccardi
Database Systems by Elmasri Navathe
http://dbserver.kaist.ac.kr/~mhkim/cs56007spring.dir/chap3.pdf