If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Creating relationships between tables
I have a Projects Table and a Customers Table. My problem is I want to have
multiple Customers on one project and I want each customer to be able to have multiple projects. I don't know how to set up the tables and relationships to do this. |
#2
|
|||
|
|||
Creating relationships between tables
You need three tables:
TblProject ProjectID etc TblCustomer CustomerID etc TblProjectCustomer ProjectCustomerID ProjectID CustomerID For data entry you need a form/subform. The main form would be based on TblProject and the subform would be based on TblProjectCustomer. In the sobform you need a combobox (or listbox) to enter CustomerID. The row source for the combobox (or listbox) would be TblCustomer. Steve "Rachel" wrote in message ... I have a Projects Table and a Customers Table. My problem is I want to have multiple Customers on one project and I want each customer to be able to have multiple projects. I don't know how to set up the tables and relationships to do this. |
#3
|
|||
|
|||
Creating relationships between tables
you're describing a classic many-to-many relationship: one customer may be
involved in many projects, and one project may involve many customers. in relational design, you model this relationship by using a "join" or "linking" table, which is the "many" side of a one-to-many relationship with each of the other two tables, as tblProjects ProjectID (primary key) other fields that describe a project, but nothing about customers. tlbCustomers CustomerID (pk) other fields that describe a customer, but nothing about projects. tblProjectCustomers ProjectID (foreign key from tblProjects) CustomerID (fk from tblCustomers) you can use the two fields as a combination primary key; or you can use a separate field (probably Autonumber) as the primary key, in which case you need to set a Unique multi-field index using both foreign key fields. the relationships are tblProjects.ProjectID 1:n tblProjectCustomers.ProjectID tblCustomers.CustomerID 1:n tblProjectCustomers.CustomerID set these relationships in the Relationships window, and make sure you enforce Referential Integrity on each relationship. so each customer involved with a specific project will be a single record in tblProjectCustomers. recommend you read up/more on relational design principles so you'll understand how the relationships work. for more information, see http://www.accessmvp.com/JConrad/acc...abaseDesign101 hth "Rachel" wrote in message ... I have a Projects Table and a Customers Table. My problem is I want to have multiple Customers on one project and I want each customer to be able to have multiple projects. I don't know how to set up the tables and relationships to do this. |
#4
|
|||
|
|||
Creating relationships between tables
In message , Rachel
writes I have a Projects Table and a Customers Table. My problem is I want to have multiple Customers on one project and I want each customer to be able to have multiple projects. I don't know how to set up the tables and relationships to do this. As others have already pointed out, the answer is to create a link table. I'll just add that it's worth taking some time to look at what the link table actually represents. You may find that there is more to it than just the keys to its two parents. -- Bernard Peek |
Thread Tools | |
Display Modes | |
|
|