In: Computer Science
Consider the following database schema:
LIKE(person, sport),
PRACTICE(person, sport),
where person and sport are keys in both tables. The table LIKE gives the sports a person likes, the table PRACTICE gives the sports a person practices. We assume that a person likes at least one sport and practices at least one sport. We assume also that a person does not like a sport if the sport is not listed among the sports that person likes.
Express the following queries in relational algebra
1.
LIKE.person
LIKE.person = PRACTICE.person ^ LIKE.sport = PRACTICE.sport (LIKE
X PRACTICE)
2.
person ( (PRACTICE) - (LIKE) )
3.
a.person, b.person
a.sport = b.sport ^ a.person != b.person (PRACTICE a X PRACTICE
b)
// self join practice where sport is same but people
different
4.
person ( (PRACTICE)
(LIKE) )
// whatever they practice is a subset of sports they Like
5.
person ( (LIKE)
(PRACTICE) )
// whatever they like is a subset of sports they Practice
6.
person ( (PRACTICE)
((
sport (LIKE) )
(
sport (PRACTICE)) ) )
// Practice relation is divided by all the sports in the union of
Like and Practice