Download presentation
Presentation is loading. Please wait.
1
Data Structures and Database Applications Implementing a Database with a Linked Lists
2
Database Linked List Representation
Internally, a linked list can also use a separate header node, which can store the amount of nodes (count) and references to both the front and rear of the list:
3
LinkedList Database Implementation
To create an efficient Database implementation of a Linked List using Next and Prev pointers and Header fields for the size of the list, and the first and last elements of the list, you need to create the following 4 tables: The first table, the Entries Table, stores the ID of an entry, the ID’s of the Next and Prev entries, and other fields with Entity data being stored by the entry. The second and third tables store the ID of the front and the rear of the list of entries, respectively. The fourth table just stores the number of entries.
4
LinkedList Database Implementation
The first table, the Entries Table, has three fields storing the ID, Next and Prev fields, as well as any other fields needed for the Entry being stored. For instance, the Entry in the following is storing a Name, a Phone and an , along with the three required fields:
5
LinkedList Database Implementation
The other three tables are the Fronts Table, the Rears Table and the Sizes Table, which store the Front and Rear IDs and the list’s size, respectively:
6
LinkedList Database Implementation
When these four tables are bound to Entity models, the different entity names – db, db2, db3, db4 – are set to access them like so:
7
LinkedList Database Implementation
Using db, the following method gets an Entry from the table using a given ID:
8
LinkedList Database Implementation
Similarly, the following methods get the next Entry or the previous Entry using a given ID:
9
LinkedList Database Implementation
Using db2, the following methods get the Front ID and Front entry in the Linked List:
10
LinkedList Database Implementation
And the following method sets the Front ID:
11
LinkedList Database Implementation
Similarly, using db3, the following methods get the Rear ID and Rear entry in the Linked List:
12
LinkedList Database Implementation
And the following method sets the Rear ID:
13
LinkedList Database Implementation
And, using db4, the following method gets the size of the Linked List:
14
LinkedList Database Implementation
And the following method sets the size of the Linked List:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.