Relational Aglebra, dont know what to do!

61 Views Asked by At

The following relational tables/schemes are given:

In bold is the primary key, in Italics is foreign key:

-City(Name,Country,Population)

-Venue(VID,Capacity,Name)

-Concert(KID,ID,DID,duration)

-Performer(ID,KID,age,name)

-Ticket(TID,KID,price,type)

Now my assignment is to find all the concerts where there were more VIP tickets than other tickets. VIP is of the attribute type, in tickets. I honestly have thought about this problem a while. My main idea what to group KID,Type,count(*) in (tickets) and somehow add the tickets of type != VIP and select where that is less than VIP tickets, but I just don;t know how to do that formally..

1

There are 1 best solutions below

0
On BEST ANSWER

There is several way to do so, I will offer you the following one

$$\Pi_{\mbox{what you're searching}}(\sigma_{\mbox{the keys}}(\mbox{the relational DB}))$$

I would join Concert and Ticket, I know it's not the most optimal but I am not accurate enough at the moment in relational Algebra to offer you something else.

Then, in my opinion, the answer would be:

$\Pi_{ID}(\sigma_{\mbox{type=`̀VIP` }}(Concert \bowtie Ticket))$