1 welcome: to the fifth learning sequence “ possible representation (2) “ recap : in the...

25
1 Welcome: To the fifth learning sequence Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations. Present learning: We shall explore the following topics: - The pointer chain. - The chain two-way. - The inverted organization.

Upload: carlton-kayes

Post on 14-Dec-2015

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

1

Welcome: To the fifth learning sequence

“ Possible representation (2) “

Recap : In the previous learning sequence, we discussed four possible representations.

Present learning: We shall explore the following topics:

- The pointer chain.

- The chain two-way.

- The inverted organization.

Page 2: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

2

Possible representation

- In this section we make a simple collection of sample data and consider some of many ways it could be represented in storage at the level of stored record interface.

Page 3: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

3

Possible representation

The sample data is consists of information about the same five suppliers; for each supplier we wish to record the same attributes:

Supplier number (S#), a supplier name (SNAME), a status value (STATUS), and location (CITY).

Page 4: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

4

Possible representation

5- An alternative to the previous representation (Combination Factoring out the city and Indexing on city) that avoids this problem is illustrated in fig5. The pointer chain.

Page 5: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

5

Possible representation

Athens

. London

Paris

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

Fig 5: Pointer chain

. .

Page 6: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

6

Possible representation

Athens

. London

Paris

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

Fig 5: Pointer chain

. .

Page 7: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

7

Possible representation

Athens

. London

Paris

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

.

Fig 5: Pointer chain

. .

Page 8: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

8

Possible representation

Athens

. London

Paris

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

.

Fig 5: Pointer chain

. .

Page 9: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

9

Possible representation

Athens

. London

Paris

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

.

Fig 5: Pointer chain

. .

Page 10: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

10

Possible representation

Athens

. London

Paris

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

.

..

Fig 5: Pointer chain

. .

Page 11: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

11

Possible representation

Athens

. London

Paris

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

.

..

Fig 5: Pointer chain

. .

Page 12: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

12

Possible representation

Athens

. London

Paris

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

.

..

Fig 5: Pointer chain

. .

Page 13: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

13

Possible representation

Athens

. London

Paris

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

.

..

Fig 5: Pointer chain

. .

Page 14: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

14

Possible representation

In this representation each occurrence (CITY or supplier) contains just one pointer. Each City pointed to the first supplier in that city. That supplier then points to the second supplier record occurrence in the same city, who points to the third, and so on, up to the last, which points back to the city.

Page 15: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

15

Possible representation

Thus for each city we have chain of all supplier in that city. The advantage of this representation is that it is easier to apply change.

The disadvantage is that, for a given city the only way to access the nth supplier is to follow the chain and access the 1st, 2nd,....,(n-1) the supplier too.

If each access involves a seek operation, the time taken to access the nth supplier may be quite considerable.

Page 16: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

16

Possible representation

6 -Another extension to the above representation might be making the chain two-way (so that stored record contains exactly two pointers) .

The DBA might choose such a representation if deleting a supplier record is a common operation.

Page 17: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

17

Possible representation

Fig5 (pointer chain) is a simple example of multilist organization when for each city we had a list of corresponding suppliers. In exactly the same way we could also have a list of suppliers for each distinct status value. In general a multilist organization can clearly contain any number of such lists.

Page 18: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

18

Possible representation

7- To return to secondly indexing: just as it is possible to provide any number of lists in the multilist organization. It is also possible to provide any number of secondary indexes in organization.

In the extreme case we have the situation illustrated in fig6 an indexing on every secondary field, or called inverted organization (the symbol ^ is used to mean pointer to).

Page 19: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

19

Possible representation

SNAME Pointers

Smith ^S1

Jones ^S2

Blake ^S3

Clark ^S4

Adams ^S5

SNAME Index

Fig 6: Inverted Organization

Page 20: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

20

Possible representation

SNAME Pointers

Smith ^S1

Jones ^S2

Blake ^S3

Clark ^S4

Adams ^S5

STATUS

Pointers

10 ^S2

20 ^S1, ^S4

30 ^S3, ^S5

SNAME Index

STATUS Index

Fig 6: Inverted Organization

Page 21: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

21

Possible representation

SNAME Pointers

Smith ^S1

Jones ^S2

Blake ^S3

Clark ^S4

Adams ^S5

STATUS

Pointers

10 ^S2

20 ^S1, ^S4

30 ^S3, ^S5

CITY Pointers

Athens ^S5

London ^S1, ^S4

Paris ^S3, ^S2

SNAME Index

STATUS Index CITY Index

Fig 6: Inverted Organization

Page 22: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

22

Possible representation

SNAME Pointers

Smith ^S1

Jones ^S2

Blake ^S3

Clark ^S4

Adams ^S5

STATUS

Pointers

10 ^S2

20 ^S1, ^S4

30 ^S3, ^S5

CITY Pointers

Athens ^S5

London ^S1, ^S4

Paris ^S3, ^S2

S#

S1

S2

S3

S4

S5

SNAME Index

STATUS Index CITY Index

SUPPLIER

File

Fig 6: Inverted Organization

Page 23: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

23

Possible representation

The organization will give good performance in response to a request for (all supplier with a given property).

A request for (all properties of given supplier) will take a long time to answer.

Page 24: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

24

Summary: In this learning sequence, we discussed the following topic:

- Three possible representations for some sample data.

Page 25: 1 Welcome: To the fifth learning sequence “ Possible representation (2) “ Recap : In the previous learning sequence, we discussed four possible representations

25

END