d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Relational Algebra
Add Reply New Topic New Poll
Retired Moderator
Posts: 15,582
Joined: Oct 17 2008
Gold: 226.37
Trader: Trusted
Feb 25 2015 02:30pm
Hello!

I have a table that looks like this



This is a list of people (namn) drinking different beers. I want to be able to sort out the people who only drinks one type of beer (only names).

For example: Alan drinks Sofiero, Lapin Kulta, Tuborg, Bass etc. Alan shouldn't be on the list.
Kari on the other hand only drinks Tuborg so I want him on the new list.

I'm pretty sure i got it right in sql (select * from TABELL group by namn, beer having count(*) = 1), but I need help translating this into relational algebra.

Thanks :)
Member
Posts: 16,138
Joined: Feb 6 2014
Gold: 2,985.99
Warn: 40%
Feb 28 2015 02:17pm
relational algebra has its own chapter, like 1 chapter, its actually easier than this code. remember stuff like PROJECTION USING PIE SIGN, AND ANOTHER PROJECTION USING THE OTHER, IT SHOULD BE IN ONE OF THE CHAPTERS OF THE BOOK.

fundamental of databse system 6th edition

σDno=4(EMPLOYEE)
σSalary>30000(EMPLOYEE)
σ<selection condition>(R)

σDno=4 AND Salary>25000 (EMPLOYEE)
would correspond to the following SQL query:
SELECT *
FROM EMPLOYEE
WHERE Dno=4 AND Salary>25000;



πSex, Salary(EMPLOYEE)

πSex, Salary(EMPLOYEE)
would correspond to the following SQL query:
SELECT DISTINCT Sex, Salary
FROM EMPLOYEE


This post was edited by captaindookiefrankwest71 on Feb 28 2015 02:17pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll