Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Call (CPhone, CDate, RNo, ANo, Desc, Length) Foreign Key (RNo) Officer (No) Foreign Key (ANo) Area (ANo) Officer (No, TName, Name, Surname, DOB, Role) Foreign

Call (CPhone, CDate, RNo, ANo, Desc, Length) Foreign Key (RNo) Officer (No) Foreign Key (ANo) Area (ANo) Officer (No, TName, Name, Surname, DOB, Role) Foreign Key (TName) Team (TName) Team (TName, THead, TArea) Foreign Key (THead) Officer (No) Foreign Key (TArea) Area (ANo) Dispatch (CPhone, CDate, TName, Report) Foreign Key (CPhone, CDate) Call (CPhone, CDate) Foreign Key (TName) Team (TName) Area (ANo, Address, City, Size)

In the Call table, CPhone is the phone number of the caller, CDate is the date of call, RNo is the officers no who receive the call, ANo is the no of the area that is associated with this call, Desc includes a description for the call, Length is the duration of the call in seconds. In the Officer table, No is the identification number of the officer, TName is the name of the team this officer is in (it can be null if this officer is not assigned to a team), Name and Surname are the name and surname of the officer, DOB is the date of birth of the officer, and Role specifies the role of the officer as Dispatcher, Police, Firefighter or Medic. In the Team table, TName is the name of the team, THead is the officers no who is the leader of this team, TArea is the areas no that this team patrols. In the Dispatch table, calls are assigned to teams using the respective foreign keys. In this table, Report contains the feedback of the corresponding team for the corresponding call. In the Area table, ANo is the identification number of this area, Address is the text description of the area, City is the city name that contains this area, and Size is the size of this area in square kilometers.

Write the following queries in SQL, based on the given information.

1. select Name, Surname, Role from Officer o where TName = 'Alpha';

2. select c.CPhone from call c JOIN Officer o on c.RNo = o.No where o.Surname = 'Kang' group by c.CPhone, o.No Having MAX(c.CDate);

3. select SUM(Length) from Call where CDate >= '2021-01-01' AND Desc = 'False Emergency Call';

4. select t.TName, COUNT(o.No) from Team t JOIN Officer o on t.TName = o.TName where o.No = 755 group by t.TName ;

5. Find the name of the teams that have an officer with the surname Tango and another officer with the surname Cash at the same time. 6. Find the address and the patrolling team count of the areas where at least 5 teams are patrolling. (In the Team table, TArea attribute indicates the area each team patrols) 7. Find the report of the dispatches in which a team is assigned to a call that is associated with an area that is different from its patrolling area. 8. Find the name of the teams that patrol the area that is associated with the call(s) that has the longest duration. 9. Find the name and surname of the officers that are in a team dispatched to a call associated with an area in the city Ankara. 10. Find the name and surname of the officers that lead a team and received at least 10 calls.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions