Oh, I did not realize that I had to say that it was homework...(Forum
rules are quite concise...)
It is homework.
I suppose that lumping clients and trainers into 1 could be a sane idea.
The table company holds info about companies that a client might be booked by. So, the client table has a FK pointed at the companyID.
All courses are run by the same company.
One more thing, here is a select statement,
Below it is the output, maybe that'll make things a little clearer.
Code:
select client.CLI_Forename + ' ' + client.CLI_Surname as [Client Name],
company.CO_CompanyName,
delegate.DEL_Date,
course.C_Code,
course.C_Title,
course.C_Cost as Cost,
course.C_Duration as Duration,
trainer.Tr_Forename + ' ' + trainer.Tr_Surname as [Trainer Name],
delegate.DEL_GroupID,
delegate.DEL_GroupLeader
from client
left join delegate on delegate.DEL_clientNumber=client.CLI_clientNumber
left join course on course.C_Code = delegate.DEL_courseCode
left join [course instance] on course.C_Code = [course instance].CI_courseCode
left join trainer on [course instance].CI_Trainer = trainer.Tr_TrainerID
left join company on client.CLI_Company = company.CO_id
order by client.CLI_Surname;
Output:
Code:
Client Name CO_CompanyName DEL_Date C_Code C_Title Cost Duration Trainer Name DEL_GroupID DEL_GroupLeader
----------------------------------------------------------------------- ---------------------------------------- ----------------------- ------ ------------------------------ --------------------- -------- --------------------------------------------------- ----------- ---------------
Denise Cartwright NULL 2010-03-12 00:00:00.000 MP01 RedMan - projects 865.00 3 Bob Symonds 0 0
Bob Simonds NULL 2010-12-31 00:00:00.000 CB01 Converting to Redbase 390.00 2 Katie Fawset 0 0
John Travolta SuperCompany ltd 2010-04-16 00:00:00.000 DP21 RedBase Programming 1200.00 5 Katie Fawset 1 0
Andrew Walker NULL 2010-12-31 00:00:00.000 CB01 Converting to Redbase 390.00 2 Katie Fawset 1 1
Also, see the new ERD where I have added FKs.