Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 12 Representing Data Elements By Yue Lu CS257 Spring 2008 Instructor: Dr.Lin.

Similar presentations


Presentation on theme: "Chapter 12 Representing Data Elements By Yue Lu CS257 Spring 2008 Instructor: Dr.Lin."— Presentation transcript:

1 Chapter 12 Representing Data Elements By Yue Lu CS257 Spring 2008 Instructor: Dr.Lin

2 Contents Data Elements and Fields Data Elements and Fields –Representing Relational Database Elements –Representing Objects –Representing Data Elements Records Records –Building Fixed-Length Records –Record Headers –Packing Fixed-Length Records into Blocks

3 Contents Data Elements and Fields Data Elements and Fields –Representing Relational Database Elements –Representing Objects –Representing Data Elements Records Records –Building Fixed-Length Records –Record Headers –Packing Fixed-Length Records into Blocks

4 Data Elements and Fields Representing Relational Database Elements Representing Relational Database Elements –Consider the MovieStar relation below declared in SQL CREATE TABLE MovieStar ( CREATE TABLE MovieStar ( name CHAR(30) PRIMARY KEY, name CHAR(30) PRIMARY KEY, address VARCHAR(255), gender CHAR(1), birthdate DATE ); –DBMS has to represent and store the relation

5 Data Elements and Fields Issues in representing relational DB elements 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

6 Contents Data Elements and Fields Data Elements and Fields –Representing Relational Database Elements –Representing Objects –Representing Data Elements Records Records –Building Fixed-Length Records –Record Headers –Packing Fixed-Length Records into Blocks

7 Data Elements and Fields Representing Objects Representing Objects –Objects can have methods or special- purpose functions associated with them –Objects may have an object identifier(OID), which is an address that refers uniquely to that object

8 Contents Data Elements and Fields Data Elements and Fields –Representing Relational Database Elements –Representing Objects –Representing Data Elements Records Records –Building Fixed-Length Records –Record Headers –Packing Fixed-Length Records into Blocks

9 Data Elements and Fields

10 Representing Data Elements Representing Data Elements –Fixed-Length Character Strings CHAR(n): n bytes 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 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

11 Data Elements and Fields Representing Data Elements (con.) Representing Data Elements (con.) –Dates and Times Date: 10 bytes (YYYY-MM-DD) Date: 10 bytes (YYYY-MM-DD) Time: 8 bytes (HH:MM:SS) Time: 8 bytes (HH:MM:SS) –May need more bytes to include fraction of a second –Bits –Enumerated Types

12 Contents Data Elements and Fields Data Elements and Fields –Representing Relational Database Elements –Representing Objects –Representing Data Elements Records Records –Building Fixed-Length Records –Record Headers –Packing Fixed-Length Records into Blocks

13 Records Building Fixed-Length Records Building Fixed-Length Records –All the fields of the record have a fixed length –E.g. A MovieStar record

14 Records Building Fixed-Length Records Building Fixed-Length Records –Sometimes, it is more efficient to align fields starting at a multiple of 4

15 Contents Data Elements and Fields Data Elements and Fields –Representing Relational Database Elements –Representing Objects –Representing Data Elements Records Records –Building Fixed-Length Records –Record Headers –Packing Fixed-Length Records into Blocks

16 Records Record Headers Record Headers –Pointer to the record schema –Length of the record –Timestamp

17 Contents Data Elements and Fields Data Elements and Fields –Representing Relational Database Elements –Representing Objects –Representing Data Elements Records Records –Building Fixed-Length Records –Record Headers –Packing Fixed-Length Records into Blocks

18 Records Packing Fixed-Length Records into Blocks Packing Fixed-Length Records into Blocks

19 Records Header 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

20 References Database Systems The Complete Book by Hector Garcia- Molina, Jeffrey D.Ullman and Jennifer Widom Fundamentals of Database Systems The Complete Book by Hector Garcia- Molina, Jeffrey D.Ullman and Jennifer Widom Fundamentals of Principles of Database Systems with Internet and Java Applications by Greg Riccardi Principles of Database Systems with Internet and Java Applications by Greg Riccardi Database Systems by Elmasri Navathe Database Systems by Elmasri Navathe http://dbserver.kaist.ac.kr/~mhkim/cs560- 07spring.dir/chap3.pdf http://dbserver.kaist.ac.kr/~mhkim/cs560- 07spring.dir/chap3.pdf


Download ppt "Chapter 12 Representing Data Elements By Yue Lu CS257 Spring 2008 Instructor: Dr.Lin."

Similar presentations


Ads by Google