ok- I'm REALLY stuck on a complex Query using a Junction Table. Here's what I have-
A flat file being imported (tbImport), with a unique property ID (MLS), information on 3 different agents, all in different fields. I am trying to normallize the DB by assigning every Agent to a separate table (away from all the other data). Every Agent has their own Employee ID (AgentCode), as well as Email Address, OfficeCode, Name and Office Name. There are 3 positions available to fill on every property- Listing Agent, CoListing Agent, and Buyer's Agent. It is possible for 1 Agent to fill 2 spots on a property (record). It is also possible for an Agent to fill DIFFERENT spots on different properties or records. So For example- on one property, Bob Smith can be both the Listing Agent, and the Buyer's Agent. Bob can also be the Co-Listing Agent on a different property. Bob can also be the Listing Agent on many other properties as well.
So- what I have is a Junction Table for the Property ID (called MLS). It also Contains the AgentCode and Position as Primary Keys. Basically the position is figured by which field in the import flat file their AgentCode shows up in. So- if CR123 shows up in the Agent1 Field- I know that is Bob Smith's Code, and that he is the Listing Agent on this property.
So I have 4 tables- tbImport- this is the flat file that is not normallized yet, and I will be updating the other tables with this info; tbListing, with a Primary Key of MLS (Number, not AutoNumber).
tbAgent, with a PK of AgentCode (again, pre-assigned not AutoNumber). This table holds all the agent's Contact/Office info. And the 3rd Table is the Junction Table- with a 1-to-Many Relationship between it and the tbListing Table, with MLS as the Foreign Key, and another 1-to-many relationship setup with the tbAgent Table, and a FK of the AgentCode.
Please see the attached image of my Relationship Diagram.
I am trying to import the records from tbImport into tbAgent & tbListings_Agents 'Position' field. I already have a query updating the tbListing table with all the other info for the Property- I now need to update/append the info into the tbAgents and Junction table.
I have been trying everything- and only ending up with Key Errors. I think I'll need to make 3 separate passes at updating the tbAgents & tbListings_Agents tables, as there are 3 different positions available. I'm a newbie to all this, so this is REALLY over my head! I am also up against a VERY tough deadline (already over) and need help ASAP. Can someone show me how to do this here?
THANK YOU!!!
ok- how do I post up a picture of my Relationships? I don't see a way to post it here.
A flat file being imported (tbImport), with a unique property ID (MLS), information on 3 different agents, all in different fields. I am trying to normallize the DB by assigning every Agent to a separate table (away from all the other data). Every Agent has their own Employee ID (AgentCode), as well as Email Address, OfficeCode, Name and Office Name. There are 3 positions available to fill on every property- Listing Agent, CoListing Agent, and Buyer's Agent. It is possible for 1 Agent to fill 2 spots on a property (record). It is also possible for an Agent to fill DIFFERENT spots on different properties or records. So For example- on one property, Bob Smith can be both the Listing Agent, and the Buyer's Agent. Bob can also be the Co-Listing Agent on a different property. Bob can also be the Listing Agent on many other properties as well.
So- what I have is a Junction Table for the Property ID (called MLS). It also Contains the AgentCode and Position as Primary Keys. Basically the position is figured by which field in the import flat file their AgentCode shows up in. So- if CR123 shows up in the Agent1 Field- I know that is Bob Smith's Code, and that he is the Listing Agent on this property.
So I have 4 tables- tbImport- this is the flat file that is not normallized yet, and I will be updating the other tables with this info; tbListing, with a Primary Key of MLS (Number, not AutoNumber).
tbAgent, with a PK of AgentCode (again, pre-assigned not AutoNumber). This table holds all the agent's Contact/Office info. And the 3rd Table is the Junction Table- with a 1-to-Many Relationship between it and the tbListing Table, with MLS as the Foreign Key, and another 1-to-many relationship setup with the tbAgent Table, and a FK of the AgentCode.
Please see the attached image of my Relationship Diagram.
I am trying to import the records from tbImport into tbAgent & tbListings_Agents 'Position' field. I already have a query updating the tbListing table with all the other info for the Property- I now need to update/append the info into the tbAgents and Junction table.
I have been trying everything- and only ending up with Key Errors. I think I'll need to make 3 separate passes at updating the tbAgents & tbListings_Agents tables, as there are 3 different positions available. I'm a newbie to all this, so this is REALLY over my head! I am also up against a VERY tough deadline (already over) and need help ASAP. Can someone show me how to do this here?
THANK YOU!!!
ok- how do I post up a picture of my Relationships? I don't see a way to post it here.