Link to home
Create AccountLog in
Avatar of Dale Massicotte
Dale MassicotteFlag for United States of America

asked on

Need help creating a complex query and/or junction table

So here goes...

I have a table 'Customers'

main fields needed are:
ID, CompanyName, Street, City, State, Zip

I suppose I need another table 'DurationMiles' with the following fields:

ID, ForeignID1, ForeignID2, Miles, Duration

So each record in DurationMiles will contain 2 foreign ID's (2 distinct records) from the Customers table so that I can use another program (Mappoint) to calculate the distance and duration between the 2 records in the 'Customers' table

Is this the correct approach?  I will need to also know how to use the junction table or query to get the miles and duration.
SOLUTION
Avatar of edtechdba
edtechdba
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Dale Massicotte

ASKER

"Is your ID in the DurationMiles table the foreign key of the Customers table?
DurationMiles.ID = Customers.ID"

Not currently

"What kind of values are going to be in the ForeignID1 and ForeignID2 fields? I'm asking because I'm wondering if you really need to create 2 records in the DurationMiles table for each Customer in order to perform this calculation (from Mapppoint). "

I was thinking that the two foreign ID's in the DurationMiles table would be 2 records of the ID in the Customers table.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.