Files
G4G0-1/Semester 1/Database Systems/Week 11/Week 11 Database Systems.md
2024-01-15 20:14:10 +00:00

1.8 KiB

Lecture 1 - Enhanced Relational Modelling

ER

Conceptual Model - identify important elements and relationships; independent of logical model, DBMS and type of DB ER Model - Contains entities, attributes, relationships and constraints; represented graphically using crows foot notation.,

Tutorial 2 ( 16:00 )

  1. Relational operators are defined as unary of binary, explain the distinction between the two.
  • Distinction lies in the number of relations the operators act on. Selection and Projection act on just 1 relation, whereas Union, Set Difference and Cartesian Product act on 2.
  1. Write the name of the 5 fundamental operations of relational algebra and a brief description of each.
  • Selection
    • Selects rows from a relation that satisfies a condition.
  • Projection
    • Retrieves specific columns or attributes from a relation.
  • Union
    • Combines tuples from two relations that have the same attributes or columns, eliminating duplicates.
  • Set Difference
    • Retrieves tuples from one relation that do not exist in another, based on common attributes
  • Cartesian Product
    • Produces a new relation by combining every tuple from one relation with every tuple from another.
  1. Consider the Staff relation shown in Table 22.1. Express each of the following in relational algebra.
  • sigma salary > 20000 (staff)
  • pi name, salary (staff)
  • pi name ( sigma salary < 10000 (staff) )
  1. Consider the teamManager relation shown in Table 22.2. With reference to both the teamManager relation and the staff relation (see Table 22.1), express the query “List the staff numbers of all staff who are not managers.” as follows: i. Write a single statement of relational algebra. ii. Write a single statement of SQL.

pi staffID(staff) - pi staffID(teamManager)

SELECT staffID
FROM Staff
EXCEPT
SELECT staffID
FROM TeamManager