At this point you can roll the joins through the relationships until you hit the contact info. At this point, we only have 1 contact stored for the company "Slum Villas" so this will work:
select salesorders.InstallAddress,
salesorders.SalePrice,
salesorders.OrderDate,
salesorders.InstallComplete,
floorplans.UnitName,
floorplans.Description,
installers.InstallerName
from installers
inner join salesorders on salesorders.InstallerId = installers.InstallerId
inner join floorplans on floorplans.FloorplanId = salesorders.FloorplanId
inner join company on company.CompanyId = floorplans.CompanyId
inner join company_contacts on company_contacts.CompanyId = company.CompanyId
inner join contacts on contacts.ContactId = company_contacts.ContactId
where installers.installerId = 1
and salesorders.InstallComplete is null;
What happens when we add another contact for that company? I'll show you. I added another contact for the company like this:
insert into contacts (
Position,
FirstName,
LastName,
OfficePhone,
CellPhone,
Email
)
values (
'Maintenance Supervisor',
'Bob',
'Dole',
'555 555 5555',
'555 234 3456',
'
[email protected]'
);
Since it's autoincremented userid, and he's the second user added in a row I know his ID is going to be 2. The company, being the first and only one added is company id 1. So we add him to the many to many table that links contacts with companies like this:
insert into company_contacts (companyid, contactid) values (1,2);