Deck 2: The Relational Model, Relational Algebra and Relational Calculus

Full screen (f)
exit full mode
Question
Describe the main characteristics of the Relational Data Model, including the properties of relations and the rules for relational integrity.
Use Space or
up arrow
down arrow
to flip the card.
Question
The Relational and CODASYL models are examples of two different approaches by which a Database Management System will be classified. Make a detailed comparison of each of these models, indicating clearly the relative advantages and disadvantages of each.
Question
Describe the difference between a base relation and a view and discuss the main benefits of using views in a relational database.
Question
From an SQL user's perspective, does the relational model provide logical and physical data independence?
Question
Choose any four relational algebra operators and explain how each functions.
Question
Given two relations R and S, where R contains N1 tuples and S contains N2 tuples (N2 > N1 > 0), give the minimum and maximum cardinality for the result relation for each of the following relational algebra expressions and in each case state any assumptions about the schemas that are required to make the expression meaningful:
(a) R \cup S
(b) R \cap S
(c) R - S
(d) R x S
(e) σ\sigma a = 1(R)
(f) Π\Pi a(R)
Question
A relational database contains details about journeys from Paisley to a variety of destinations and contains the following relations:
Operator (opCode, opName)
Journey (opCode, destinationCode, price)
Destination (destinationCode, destinationName, distance)
Each operator is assigned a unique code (opCode) and the relation operator records the association between this code and the operator's name (opName). Each destination has a unique code (destinationCode) and the relation destination records the association between this code and the destination name (destinationName), and the distance of the destination from Paisley. The relation Journey records the price of an adult fare from Paisley to the given destination by as specified operator, several operators may operate over the same route.
Formulate the following queries using relational algebra, tuple relational calculus, and domain relational calculus (the answers to these queries in SQL are given in the next section):
(a) List the details of journeys less than £100.
(b) List the names of all destinations.
(c) Find the names of all destinations within 20 miles.
(d) List the names of all operators with at least one journey priced at under £5.
(e) List the names of all operators and prices of journeys to 'Ayr'.
(f) List the names of all destinations that do not have any operators.
Question
The following tables form part of a database held in a Relational Database Management System:
The following tables form part of a database held in a Relational Database Management System:   Formulate the following queries in relational algebra, tuple relational calculus, and domain relational calculus. (1) List all employees. (2) List all the details of employees who are female. (3) List the names and addresses of all employees who are Managers. (4) Produce a list of the names and addresses of all employees who work for the 'IT' department. (5) Produce a list of the names of all employees who work on the 'SCCS' project.<div style=padding-top: 35px> Formulate the following queries in relational algebra, tuple relational calculus, and domain relational calculus.
(1) List all employees.
(2) List all the details of employees who are female.
(3) List the names and addresses of all employees who are Managers.
(4) Produce a list of the names and addresses of all employees who work for the 'IT' department.
(5) Produce a list of the names of all employees who work on the 'SCCS' project.
Question
The following tables form part of a database held in a Relational Database Management System:
The following tables form part of a database held in a Relational Database Management System:   Formulate the following queries in relational algebra, tuple relational calculus, and domain relational calculus (the answers to these queries in SQL are given in the next section). (1) List all Boeing aircraft. (2) List all Boeing 737 aircraft. (3) List the employee numbers of pilots certified for Boeing aircraft. (4) List the names of pilots certified for Boeing aircraft. (5) List the aircraft that can fly nonstop from Glasgow to New York (flyingRange > flightDistance). (6) List the employee numbers of employees who have the highest salary. (7) List the employee numbers of employees who have the second highest salary. (8) List the employee numbers of employees who are certified for exactly three aircraft.<div style=padding-top: 35px> Formulate the following queries in relational algebra, tuple relational calculus, and domain relational calculus (the answers to these queries in SQL are given in the next section).
(1) List all Boeing aircraft.
(2) List all Boeing 737 aircraft.
(3) List the employee numbers of pilots certified for Boeing aircraft.
(4) List the names of pilots certified for Boeing aircraft.
(5) List the aircraft that can fly nonstop from Glasgow to New York (flyingRange > flightDistance).
(6) List the employee numbers of employees who have the highest salary.
(7) List the employee numbers of employees who have the second highest salary.
(8) List the employee numbers of employees who are certified for exactly three aircraft.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/9
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 2: The Relational Model, Relational Algebra and Relational Calculus
1
Describe the main characteristics of the Relational Data Model, including the properties of relations and the rules for relational integrity.
Relational
- set of tables (as perceived by users)
- rows/columns
- variety of possible storage structures
- no repeating groups
- no links/pointers
- use of join columns.
- no duplicate tuples
- tuples are unordered
- attributes are unordered
- all attribute values are atomic.
Entity Integrity: No attribute participating in the PK of a base relation is allowed to accept null values.
Referential Integrity: If a base relation R2 includes a FK targeting the PK of R1, then every value of FK must either be:
- equal to the value of PK in some tuple of R1 or
- wholly null.
2
The Relational and CODASYL models are examples of two different approaches by which a Database Management System will be classified. Make a detailed comparison of each of these models, indicating clearly the relative advantages and disadvantages of each.
CODASYL
- records in chains/rings
- parent-child links
- many parents for a child
- ordering of all records
- fixed access paths
- potential for automatic referential integrity.
Relational
- set of tables (as perceived by users)
- rows/columns
- variety of possible storage structures
- no repeating groups
- no links/pointers
- use of join columns.
CODASYL Data Model Advantages
- longevity and availability of DBMSs for this model
- all data relationships can be modeled
- standards exist
- good performance
- data independence.
CODASYL Data Model Disadvantages
- complex navigation
- complexity.
Relational Data Model Advantages
- simplicity
- high level of data independence
- strong theoretical foundation.
Relational Data Model Disadvantages
- performance needs improvement
- referential integrity not supported.
3
Describe the difference between a base relation and a view and discuss the main benefits of using views in a relational database.
A base relation is a named relation, corresponding to an entity in the conceptual schema, whose tuples are physically stored in the database. A view can be constructed by performing operations such as the relational algebra selection, projection, join or other calculations on the values of existing base relations. A view is the dynamic result of one or more relational operations operating on the base relations to produce another relation. A view is a virtual relation that does not actually exist in the database but is produced upon request by a particular user, at the time of request.
The main benefits of views includes:
• It provides a powerful and flexible security mechanism by hiding parts of the database from certain users. The user is not aware of the existence of any attributes or tuples that are missing from the view.
• It permits users to access data in a way that is customized to their needs, so that the same data can be seen by different users in different ways, at the same time.
• It can simplify complex operations on the base relations. For example, if a view is defined as a join of two relations, the user may now perform the more simple unary operations of selection and projection on the view, which will be translated by the DBMS into equivalent operations on the join.
4
From an SQL user's perspective, does the relational model provide logical and physical data independence?
Unlock Deck
Unlock for access to all 9 flashcards in this deck.
Unlock Deck
k this deck
5
Choose any four relational algebra operators and explain how each functions.
Unlock Deck
Unlock for access to all 9 flashcards in this deck.
Unlock Deck
k this deck
6
Given two relations R and S, where R contains N1 tuples and S contains N2 tuples (N2 > N1 > 0), give the minimum and maximum cardinality for the result relation for each of the following relational algebra expressions and in each case state any assumptions about the schemas that are required to make the expression meaningful:
(a) R \cup S
(b) R \cap S
(c) R - S
(d) R x S
(e) σ\sigma a = 1(R)
(f) Π\Pi a(R)
Unlock Deck
Unlock for access to all 9 flashcards in this deck.
Unlock Deck
k this deck
7
A relational database contains details about journeys from Paisley to a variety of destinations and contains the following relations:
Operator (opCode, opName)
Journey (opCode, destinationCode, price)
Destination (destinationCode, destinationName, distance)
Each operator is assigned a unique code (opCode) and the relation operator records the association between this code and the operator's name (opName). Each destination has a unique code (destinationCode) and the relation destination records the association between this code and the destination name (destinationName), and the distance of the destination from Paisley. The relation Journey records the price of an adult fare from Paisley to the given destination by as specified operator, several operators may operate over the same route.
Formulate the following queries using relational algebra, tuple relational calculus, and domain relational calculus (the answers to these queries in SQL are given in the next section):
(a) List the details of journeys less than £100.
(b) List the names of all destinations.
(c) Find the names of all destinations within 20 miles.
(d) List the names of all operators with at least one journey priced at under £5.
(e) List the names of all operators and prices of journeys to 'Ayr'.
(f) List the names of all destinations that do not have any operators.
Unlock Deck
Unlock for access to all 9 flashcards in this deck.
Unlock Deck
k this deck
8
The following tables form part of a database held in a Relational Database Management System:
The following tables form part of a database held in a Relational Database Management System:   Formulate the following queries in relational algebra, tuple relational calculus, and domain relational calculus. (1) List all employees. (2) List all the details of employees who are female. (3) List the names and addresses of all employees who are Managers. (4) Produce a list of the names and addresses of all employees who work for the 'IT' department. (5) Produce a list of the names of all employees who work on the 'SCCS' project. Formulate the following queries in relational algebra, tuple relational calculus, and domain relational calculus.
(1) List all employees.
(2) List all the details of employees who are female.
(3) List the names and addresses of all employees who are Managers.
(4) Produce a list of the names and addresses of all employees who work for the 'IT' department.
(5) Produce a list of the names of all employees who work on the 'SCCS' project.
Unlock Deck
Unlock for access to all 9 flashcards in this deck.
Unlock Deck
k this deck
9
The following tables form part of a database held in a Relational Database Management System:
The following tables form part of a database held in a Relational Database Management System:   Formulate the following queries in relational algebra, tuple relational calculus, and domain relational calculus (the answers to these queries in SQL are given in the next section). (1) List all Boeing aircraft. (2) List all Boeing 737 aircraft. (3) List the employee numbers of pilots certified for Boeing aircraft. (4) List the names of pilots certified for Boeing aircraft. (5) List the aircraft that can fly nonstop from Glasgow to New York (flyingRange > flightDistance). (6) List the employee numbers of employees who have the highest salary. (7) List the employee numbers of employees who have the second highest salary. (8) List the employee numbers of employees who are certified for exactly three aircraft. Formulate the following queries in relational algebra, tuple relational calculus, and domain relational calculus (the answers to these queries in SQL are given in the next section).
(1) List all Boeing aircraft.
(2) List all Boeing 737 aircraft.
(3) List the employee numbers of pilots certified for Boeing aircraft.
(4) List the names of pilots certified for Boeing aircraft.
(5) List the aircraft that can fly nonstop from Glasgow to New York (flyingRange > flightDistance).
(6) List the employee numbers of employees who have the highest salary.
(7) List the employee numbers of employees who have the second highest salary.
(8) List the employee numbers of employees who are certified for exactly three aircraft.
Unlock Deck
Unlock for access to all 9 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 9 flashcards in this deck.