so im trying really hard to understand relationships and kinda tough from the outside in. Ive stop coding this program to concentrate on learning how to query with relationships and see how they interact etc., but i dont know where to start. if i can see it working then i will understand it.
What ive done so far is create 3 brand new tables.
Branches
Customers
Jobsites
************
BranchId
Branch
CustomerId
BranchID
CustomerName
JobsiteID
CustomerID
JobsiteName
*************
ive set up relationships in this way...
Branches.BranchID one-to-many Customers.BranchID
Customers.CustomerID one-to-many Jobsites.CustomerID
so in theory (i guess) its saying that each branch can have many customers and each customer can have many jobsites. Still maintaining the jobsite relation to branch through the customer, right?
My problem so far is how do i start my sql with these.
Branches will never change but i want to (firstly) input a customer.
So typically i would do something similiar to
the problem in this case is i actually need the branchid to go into the customers table to keep up the relationship and not the actual branch name, so how can i grab the branchid based on the branch name.
What ive done so far is create 3 brand new tables.
Branches
Customers
Jobsites
************
BranchId
Branch
CustomerId
BranchID
CustomerName
JobsiteID
CustomerID
JobsiteName
*************
ive set up relationships in this way...
Branches.BranchID one-to-many Customers.BranchID
Customers.CustomerID one-to-many Jobsites.CustomerID
so in theory (i guess) its saying that each branch can have many customers and each customer can have many jobsites. Still maintaining the jobsite relation to branch through the customer, right?
My problem so far is how do i start my sql with these.
Branches will never change but i want to (firstly) input a customer.
So typically i would do something similiar to
Code:
sql = "INSERT INTO Customers ([BranchID], [CustomerName] VALUES (" & globals.branch & ", '" & me.customertxt.value & "')"
the problem in this case is i actually need the branchid to go into the customers table to keep up the relationship and not the actual branch name, so how can i grab the branchid based on the branch name.
Last edited: