dbTalk Databases Forums  

Relational Algebra

comp.databases comp.databases


Discuss Relational Algebra in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mmcclaf
 
Posts: n/a

Default Relational Algebra - 02-27-2009 , 06:34 PM






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?

Reply With Quote
  #2  
Old   
Jasen Betts
 
Posts: n/a

Default Re: Relational Algebra - 02-28-2009 , 05:22 AM






On 2009-02-28, mmcclaf <mmcclaf (AT) gmail (DOT) com> wrote:
Quote:
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

Quote:
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

Quote:
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.

Quote:
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.



Reply With Quote
  #3  
Old   
mmcclaf
 
Posts: n/a

Default Re: Relational Algebra - 02-28-2009 , 09:16 AM



On Feb 28, 6:22*am, Jasen Betts <ja... (AT) xnet (DOT) co.nz> wrote:
Quote:
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.
I am just using relational algebra.... like a textual representation
of a SQL statement for a query.... Except replace the capital words
with the symbols for relational algebra.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.