A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Creating relationships between tables



 
 
Thread Tools Display Modes
  #1  
Old May 23rd, 2009, 09:00 PM posted to microsoft.public.access.tablesdbdesign
Rachel
external usenet poster
 
Posts: 187
Default 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  
Old May 23rd, 2009, 10:01 PM posted to microsoft.public.access.tablesdbdesign
Steve[_70_]
external usenet poster
 
Posts: 152
Default 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  
Old May 23rd, 2009, 11:16 PM posted to microsoft.public.access.tablesdbdesign
tina
external usenet poster
 
Posts: 1,997
Default 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  
Old May 24th, 2009, 12:30 PM posted to microsoft.public.access.tablesdbdesign
Bernard Peek[_3_]
external usenet poster
 
Posts: 42
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:25 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.