Part 1 Flashcards
(113 cards)
Give a brief explanation of the difference between the rerms information and data.
Information is any kind of knowledge that is interpretable by people in some context. Data is a representaion of information; it has no meaning without a context.
Give a sentence that represents your understanding of the information content of the form.
The cource with the title “Relational Databases: theory and practice” has code M359, cource manager John Sykes and 618 students enrolled on it.
“Students enrolled” on the form is an example of devirred data. Explain what this means in terms of data in a database.
The value for “Student enrolled” is a dirrived data becouse it is calculated from other data in the database.
State the number of occurences of the Supplies relationship shown in Figure 1.
5 ( the number of occurrence lines).
What can you deduce about the degree and participation conditions of the Supplies relationship based on the occurrences given?
The participation of the Supplier in the relationship is optional. An occurence of Supplier may be related to many occurrences of Part via the Supplier relationship.
“The participation of the Supplier in the relationship is optional. An occurence of Supplier may be related to many occurrences of Part via the Supplier relationship.”
draw an E-R diagram showing the Supplies relationship between the two entities typesSupplier and Part.
relation Staff
StaffNumber: StaffNumbers
Name: Names
primary key StaffNumber
relation Computer
Code: Codes
Type: Types
primary key Code
relation IsAssigned
StaffNumber: StaffNumbers
Code: Codes
primary key StaffNumber
foreign key StaffNumber references Staff
alternative key Codes
foreign key Code references Computer
Write down relational algebra epressions;
Each staff member is associated with at least one task
constraint ((project Staff over EmployeeNumber)
difference
(project Task over EmployeeNumber))
isEmpty
A staff member can be associated with a secretarial task only if his/her grade is 2 or above.
constraint
(select Staff join Task where Grade > 1 and TaskType = Secretarial)
is empty
Demonstrate that Vets has no functional dependencies with determinant PersonName and with the right-hand side consisting of a single attribute.
PersonName>Vet? No, because e.g. Barker is associated with two values of Vet.
PersonName>AnimanName? No, because e.g. Ahmad is associated with animals with names Fluffy and Tiger.
PersonName>AnimalType? No, Because e.g. Barker is associated with both a dog and a horse.
Consider the following decomposition of Vets into the relations Vets1 and Animals:
Vets1 alias (project Vets over Vet, PersonName, AnimalName)
Animals alias (project Vets over AnimalName, AnimalType)
Is this a non-lossy decomposition?
The first decomposition gives a relation which can be depicted by the first three columns of the table; the second gives a relation which can be depicted by the last two columns, When we join these two decompositions together, we get the following tuples.
The second tuble depicted was not in the orginal relation, so this is a lossy decomposition - the information that the second tuple is not part of Vets is lost.
Consider the following relation R with functional dependecies as shown;
R(a, b, c, d)
a,b -> c
a,b -> d
a -> c
Is R in third normal form?
R is not in second normal form because of a -> c. ( That is, c is not fully functionally dependent on the primary key.)
So R cannot be in third normal form as it is not even in second normal form.
SELECT b.a1, b1
FROM a,b
WHERE b.a1 = a.a1
AND a2 > 500
SELECT a1, a2
FROM a
WHERE (SELECT COUNT(*)
FROM b
WHERE b.a1 = a.a1)<2
SELECT c2, f
FROM c, (SELECT b2, COUNT(*) AS f
FROM b
GROUP BY b2) AS t1
WHERE b2 = c1
List the membership number, name and date of birth of each member for whom date of birth has been stored
SELECT member_no, name, date_of_birth
FROM member
WHERE date_of_birth IS NOT NULL
Give the membership number and name of each member who is currently borrowing one oe more CDs.
SELECT DISTINCT member.member_no, name
FROM member, loan
WHERE member.member_no=loan.member_no
For each member of the library, list his or her membership number and the number of CDs that he or she is currently borrowing. Your solution should show 0 as the number of CDs borrowed for members who are not currently borrowing CDs.
SELECT member.member_no, COUNT(cd_name) AS
number_borrowed
FROM member LEFT OUTER JOIN loan
ON member.member_no=loan.member_no
GROUP BY member.member_no
The administrator of the CD library has defined a procedure make_loan. The definition contains the declaration: make_loan(IN member_nos, IN cs_names)
where member_nos and CD_names are the domains of membership numbers and CD name, respectively. When make_loan is called, a row is added to the loan table containing the membership number of the member borrowing the CD, the name of the CD and the return date, which is calculated by the procedure.
Give two reasons why using this procedure may be preferable to wrking directly with the loan table.
Access conrol: A user can be given access to the procedure, but not have any access privilages to the underlying tables.
Ease of use: The procedure means that the processing (calculation of the return date, and statements relating to the specific tables) cab be hidden from the user.
In addition to the make_loan procedure, a function items_borrowed is define which returns the number of the CD that a member has borrowed. Its signatures is
items_borrowed (IN member_nos) RETURNS INTEGER
A member is allowed to borrow up to 3 CDs. The member with membership number m48 wishes to borrow “Best of Bach” and “Magic of Mozart”.
You are required to write a transaction which either successfully completes with the member borrowed more than 3 CDs. You should use the procedure make_loan and the function items_borrowed to answer this question.
BEGIN
CALL make_loan(‘m48’, ‘Best of Bach’);
CALL make_loan(‘m48’, ‘Magic of Mozart’);
IF items_borrowed(‘m48’) > 3
THEN ROLLBACK WORK;
ELSE COMMIT WORK;
END IF;
END
Entity-relationship diagram
Entity types
Additional constraints
Assumptions
Limitations
Entity types
Employee(StaffNo, Names_)_
Book(ISBN, Title, Author, Cost)
Reservation(StaffNo, ISBN, DateReserved)
Additional consttaints
c. 1 Reservation is a weak entity tyoe dependent on the entity type Employee. So each value of the StaffNo attribute in the entity type Reservation must be the same value as the StaffNo attribute of the Employee instance to which the Reservation entity type is related by the relationship Makes(a consequence of weak-strong entity types).
c. 2 Reservation is a weak entity type dependent on the entity type Book. So each value of the ISBN attribute in the entity type Reservation must be the same value as the ISBN attribute of the Book onstance to which the Reservation entity type is related by the relationship IsForA (a consequence of the weak-strong entity types.)
Assumptions - None
Limitations - None
Give three reasons why it may be necessary to restructure a database after it has been built and installed.
- Correcting errors or omissions in the database design and/or implementing that remained undetected after acceptance testing.
- Optimising performance.
- Satisfying new and changing requirements.
Give two reasons why denormalisation is not usually performed unless a performance need arises.
Denormalisation results in duplicated information which (1) may require more disk space to store (2) may result in insertion, amendment and deletion anomalies if the duplicated information needs to be updated.
What do (i) OLAP and (ii) OLTP systems facilitate within an organisation?
i. OLAP systems enable decision makers to gain insight into an organisation’s data from different, and multiple, perspectives.
ii. OLTP systems support the day-to-day operations of an organisation, such as purchasing, inventory, manufacturing, banking, payroll and accounting.