P
P
parkito2015-12-20 00:18:59
SQL
parkito, 2015-12-20 00:18:59

How to translate SQL code into relational algebra code?

Hello. The task is given - to translate the code from the sql language into the language of relational algebra. With simple examples with selection, cartesian product, etc. I cope, but here the complex code turned out to be beyond my power. Please help with this. The grouping generally took out the brain.
Request 1

SELECT DeparturePoint, ArrivalPoint FROM dbo.Flight
WHERE EXISTS (
 
SELECT Board.BoardNumber  FROM dbo.ScoreBoard INNER JOIN dbo.Board ON Board.BoardNumber = ScoreBoard.BoardNumber
WHERE EXISTS
     (
           SELECT Plane.PlaneModel FROM dbo.Board INNER JOIN dbo.Plane ON Plane.PlaneModel = Board.PlaneModel
           WHERE Plane.MountOfMotors = 2
     )

Request 2
SELECT  ArrivalPoint
FROM 
dbo.Flight, dbo.ScoreBoard,dbo.Board,dbo.Plane
WHERE Flight.FlightNumber = ScoreBoard.FlightNumber AND ScoreBoard.BoardNumber = Board.BoardNumber AND Board.PlaneModel=Plane.PlaneModel
GROUP BY ArrivalPoint
HAVING  COUNT(DISTINCT Plane.PlaneModel) = (SELECT COUNT(PlaneModel) FROM dbo.Plane)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Vitrenko, 2015-12-20
@Vestail

Try RelaX .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question