Using a table twice (1 Viewer)

Tyler08

Registered User.
Local time
Today, 23:45
Joined
Feb 27, 2008
Messages
44
My database has a table listing employee details which links to a table of documents. Another table lists document versions which links to a table of document version owners.

Since most of the people in the employees table are also in the document owners table any alterations to their details need to be updated twice.

Can anyone tell me how to use a table twice in one database? All attempts to date have resulted in “ambiguous outer joins”.

Regards

Tyler
 

KenHigg

Registered User
Local time
Today, 18:45
Joined
Jun 9, 2004
Messages
13,327
Can you post a diagram of the current relationships window?
 

RuralGuy

AWF VIP
Local time
Today, 16:45
Joined
Jul 2, 2005
Messages
13,826
If all document owners are employees then you do not need a document owners table. If not then you still only need one "people" table with an "IsEmployee" field.
 

Tyler08

Registered User.
Local time
Today, 23:45
Joined
Feb 27, 2008
Messages
44
Thanks for the reply. Will the forum let me post a jpg of the Relationships window? If not I'll email it home and post a link to a Photobucket url tonight. My company firewall will not let me access photo sharing web sites. :mad:

Or, the structure is like this:

TblEmployee
TblDocument
TblVersion
TblOwner

EmployeeID is the primary key in TblEmployee and the foreign key in TblDocument
DocumentID is the primary key in TblDocument and the foreign key in TblVersion
OwnerID is the primary key in TblOwner and the foreign key in TblVersion


Tyler
 
Last edited:

Mile-O

Back once again...
Local time
Today, 23:45
Joined
Dec 10, 2002
Messages
11,316
You need three tables.

  • One for documents;
  • One for employees; and
  • One to act as a junction between the two.



tblDocuments
DocumentID (Autonumber) - Primary Key
document property fields

tblEmployees
EmployeeID (Autonumber) - Primary Key
Forename (Text)
Surname (Text)

tblEmployeesToDocuments
EmployeeID (Number) - Foreign Key
DocumentID (Number) - Foreign Key

These two fields together then comprise your composite primary key.

 

KenHigg

Registered User
Local time
Today, 18:45
Joined
Jun 9, 2004
Messages
13,327
You need three tables.

  • One for documents;
  • One for employees; and
  • One to act as a junction between the two.



tblDocuments
DocumentID (Autonumber) - Primary Key
document property fields

tblEmployees
EmployeeID (Autonumber) - Primary Key
Forename (Text)
Surname (Text)

tblEmployeesToDocuments
EmployeeID (Number) - Foreign Key
DocumentID (Number) - Foreign Key

These two fields together then comprise your composite primary key.


You left out the document version / owner parts - ?
 

Tyler08

Registered User.
Local time
Today, 23:45
Joined
Feb 27, 2008
Messages
44
Just found the paperclip icon!

Relationships jpg attached

Tyler
 

Attachments

  • Relationships.JPG
    Relationships.JPG
    30.8 KB · Views: 201

RuralGuy

AWF VIP
Local time
Today, 16:45
Joined
Jul 2, 2005
Messages
13,826
IMHO, if documents always have one and only one "owner" then I see no reason not to put that ForeignKey right in the Documents table and eliminate the junction table.
 

RuralGuy

AWF VIP
Local time
Today, 16:45
Joined
Jul 2, 2005
Messages
13,826
Just found the paperclip icon!

Relationships jpg attached

Tyler
When you use the Post Reply button or go to Advanced in the Quick Reply area, scroll down to "Manage Attachments" area to post an attachment.
 

Tyler08

Registered User.
Local time
Today, 23:45
Joined
Feb 27, 2008
Messages
44
TblVersion is there because each document (TblDocument) has many versions (TblVersion) and each version has it's own owner (TblOwner), not always the same person as the Employee.

Tyler
 
Last edited:

RuralGuy

AWF VIP
Local time
Today, 16:45
Joined
Jul 2, 2005
Messages
13,826
TblVersion is there because each document (TblDocument) has many versions (TblVersion) and each version has it's own owner (TblOwner)

Tyler
I think of Version as just another attribute (field) of the document.
 

boblarson

Smeghead
Local time
Today, 15:45
Joined
Jan 12, 2001
Messages
32,059
Something's not right as the relationship should show a ONE-To-Many relationship between documents and versions. Did you make sure your document ID in the versions table isn't set to Indexed (No Duplicates) and should be Duplicates OK instead.

The same thing goes between Employees and Documents. As it looks right now it looks as if an employee can only have one document, and that shouldn't be the case.
 

Tyler08

Registered User.
Local time
Today, 23:45
Joined
Feb 27, 2008
Messages
44
Ok, I'll look at that. But I still need to display two different names one one form. One name from the Employee table and one from the Owner table.

Tyler
 

boblarson

Smeghead
Local time
Today, 15:45
Joined
Jan 12, 2001
Messages
32,059
I think of Version as just another attribute (field) of the document.

I would have to disagree on this if you want to track multiple versions of a document, not just have one version at any one time. There are reasons why you would do so. One example is the production illustration documents produced by Boeing. We needed to know which version of the P.I. was in what department at any one time, not just the most up to date version.
 

boblarson

Smeghead
Local time
Today, 15:45
Joined
Jan 12, 2001
Messages
32,059
Ok, I'll look at that. But I still need to display two different names one one form. One name from the Employee table and one from the Owner table.

Tyler

You can put the table in the relationships TWICE - once to show the employee and once for the owner.
 

Mile-O

Back once again...
Local time
Today, 23:45
Joined
Dec 10, 2002
Messages
11,316
You left out the document version / owner parts - ?


Did I? Oh well. It was more the IsEmployee checkbox that caught my eye.

Well, there can be a tblVersions with all version infor, linked to a VersionID in the tblDocuments.
 

RuralGuy

AWF VIP
Local time
Today, 16:45
Joined
Jul 2, 2005
Messages
13,826
Ok, I'll look at that. But I still need to display two different names one one form. One name from the Employee table and one from the Owner table.

Tyler
Hi Tyler,
What is the difference between Owner and Employee?
 

Users who are viewing this thread

Top Bottom