Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2004 ECE569 Lecture 04.1 ECE 569 Database System Engineering Fall 2004 Yanyong Zhang www.ece.rutgers.edu/~yyzhangwww.ece.rutgers.edu/~yyzhang Course.

Similar presentations


Presentation on theme: "Fall 2004 ECE569 Lecture 04.1 ECE 569 Database System Engineering Fall 2004 Yanyong Zhang www.ece.rutgers.edu/~yyzhangwww.ece.rutgers.edu/~yyzhang Course."— Presentation transcript:

1 Fall 2004 ECE569 Lecture 04.1 ECE 569 Database System Engineering Fall 2004 Yanyong Zhang www.ece.rutgers.edu/~yyzhangwww.ece.rutgers.edu/~yyzhang Course URL www.ece.rutgers.edu/~yyzhang/fall04www.ece.rutgers.edu/~yyzhang/fall04

2 Fall 2004 ECE569 Lecture 04.2 File Organization  File organization is a method of arranging the records in a file when the file is stored on disk. l Each file organization makes certain operations efficient but other operations expensive eg. employee(name, age, salary) -Retrieve employee records in order of increasing age -Retrieve all the employees who make more than $5000 -Sometimes, inserts are more important than retrieval l heap files: unordered file

3 Fall 2004 ECE569 Lecture 04.3 Different File Organizations File Unstructured (System Sequenced) Structure d Associative Non- Associative Key- sequenced HashEntry Sequenced Relative heap

4 Fall 2004 ECE569 Lecture 04.4 Heap file implementation I: linked list  Maintain a heap file as a doubly linked list of pages  The DBMS can remember where the first page is located by maintaining a table containing pairs of in a known location on disk. The first page is called header page. header page free page data page

5 Fall 2004 ECE569 Lecture 04.5 Heap file implementation II: page directory  Maintain a directory of pages  The DBMS can remember where the first directory page of each heap file is located. The directory is itself a collection of pages and is shown as a linked list below data page

6 Fall 2004 ECE569 Lecture 04.6 File operations  Create a file  Destroy a file  Insert a tuple  Delete a tuple  Search a tuple  Different file organizations have different implementations

7 Fall 2004 ECE569 Lecture 04.7 System-sequenced files  The tuple-oriented file system has complete control over where the tuples are stored.  Additional information such as insert order is not maintained.  Tuples are inserted wherever the free space administration points.  Space freed by deleted tuples can be reclaimed either directly or after reorganization.

8 Fall 2004 ECE569 Lecture 04.8 System-sequenced files operations  insert. The place for a new tuple is determined by the tuple-oriented space allocation.  update. If the tuple length changes: l The tuple stays in its old page l The tuple must be moved to another page, but it has to be completely removed from its current page.  delete.

9 Fall 2004 ECE569 Lecture 04.9 Entry-sequenced files  Tuples are appended to the file.  A sequential file that reflects the order in which the tuples arrived.  e.g., log files

10 Fall 2004 ECE569 Lecture 04.10 Entry-sequenced files operations  insert l Free space is handled by a free space cursor, which at any instant is the end-of-file pointer. l If the last page cannot accommodate the tuple, a new empty page is claimed.  update. An update cannot increase the tuple size.  Delete. Free space cannot be reclaimed.

11 Fall 2004 ECE569 Lecture 04.11 Relative Files  Relative files are arrays of tuples.  The file is pre-formatted l Contiguous page allocation l Fixed size tuples. header empty slot 6283

12 Fall 2004 ECE569 Lecture 04.12 Relative files operations  insert. insert at, insert near, insert at end, insert anywhere  update. Tuples can be updated arbitrarily as long as the resulting length is smaller than the maximum size.  delete. The directory entry pertaining to the slot to be set to 0.

13 Fall 2004 ECE569 Lecture 04.13 Key-Sequenced and Hash Files  Associative access is characterized by the mapping: tuple.attribute value(s) -> location in file.  Implies a mapping from attribute value(s) to the TID.  Fast access to each tuple.


Download ppt "Fall 2004 ECE569 Lecture 04.1 ECE 569 Database System Engineering Fall 2004 Yanyong Zhang www.ece.rutgers.edu/~yyzhangwww.ece.rutgers.edu/~yyzhang Course."

Similar presentations


Ads by Google