1. (25) Answer the following questions: i) Why must the meta data be

advertisement
1. (25) Answer the following questions:
i) Why must the meta data be established for a database?
ii) What is the meaning of each attribute in the relation schema
shown below?
i) The meta data in a system catalog is established to interpret the
data in databases for application. It is in particular important to
the data/program independence, by which we mean that each
time we update data, the relational schemas, or key constraints
in databases, the data access programs within a database system
needn’t be changed since they use the meta data as an
interpreter to manipulate the data in the databases for
application. Once a relational schema is changed, what we need
to do is to modify the corresponding meta data while the access
programs remain the same.
ii)
Column
REL_NAME
INDEX_NAME
MEMBER_ATTR
INDEX_TYPE
ATTR_NO
ASC_DESC
Description
Table name, for which an index is
established
Column to store index names
assigned by the system
Attribute name, over which the
index is created
Type of the index
The attributes involved in an
index each is assigned a different
number
Whether the attribute values in
an index are sorted increasingly
or decreasingly.
If we have created a primary index over SSN in the Employee table,
and a clustering index over Location in the Department table, we will
have two tuples in RELATION_INDEXES as shown below.
REL_NAME
INDEX_NAME
Emploee
Department
EI
DI
MEMBERATTR
SSN
Location
INDEX_TYPE
ATTR_NO
ASC_DEC
Primary
Clustering
1
1
ascending
ascending
3. Assume that a file contains an integer sequence:
18, 17, 1, 2, 3, 4, 16, 15, 14, 13, 5, 6, 7, 8, 9, 10, 12, 11
and the buffer (in main memory) is of size 5 blocks with each being able to hold 2
integers.
Sort this file using the external sorting algorithm. Trace the computation process.
sorted run1:
1
3
13
15
17
2
4
14
16
18
Buffer:
1 2
5
6
3
4
5
6
sorted run2:
5
7
9
11
Temporary file:
6
8
10
12
1
Buffer:
5
6
1
2
……
13 14
13 14
5
7
6
1
2
8
5
6
3
4
3… … 4
……
Temporary file:
13 14
5
6
13 14
1
12
4
3
4
……
5 6
5
6
7
8
1
2
3
7
8
2
4. (15) Given the following relation schema and assume that a primary
index has been established on DNUMBER, how to evaluate
DNUMBER>5(DEPARTMENT) in an efficient way? Describe your
method.
To evaluate this query, we will first load the primary index into memory
and then search the index to find the entry with DNUMBR = 5. Doing
along the link associated with this entry to find the data page where the
record with DNUMBR = 5 is stored. We will return all the records with
DNUMBR > 5, as well as all the records in the subsequent data pages, as
illustrated in the following figure.
Data file: DEPARTMENT
Primary index:
DNUMBER
Index file: DI
(<k(i), p(i)> entries)
1
2
3
1
4
5
5
6

DNUMBER>5
(DEPARTMENT)
7
8
Dname
...
...
...
Download