I'm given a table with two columns: id_ship and date. I need to find the ids of the ships that appear the maximum number of times (that is , the ships that have the maximum number of dates), assuming that a ship cannot have more than three dates.
It's easy to find the ids of the ships that have three dates, just selecting from the triple cartesian product of the table. However, I'm not able to check if the result obtained is empty or not. If it's not empty, I would have to choose this view, while if it is empty I would need to look for the ships that have two dates and check again if this is empty. How can I proceed? Remember I cannot use extended relational algebra, so it's not valid the use of aggregating functions or extended projection.
EDIT: Sorry, I thought the concept "classical relational algebra" was standard. The operations that. The operations supported by my RA are: select, project, rename, union, difference, intersect, cartesian product, natural join, join with condition and division