cableguy47905 via AccessMonster.com said:
Thanks for keeping up with me on this. i really appreciate it.
You're welcome.
A company may have one contract with us for specific purpose, and another for
a different purpose, etc. They are able to be active all at the same time,
so there isn't a timeframe, or a renewal of a contract to worry about. So
all of these contracts have one thing in common, the company.
Sometimes a contract may have different Locations associated with it. So a
contract can be representative of several different locations with all their
own personal information such as address, phone, email etc. Those locations
are only associated with the one contract, not with any others that the
company has with us.
Thank you for clarifying.
It may be that the relationship between Locations and
ContractLocations that I specificed would have to be altered, since
contracts can have many locations, but each location can only have one
contract.
Each contract may have many locations. (1-to-Many from Contracts to
ContractLocations.)
Each location will appear on only one contract. (1-to-1 from Locations
to Contract Locations.)
Yes, I am pretty sure I understand that part, but I don't know how the tables
in the background are going to be set up.
The tables would be set almost up exactly as I gave them in my earlier
post.
I have modified them per these clarifications.
CREATE TABLE Companies
(CompanyID AUTOINCREMENT
,CompanyName TEXT(255)
,CONSTRAINT pk_Companies
PRIMARY KEY (CompanyID)
)
CREATE TABLE Contracts
(ContractID AUTOINCREMENT
,ContractName TEXT(255)
,CONSTRAINT pk_Contracts
PRIMARY KEY (ContractID)
)
CREATE TABLE Locations
(LocationID AUTOINCREMENT
,LocationName TEXT(255)
,CONSTRAINT pk_Locations
PRIMARY KEY (LocationID)
)
CREATE TABLE CompanyContracts
(CompanyContractID AUTOINCREMENT
,CompanyID INTEGER
,ContractID INTEGER
,CONSTRAINT pk_CompanyContracts
PRIMARY KEY (CompanyContractID)
,CONSTRAINT fk_CompanyContracts_Companies
FOREIGN KEY (CompanyID)
REFERENCES Companies (CompanyID)
,CONSTRAINT fk_CompanyContracts_Contracts
FOREIGN KEY (ContractID)
REFERENCES Contracts (ContractID)
,CONSTRAINT un_CompanyID_ContractID
UNIQUE (CompanyID, ContractID)
)
CREATE TABLE MainContracts
(CompanyContractID INTEGER
,CONSTRAINT pk_MainContracts
PRIMARY KEY (CompanyContractID)
,CONSTRAINT fk_MainContracts_CompanyContracts
FOREIGN KEY (CompanyContractID)
REFERENCES CompanyContracts (CompanyContractID)
)
CREATE TABLE ContractLocations
(ContractLocationID AUTOINCREMENT
,CompanyContractID INTEGER
,LocationID INTEGER
,CONSTRAINT pk_ContractLocations
PRIMARY KEY (ContractLocationID)
,CONSTRAINT fk_ContractLocations_CompanyContracts
FOREIGN KEY (CompanyContractID)
REFERENCES CompanyContracts (CompanyContractID)
,CONSTRAINT fk_ContractLocations_Locations
FOREIGN KEY (LocationID)
REFERENCES Locations (LocationID)
,CONSTRAINT un_LocationID
UNIQUE (LocationID)
)
Is it possible to update all of this information on one form? Maybe
with subforms is alright.
I would like to say yes and yes, but I am running out the door in 4
minutes and don't have time to create and load sample data to the
tables, and then design a test form and write a step-by-step to
replicate what I did.
If I have time, I'll be back on it later tonight, and for sure when I
get home from work tomorrow evening (07-Jun-2007).
Right now the DB has just one table and all of the data is able to be updated
via one form. There is no normalization to it at all. It has worked fine up
til now. I want to be able to perform more specific searches/queries. So it
doesn't work for me right now.
This would be by simply doing a "find" on the txtContractID textbox.
Right now it brings up all the information, but it is just not functional.
You have to put in the main contract to find out the others associated with
it.
I'm not sure why it would be processed that way.
In the setup I gave, once you know what one ContractID is, you know
the CompanyID, and therefore can automatically find all the associated
contracts (in the CompanyContracts table). The main contract is a
fact recorded in another table, and is only queried when it is
desirable to know what the main contract is.
not?
Nothing really defines it, it just happens to be the one that gets the most
attention. I could be any one of them. No real definition for it.
That's a minor red-flag (at least to me). It's a "fuzzy" idea
floating around in the database.
It effectively means that no one knows for certain why a certain fact
is being recorded in the database.
I did create the tables that you gave me for the design that you had in mind,
but I am a little stumped about the ContractLocations table. I am not sure
what that table is for. Couldn't I just put the LocationID in the
CompanyContract table and do a one to one with the Location table?
No, that won't work. It would mean that each ContractID could only be
associated with one LocationID.
Well, now that I know that the relationship between Contracts and
Locations is not many-to-many (which I why I set it up that way), yes,
you could do it that way.
----
You could dump the date columns from CompanyContracts since you have
stated you do not need them.
-----
I, personally, would keep them anyway. I would have the application
record the date the the row in CompanyContracts was entered, and then
I would also have the application record the date the contract was
closed. CompanyContract rows with a closing date would be filtered
out of most active queries so that they would not appear on forms, but
you would retain the historical proceedings of your contracts.
Or, at least you could create a set of duplicate "archive" tables to
stick deleted information in.
Someday a manager is going to ask "what did we have before".
Thanks again for the help.
Sincerely,
Chris O.