Question

I am fairly green when it comes to working with Access and databases in general.

I am asking for your help in figuring out how to set the correct relationships for three tables:

Table 1 contains:
(no unique ID)
SalesTripID
EmployeeName
StartDate
EndDate
*Each record on this table is related to 1 specific employee's 1 specific sales trip

Table 2 contains:
HotelName
HotelStart
HotelEnd
HotelTotal
*This table may contain multiple records that belong to only 1 record on table 1 (for instance, an employee would stay at 2 hotels during their sales trip)

Table 3 contains:
(no unique ID)
MealVendor
MealDate
MealTotal
*This table, similar to Table 2, may have multiple records in it that are tied to the 1 SalesTripID

How do I set something up to show me each SalesTripID, the multiple Table 2, and the multiple Table 3 records associated with it? Do I need to add a Primary Key anything other than Table 1? Is writing a query involved to display the information? Because I am so green, any and all feedback is welcome.

Was it helpful?

Solution

The following is my recommendation:

Relationship setup

Add a SalesTripId field on tables 2,3. This is called a ForeignKey.

If SalesTripId in Table1 is not unique (i.e. each employee can have a trip with the same Id as another employee), add another field (Id) in Table1. You can use Access' AutoNumber type for that field.

I recommend always having a primary key in your tables. But you can skip the Id fields in tables 2,3.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top