MS Developer Applications

     Go!
Prospero Blocks


 

Chat Center

Access Conference Room
Topic: Access

Board Folders

Misc. Tech Questions: 2352 msgs in 554 dscns, Latest: Jan-16 Misc. Tech Que...
2352 msgs in 554 dscns
Latest: Jan-16
Access Database Design: 1209 msgs in 248 dscns, Latest: Jan-4 Access Databas...
1209 msgs in 248 dscns
Latest: Jan-4
Access Forms/Reports: 3450 msgs in 754 dscns, Latest: 9:27 AMAccess Forms/R...
3450 msgs in 754 dscns
Latest: 9:27 AM
Access Code/Macros: 2335 msgs in 550 dscns, Latest: Sep-24 Access Code/Ma...
2335 msgs in 550 dscns
Latest: Sep-24
Access Roundtable: 851 msgs in 199 dscns, Latest: 5/17/09 Access Roundtable
851 msgs in 199 dscns
Latest: 5/17/09
SQL Server/Queries: 1046 msgs in 249 dscns, Latest: Dec-21 SQL Server/Que...
1046 msgs in 249 dscns
Latest: Dec-21
.NET Programming: 841 msgs in 198 dscns, Latest: Dec-21 .NET Programming
841 msgs in 198 dscns
Latest: Dec-21
VB/VBA Programming: 1081 msgs in 270 dscns, Latest: Nov-3 VB/VBA Program...
1081 msgs in 270 dscns
Latest: Nov-3
VFP/Fox:Lang/Design/OOP: 4508 msgs in 740 dscns, Latest: Nov-16 VFP/Fox:Lang/D...
4508 msgs in 740 dscns
Latest: Nov-16
VFP/Fox:Forms/Controls: 2405 msgs in 424 dscns, Latest: Feb-4 VFP/Fox:Forms/...
2405 msgs in 424 dscns
Latest: Feb-4
VFP/Fox:Data/DBC/Views: 1699 msgs in 278 dscns, Latest: Jan-11 VFP/Fox:Data/D...
1699 msgs in 278 dscns
Latest: Jan-11
VFP/Fox:Reports/Misc/2x: 1823 msgs in 401 dscns, Latest: Feb-8 VFP/Fox:Report...
1823 msgs in 401 dscns
Latest: Feb-8
Delphi/Kylix/Pascal: 896 msgs in 86 dscns, Latest: 1/23/07 Delphi/Kylix/P...
896 msgs in 86 dscns
Latest: 1/23/07
Breakpoint Chatter: 1855 msgs in 119 dscns, Latest: 4/12/09 Breakpoint Cha...
1855 msgs in 119 dscns
Latest: 4/12/09
Message Area
Access Database Design

Linking a table to itself

 Subscribe SubscribeGet a printer-friendly version of this discussion Print Discussion 

#1 of 3

     Posted 3/9/05 10:59 AM   
Varda
 
From  Varda  Posts 49  Last 6/5/07
To  All      [Msg # 23133.1 ]    

Using Access 2003

I'm finally done with the project I was on for the past 5 years and moved on to my next project.

I have a client who wants to track all his construction projects. But he also wants to track any projects that are related. So for example, if there's a Project called "Build Wall", then he wants to make sure it's very clear that the Project "Put in Windows" is related to it. (Although this particular example could easily be accomodated by calling it SUB-Project, there are many other projects that are not "subs" but simply related to each other).

Has anyone come across such a dilemma? How have you dealt with it?

I've been considering creating tblProject and tblProjectRelated that has two fields for the many-to-many relationship (ProjectID and ProjectRelatedID). But I foresee a problem with creating a report that shows all projects and their related projects, as I'll have to search in TWO fields in tblProjectRelated.

Am I making any sense, or should I freshen up on my English skills before reposting again?

Varda

 

 OptionsReply to this Message Reply

#2 of 3

     Posted 3/9/05 11:51 AM   
Ken Sheridan
 
From  Ken Sheridan  Posts 907  Last 8/5/06
To  Varda      [Msg # 23133.2 Message 23133.2 replying to 23133.1 23133.1 ]    

Varda:

>>But he also wants to track any projects that are related<<

This is similar to the classic bill of materials problem, in which an assembly might be made up of other assemblies which are made up of other assemblies and so on down to the atomic parts.  In this all assemblies and atomic parts are stored as rows in a Parts table and a PartStructure table with columns such as MajorPart and Minorpart models the relationship.

In your case a project is the equivalent of an assembly, and may comprise other sub-projects, which in turn might comprise their own sub-projects.  In your example putting in the windows is a sub-project of building the wall, which in turn might be a sub-project of build house.

So to model this you'd have a table Projects with a primary key ProjectID and a table ProjectStructure say, with columns MainProject and SubProject say each referencing the primary key of Projects.  The problem comes when you want to create a report or form which shows the projects, their sub-projects, their sub-projects and so on.  To do this requires recursive querying.  Now while recursion is no problem with VBA functions you cannot have recursive queries.  It is possible to simulate recursion however and there have been various means devised for doing this.  Some years ago I produced a little demo of a way I'd worked out to accompany a magazine article.  This works by creating a separate temporary database and tables in it from the stored data.  I'm attaching this as a Zip archive, which includes the original ReadMe file giving an explanation of how its done.  The database includes a report, which is printed from a button on the main form.  This report is based on the BoM table created in the external database, joined in a query to two instances of the local Parts table.  The Zip archive also includes a PartsTree database which illustrates a means of displaying the data as an indented tree type report.

You should, I think, be able to adapt this approach to your client's requirements without too much trouble.

PS:  I seem to be having trouble getting the attachment to stick, so you may find this message has been edited a few times!

Regards

Ken
Ken Sheridan, Stafford, England


Attachments
Name:   bom_2k.zipSize:   90 K


Edited 3/9/05   by  Ken Sheridan

Edited 3/9/05   by  Ken Sheridan
 OptionsReply to this Message Reply

#3 of 3

     Posted 3/9/05 1:03 PM   
Ken Sheridan
 
From  Ken Sheridan  Posts 907  Last 8/5/06
To  Varda      [Msg # 23133.3 Message 23133.3 replying to 23133.1 23133.1 ]    

Varda:

>>But I foresee a problem with creating a report that shows all projects and their related projects, as I'll have to search in TWO fields in tblProjectRelated<<

I didn't address that point in my first reply.  To get the associations in both directions you'd use a UNION operation.  With my demo the SQL would be:

SELECT Parts.PartName AS Part, Parts_1.PartName AS RelatedPart
FROM (Parts INNER JOIN BoM ON Parts.PartNum = BoM.MajorPartNum)
INNER JOIN Parts AS Parts_1 ON BoM.MinorPartNum = Parts_1.PartNum
UNION
SELECT Parts_1.PartName AS Part, Parts.PartName AS RelatedPart
FROM (Parts INNER JOIN BoM ON Parts.PartNum = BoM.MajorPartNum)
INNER JOIN Parts AS Parts_1 ON BoM.MinorPartNum = Parts_1.PartNum
ORDER BY Part,RelatedPart;

Regards

Ken
Ken Sheridan, Stafford, England

 OptionsReply to this Message Reply
 Subscribe SubscribeGet a printer-friendly version of this discussion Print Discussion 
Access Database Design

Linking a table to itself

  
 
     

Welcome, Guest

  • Post a message
  • New messages to you
  • Log in

Start Search
Advanced Search

Prospero Blocks
 
 
Special Offers
 
 
 

Finding People

 
 
 

Cool Clicks!

 
 
 
© 2009 Netscape Communications Corp. All rights reserved.

Legal Notices | Privacy Policy