![]() | |
#1
| |||
| |||
|
#2
| ||||
| ||||
|
|
I'm having trouble with some relational algebra questions in a school assignment. I have the first 15 completed but stuck on the last 4. I'm hoping someone can provide some help... I'm not necessarily looking for straight up answers, but perhaps a good hint at trying to solve the problem. Unless someone wants to provide the equation and explain why it's that, it would be great too. Reference to responses will be given in the assignment cine an SQL file will be developed from it. This is what I have: Classes(class, type, country, numGuns, bore, displacement) Ships (name, class, launched) Battles (name, date) Outcomes (ship, battle, result) The four queries I'm stuck on are the following: 1. Find the classes that have only one ship as a member of that class (not all ships are listed in the Ship table) |
|
2. Find the countries that had both battleships and battlecruisers (those fall under type in Classes) |
|
3. Find those ships that "lived to fight another day"; they were damaged in one battle, but later fought in another. |
|
Another problem with this assignment... I have to list all the ships mentioned in the database. All the ships may not appear in the Ships relations... I said the following in algebraic expression SELECT name(Ships UNION (SELECT ship (Outcome UNION(SELECT class (Classes))) Would that work? |
#3
| |||
| |||
|
|
On 2009-02-28, mmcclaf <mmcc... (AT) gmail (DOT) com> wrote: I'm having trouble with some relational algebra questions in a school assignment. I have the first 15 completed but stuck on the last 4. I'm hoping someone can provide some help... I'm not necessarily looking for straight up answers, but perhaps a good hint at trying to solve the problem. Unless someone wants to provide the equation and explain why it's that, it would be great too. Reference to responses will be given in the assignment cine an SQL file will be developed from it. This is what I have: Classes(class, type, country, numGuns, bore, displacement) Ships (name, class, launched) Battles (name, date) Outcomes (ship, battle, result) The four queries I'm stuck on are the following: 1. Find the classes that have only one ship as a member of that class (not all ships are listed in the Ship table) hint: you want to group by class 2. Find the countries that had both battleships and battlecruisers (those fall under type in Classes) hint: you want to join class to class by country=country 3. Find those ships that "lived to fight another day"; they were damaged in one battle, but later fought in another. you should join outcome to get the date battle when ships were damaged and then join that to a similar join where the date is later but ant outcome is allowed. Another problem with this assignment... I have to list all the ships mentioned in the database. All the ships may not appear in the Ships relations... I said the following in algebraic expression SELECT name(Ships UNION (SELECT ship (Outcome UNION(SELECT class (Classes))) Would that work? if it would I don't understans the language you are using. |
![]() |
| Thread Tools | |
| Display Modes | |
| |