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

22
1 Welcome: To the forth learning sequence Possible representation (1) “ Recap : In the previous learning sequence, we discussed the basic definitions of Data base subject. Present learning: We shall explore the following topics: - Regular organization. - Factoring out the CITY value. - Indexing on city. - Combination the previous representations.

Upload: lorin-atkins

Post on 20-Jan-2018

214 views

Category:

Documents


0 download

DESCRIPTION

3 Possible representation The sample data is consists of information about five suppliers; for each supplier we wish to record a: Supplier number (S#), a supplier name (SNAME), a status value (STATUS), and location (CITY).

TRANSCRIPT

Page 1: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

1

Welcome: To the forth learning sequence “ Possible representation (1) “Recap : In the previous learning sequence, we discussed the basic

definitions of Data base subject.

Present learning: We shall explore the following topics:

- Regular organization. - Factoring out the CITY value. - Indexing on city. - Combination the previous representations.

Page 2: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

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 forth learning sequence “ Possible representation (1) “ Recap : In the previous…

3

Possible representation The sample data is consists of information

about five suppliers; for each supplier we wish to record a:

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

Page 4: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

4

Possible representation

1- Note that the (Figure1) actually a very simple conceptual model of the data.

S# SNAME

STATUS CITY

S1 Smith 20 London

S2 JOHNS 10 Paris

S3 BLACKE 30 Paris

S4 CLARK 20 London

S5 ADAMS 10 Athens

Fig 1: sample data regular organization

Page 5: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

5

Possible representation The representation in fig 1 (file containing five

stored record occurrence) has the advantage of simplicity but would probably be inadequate for various reasons in a realistic situation.

Suppose, for example we have (10.000) suppliers instead of just of five, but that they were located in only (10) different cities.

Page 6: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

6

Possible representation

2- If we assume that the amount of storage required for a pointer is less than that required a city name, the representation illustrated in fig2 will clearly save some storage space in such a situation.

Page 7: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

7

Possible representation

S# SNAME

STATUS

CITY POINTE

RS1 Smith 20S2 JOHNS 10S3 BLACKE 30S4 CLARK 20S5 ADAMS 10

CITYAthens

London

Paris

Supplier file

City file

Fig2: Factoring out the CITY value

Page 8: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

8

Possible representation

S# SNAME

STATUS

CITY POINTE

RS1 Smith 20S2 JOHNS 10S3 BLACKE 30S4 CLARK 20S5 ADAMS 10

CITYAthens

London

Paris

Supplier file

City file

Fig2: Factoring out the CITY value

Page 9: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

9

Possible representation

Here we have two stored files, a supplier file and a city file, with pointers out of the former into the later.

These pointers are Stored Record Addresses (SRAs). The only advantage of this representation (compared with the previous one) is the saving in space.

A request to find all properties (attributes) of a given supplier (entity) will require at least one more access than before.

Page 10: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

10

Possible representation

3- A request to find all suppliers (entities) in a given CITY will involve several more access.

If such a case requested and it is an important one.

The DBA may choose the alternative representation shown in fig3.

Page 11: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

11

Possible representation

S# SNAME

STATUS

S1 Smith 20S2 JOHNS 10S3 BLACKE 30S4 CLARK 20S5 ADAMS 10

CITY SUPPLEIRPOINTER

Athens

London

Paris

City file Supplier file

Fig3: Indexing on city

Page 12: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

12

Possible representation

S# SNAME

STATUS

S1 Smith 20S2 JOHNS 10S3 BLACKE 30S4 CLARK 20S5 ADAMS 10

CITY SUPPLEIRPOINTER

Athens

London

Paris

City file Supplier file

Fig3: Indexing on city

Page 13: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

13

Possible representation Here again we have two stored file. A

supplier file and a city file but this time there are pointers out of the later city into the firmer supplier.

Each city stored record occurrence contains pointers to all corresponding supplier stored record occurrence.

Page 14: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

14

Possible representation It should be obvious that the last

representation of data (factoring out the city) is better than the previous figure (Indexing on city) for queries asking for all supplier in a given city but worse for queries asking for all attributer of given supplier.

Here we conclude that representation of data is strongly dependent on the queries (access) asked by the system user.

Page 15: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

15

Possible representation Also it is worth to mention, that it is the Data

Base Management System (DBMS), not the Access Method that maintain the pointers; the access method is only responsible for assigning a unique stored record address (SRA) as it was mentioned before.

The interesting thing about the previous representation is that the CITY file is an index to the SUPPLIER file (an index controlled by the DBMS, not by the access method).

Page 16: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

16

Possible representation

4- To obtain the advantages of each of the previous two representation (at the cost of repairing slightly more storage space and probably more significant having more pointed maintenance to do when changes occur); we can have the following representation for data (fig 4).

Page 17: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

17

Possible representation

Athens

. London

. . Paris

. .

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

Fig 4: Combination the previous Fig2@3

Page 18: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

18

Possible representation

Athens

. London

. . Paris

. .

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

.

Fig 4: Combination the previous Fig2@3

Page 19: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

19

Possible representation

Athens

. London

. . Paris

. .

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

.

..

Fig 4: Combination the previous Fig2@3

Page 20: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

20

Possible representation

Athens

. London

. . Paris

. .

S1

Smith

20

. S2

Jones 10

S3

Black

30 S4

Clark

20 S5

Adams

30

.

.

..

Fig 4: Combination the previous Fig2@3

Page 21: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

21

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

- Four possible representations for some sample data.

Page 22: 1 Welcome: To the forth learning sequence “ Possible representation (1) “ Recap : In the previous…

22

END