2. Three primary methods:
1.sequential storage
2.creating index table for data
3.direct/hashed key storage
1.sequential storage
Each row is stored in a predefined order.
Uses:
-- data retrieval is always in a fixed order.
--contains a lot of common data.
-- backup for transferring data to a different db.
3. Drawbacks:
1.finding an arbitrary row is much slower.
2.deletion is fast and efficient but the
problem occurs when you want to insert a
new row.
4. 8 SUDHARCHANAN
9 YOKESH
ID NAME
1 AGASH
2 AJITH Insert a new data with the name of
3 HARISH
naresh.
4 MUGESH
5 DINESH
6 MANOJ
7 LOGESH
5. Step1:Read each row.
Step2:Decide if this row comes beforethe
new row,
- - - I f so,store it in a new table.
Step3:Reach the insertion point,save the new
row of data.
Step4:Append the rest of the data to the end
of the new table.
6. To add a row of data,the db has to retrieve
every row in the table.
Operations for inserting a new row into a
table:
Sort the name and insert the new
row(naresh).
Copy the top of the table to a new table.
Store the new data row (10 Naresh).
Copy the rest of the data.
7. ID NAME
1 AGASH
2 AJITH
5 DINESH
3 HARISH
6 MANOJ
4 MUGESH
10 NARESH
7 LOKESH
8
9
SUDHARC
H
YOKESH
ANAN
8. Problems of sequential tables can be solved
by using a indexes.
Use of pointers:
--when data is stored,it is stored atsome
location.
--This location is identified by address.
-- A variable that points to this address is
called a pointer.
--Physical pointers used to provide fast
access to data.
9. Drawbacks:
-- db is tied to a specific disk drive.
--Data must be stored in the same physical
location.
Backup restoring
Move the db to a new drive
10. DATA
KEY VALUE ADDRESS
POINTER
ADDRESS
Data can be stored in
one location.
key value can be
stored in a different
location.
When the db retrieves
the key value,it follows
the pointer to retrieve
the associated data.
11. Faster access to data.
Sorts and stores the key value from the
original table along with a pointer to the rest
of the data in each row.
USES:
--Fast random and sequential accessto
tables.
-- DB system can search the index and use
the pointers to retrieve the desired data.
12. Address ID Name
A11 1 K
A22 2 B
A32 3 G
A42 4 A
A47 5 L
A58 6 W
A63 7 V
A67 8 U
A78 9 R
A83 10 S
ID Pointer
1 A11
2 A22
3 A32
4 A42
5 A47
6 A58
7 A63
8 A67
9 A78
10 A83
Name Pointer
K A11
B A22
G A32
A A42
L A47
W A58
V A63
U A67
R A78
S A83
Indexed for ID and
Name
13. Sorted index can be searched rapidly.
If you search a file sequentially,use N+1/2
data look ups to find the desired row.
Binary Search:keeps splitting the data set in
half until it findsthe desired data.
Example:
To find the entry for Perin.start at the
midpoint 14 /2=7 and the 7th entry is Manoj.
16. Drawbacks:
If the index is stored sequentially then it
faces the same difficulties with inserting a
new row as the sequential approach.
Indexes are defined when a new row of data
is added to the table,every index is to be
modified.
17. Steps to select an indexed columns:
1. To index only the columns that require
random searches.
2.Index the columns used in the JOIN
condition.
3. To test your application with large amount
of simple data and heavy usage.
4. A good analyser can monitor usage,
- - - identify problems.
--- suggest which columns should be
indexed.
18. To solve a insert problem,indexes can
generally based on linked list instead of
sequential index list.
With a linked list,
---Any data element can be stored
separately.
A pointer is then used to link to the next data
item.
19.
20. An index element – 3 parts:
1.Key Value
2.A pointer to the associated data element.
3.A pointer to the next index element.
Advantage:
Insertion and deletion of data can be made
easily and rapidly.
21. Eaton B71 ***B14 A58
B29
B14 Eles B71 A97
New element keep the B14
address
Farris B38 A63
B71
22. Inserting a new key row into a linked list
requires three basic steps:
1.Store the data and store the index element
keeping the address of each.
2.Find the point in the index to insert the
new row using a binary search.
3.Change the link pointers.
23. Link the elements into a tree.
Each element contains:
--key value.
--pointer to the rest of thedata.
-- two link pointers.
24. < key Data <=
Two links:
1.Left Pointer– lower values.
2.Right Pointer- value greater than or to the value
in the node.
Root Node - highest node on the tree.
Bottom Node – called as leaves end of the tree
branches.
The number of nodes between the root and the leaves
are called the depth of the tree.
25. Set the degree m and m is usually an odd
number.
-- The degree represents the maximum
number of children that can fall below
any node.
Every node (except the root) must have between
m/ 2 and m children.
All leaves are at the same level or depth.
All key values are displayed on the bottom
leaves.
A non-leaf nodes with n children will contain n-1
key values.
Leaves are connected by pointers.
26. Advantage:
--provides a guaranteed level of performance
for access to the data.
-- fast sequential retrieval.
--ability to add or delete elements from the
tree.
27. Store all the key values in numbered storage
location.
Key value is converted to a storage location
number and is divided by a prime number.
Example:
Consider 100 elements with key values
ranging from 100 to 999.
-- 101 is the prime number.
-- divide each key value by the prime number
and look at the remainder.
29. If two keys have the same remainder,one is
stored in an overflow location.
711
310
528
Overflow /collisions
30. Uses:
1.fast for finding and storing random data.
2.The key value is immediately converted
into a storage location.
Drawbacks:
1.no sequential retrieval of data.
2.more time to reorganize the table.
3.decide the space that will be needed before
you collect the data.