Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Relational Algebra

    I am trying to under the equivalent of SQL to Relational Algebra, can anyone help to convert the below SQL statements into Relational Algebra. Thank you.


    SELECT Customer.LastName, Customer.Address, Customer.Nationality
    FROM Customer INNER JOIN Product ON Customer.CustomerCode = Product.CustomerCode WHERE Product.Purchased <> 'CLOTHS') AND (Product.SalesPersonCode = '30098')

  2. #2
    Join Date
    Apr 2012
    Posts
    3
    One of the ways I can think at first is:

    π Customer.LastName, Customer.Address, Customer.NationalityProduct.Purshased <> 'CLOTHS' ^ Product.SalesPerson='30098' (Customer ⋈ Customer.CustomerCode=Product.CustomerCode Product))

    Something like that...

  3. #3
    Join Date
    Apr 2012
    Posts
    3

    Relation Algebra

    Thanks DrKrusty.

    I found it easy from SQL statement and when I was constructing the notations I started visa versa i.e. specifying unique ID for both table instead of criteria first. Is is necessary to define table.attribute i.e. Customer.CustomerCode when working with only one table?

  4. #4
    Join Date
    Apr 2012
    Posts
    3
    No, you do not need to specify the table name when working with only one table.
    I just don't understand why you have the 'CustomerCode' attribute in the table Product. I does not make sense to me...

  5. #5
    Join Date
    Apr 2012
    Posts
    3

    Relation Algebra

    I have two tables, customer and product, I think to be able to know which customer by certain product, the Customer.Code on Product table will be foreign key from Customer table. Sorry, I am taking my course assignment and new to databases.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •