Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

WRITE THE FOLLOWING QUERIES IN RELATIONAL ALGEBRA 8.Determine if any client is a

ID: 3601008 • Letter: W

Question

WRITE THE FOLLOWING QUERIES IN RELATIONAL ALGEBRA

8.Determine if any client is also a registered user. This occurs if the Client IDis the same as the User ID. The correct answer will have columns Client Name, Client Address, User Name, Password, User City, and User State.

9.Find those clients that have only one ad. The answer will have columns Name and Address.


10.I have added a Size column to the page table as well as to the Ad table. Calculate the storage requirement for each server and display those servers that do not have enough disk space to store all of the pages and ads assigned to it.

.TABLES

Client(Client ID, Client Name, Client Address)

Ad(Ad Contract ID, Ad Start Date, Ad End Date, Ad JPEG, Size [inbytes], Client ID, Server Name)

Server (Server Name, Server Location, Memory Size[in Gigabytes], Disk Size[in terabytes])

Page (Page URL, Page Name, Page Text, Server Name, Size [in bytes])

User (User ID, City, State)

Registered User (User ID, User Name, Password)

Anonymous User (User ID)

On Page (Ad Contract ID, Page URL, Start Date, End Date)

Access (User ID, Ad Contract ID, Page URL, Start Date, Access Date)

Explanation / Answer

8.select Client Name,Client Address,User Name,Password,City as User City,State as User State
from Client c
inner join Registered User r
on c.ClientID=r.UserId
inner join User u
on r.UserID=u.UserID
where c.ClientID=r.UserId


9.select Client Name,Client Address
from Client
where ClientID in
(select ClientID from Ad
having count(ClientID)=1)

10.select s.Min(Disk Size),s.Server Name
from Ad a
inner join Server s
on a.Server Name=s.Server Name
inner join Page p
on s.Server Name=p.Server Name
group by Server Name