# Solutions for Exercise no. 4

### 1. Tuple Relational Calculus

1:

{t | \$f Î Employees \$d Î Departments(t[FName] = f[FName] Ù
d[MGRCPR] = 654 Ù d[DNUMBER] = f[DNO])}

2:
{t\$e Î Employees \$p Î Projects \$a Î Allocations (t[CPR] = e[CPR] Ù
e[BDATE] < 1961-01-01 Ùp[PNAME] = 'InteractiveTV' Ù
p[PNUMBER] = a[PNO] Ù a[ECPR] = e[CPR])}

3:
{t | \$e Î Employees \$p ÎProjects \$aÎ Allocations
(t[FNAME] = e[FNAME] Ù t[MINIT] = e[MINIT] Ù t[LNAME] = e[LNAME] Ù
e[DNO] = 10 Ù p[PNAME] = 'PalmTop' Ù a[HOURS] 15 Ù
p[PNUMBER] = a[PNO] Ù a[ECPR] = e[CPR])}

### 2. Domain Relational Calculus

1:.
{ áDNBRñ | \$DLOCATION (áDNBR, DLOCATIONñ Î Locations Ù
Ø\$PLOCATION, \$PNAME, PNUMBER
(áPNAME, PNUMBER, PLOCATION, DNBRñ Î Projects Ù
PLOCATIONS = DLOCATIONS))}

2:
Anonymous variables are in the following query implicitly existentially quantified, e.g., á _, _ñ Î p stands for \$v1, v2 áv1, v2ñ Î p.

{áCPR, BDATEñ | \$DNO (á_, _, _, CPR, BDATE, _, _, _, DNOñ Î Employees Ù
\$MGRCPR, BDATE1 á_, _, _, MGRCPR, BDATE1, _, _, _, _ñ Î Employees Ù
á_, DNO, MGRCPR, _ñ Î Departments Ù BDATE < BDATE1)}

### 3. Relational Algebra

1:
pFNAME (sMGRCPR = 654 Employees nDNO = DNUMBER Departments))

2:
R1 ¬((Employees n CPR = ECPR Allocations) n PNO = PNUMBER Projects))
pCPR (sBDATE < 1961-01-01 Ù PNAME = 'InteractiveTV'(R1)

3:
R1¬Employees n CPR = ECPR Allocations
R2 ¬R1 n PNO = PNUMBER Projects
R3 ¬sDNO = 10 Ù PNAME = 'PalmTop' Ù HOURS 15 (R2)
pFNAME, MINIT, LNAME (R3)

4:
R1  ¬Locations n DDNBR = DNUM Ù DLOCATION = PLOCATION Projects
R 2 ¬pDNBR, DLOCATION (R1)
R3  ¬ Locations \ R2
pDNBR (R3)

5:
R1 ¬(Employees n DNO = DNUMBER Departments) n EEmployees.CPR = Managers.CPR rManagers(Employees)
R2 ¬sEmployees.BDATE < Managers.BDATE (R1)
pEmployees.CPR, Employees.BDATE (R2)

Result sets

1: Empty

2:
 FNAME Kristian Charlotte Niels

3:
 CPR 111 654

4:
 DNBR 12

5:
 CPR BDATE 123 1955-12-10

Best regards,
Kristian Torp