I have a question about how to make records in a table reference other
records in the same table....
Suppose I'm building a small database to track some basic information
on several companies. In addition to the ID and other info, I want to
track predecessor and succesor companies, if any.
In other words, a given company may have come into being from the
merger of two or more predecessors, may have been spun-off from a
single predecessor, or may not have a predecessor as a start-up.
Conversely, a company may no longer exist because it merged with
another to form a new company, or may have divided itself to form
multiple new companies. (The successors.)
In this scenario my questions are:
1. How do I set things up so that a record in the table references one
or more other records in that same table? Keeping in mind that there
could be multiples each of predecessors and successors.
2. How would the form be set up, as the number of predecessors and
successors will vary? I assume a couple of subforms are in order here.
Datasheet style is fine for my purposes.
Typically flat-file databases have served my needs in the past, but
I've been trying to get a better handle on RDBMSs, and this is a bit
beyond my current experience.
My version of Access 2000. 6 8613
if a company has more than one predecessor (formed by a merger of 2+
companies) or more than one successor, then you would have to split the
predecessor and succesor information into separate tables.
Some database applications will let you do this kind of thing by using
things like repeating fields. (Like FileMaker) They're somewhat
useful, but if you want to write reports on a subset of repeating field
values, then forget it. You have to split the repeating fields.
If you *really* want to reference the same Company table in the
Predecessor and Successor fields, you could create a combobox for each
and use SELECT CompanyID, CompanyName FROM Company as the rowsource for
your combobox...But I would lean toward creating separate tables for
the Predecessor and Successor info. Then you should be able to track
what you need.
Sounds like a rough place to start with Access. I may be wrong, but
this does not sound like an easy question.
if a company has more than one predecessor (formed by a merger of 2+
companies) or more than one successor, then you would have to split the
predecessor and succesor information into separate tables.
Some database applications will let you do this kind of thing by using
things like repeating fields. (Like FileMaker) They're somewhat
useful, but if you want to write reports on a subset of repeating field
values, then forget it. You have to split the repeating fields.
If you *really* want to reference the same Company table in the
Predecessor and Successor fields, you could create a combobox for each
and use SELECT CompanyID, CompanyName FROM Company as the rowsource for
your combobox...But I would lean toward creating separate tables for
the Predecessor and Successor info. Then you should be able to track
what you need.
Sounds like a rough place to start with Access. I may be wrong, but
this does not sound like an easy question.
Interesting question, John.
The table can refer to another record in itself, just by adding a foreign
key field that refers to its primary key. To create the relation window,
drag a 2nd copy of the table into the Relationships window (Tools menu.)
Access aliases the 2nd copy with an "_1" suffix, and you can create the
relation as normal. For an introductory example, see:
Self Joins: tables that look themselves up (Pedigrees example)
at: http://allenbrowne.com/ser-06.html
In your case, you are wanting to deal with multiple predecessors and
successors, so a self-join may not be enough. You may need a junction table
containing fields:
PredecessorID foreign key to Main.MainID
SuccessorID also a foreign key to Main.MainID
This would allow you to define any records as predecessor of any others.
In terms of interface, you would have a main form, with 2 subforms. The
first subform shows the predecessors of the current record, and the 2nd
subform shows its successors. This is an incredibly simple but very flexible
design, that works very well. I used the design once and had no problems at
all until the client asked for the data to be exported in flatfile format
which proved to be messy.
Where it becomes complex is if you are asked to trace the generations up or
down to an unknown depth, especially if there is a possibility of a
predecessor also being a successor of itself (cyclic relationship.) To study
the general design of one part holding other parts that are parts in their
own rights, search on "bill of materials". Here's a starting point: http://www.mvps.org/access/modules/mdl0027.htm
The SQL langauge is not good at handling this kind of relation, so
ultimately it can get messy. More reading: http://www.intelligententerprise.com/001020/celko.shtml http://www.dbmsmag.com/9603d06.html http://www.dbmsmag.com/9604d06.html http://www.dbmsmag.com/9605d06.html http://www.dbmsmag.com/9606d06.html
HTH
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"John E" <n7***@hotmail. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. . I have a question about how to make records in a table reference other records in the same table....
Suppose I'm building a small database to track some basic information on several companies. In addition to the ID and other info, I want to track predecessor and succesor companies, if any.
In other words, a given company may have come into being from the merger of two or more predecessors, may have been spun-off from a single predecessor, or may not have a predecessor as a start-up.
Conversely, a company may no longer exist because it merged with another to form a new company, or may have divided itself to form multiple new companies. (The successors.)
In this scenario my questions are:
1. How do I set things up so that a record in the table references one or more other records in that same table? Keeping in mind that there could be multiples each of predecessors and successors.
2. How would the form be set up, as the number of predecessors and successors will vary? I assume a couple of subforms are in order here. Datasheet style is fine for my purposes.
Typically flat-file databases have served my needs in the past, but I've been trying to get a better handle on RDBMSs, and this is a bit beyond my current experience.
My version of Access 2000.
Interesting question, John.
The table can refer to another record in itself, just by adding a foreign
key field that refers to its primary key. To create the relation window,
drag a 2nd copy of the table into the Relationships window (Tools menu.)
Access aliases the 2nd copy with an "_1" suffix, and you can create the
relation as normal. For an introductory example, see:
Self Joins: tables that look themselves up (Pedigrees example)
at: http://allenbrowne.com/ser-06.html
In your case, you are wanting to deal with multiple predecessors and
successors, so a self-join may not be enough. You may need a junction table
containing fields:
PredecessorID foreign key to Main.MainID
SuccessorID also a foreign key to Main.MainID
This would allow you to define any records as predecessor of any others.
In terms of interface, you would have a main form, with 2 subforms. The
first subform shows the predecessors of the current record, and the 2nd
subform shows its successors. This is an incredibly simple but very flexible
design, that works very well. I used the design once and had no problems at
all until the client asked for the data to be exported in flatfile format
which proved to be messy.
Where it becomes complex is if you are asked to trace the generations up or
down to an unknown depth, especially if there is a possibility of a
predecessor also being a successor of itself (cyclic relationship.) To study
the general design of one part holding other parts that are parts in their
own rights, search on "bill of materials". Here's a starting point: http://www.mvps.org/access/modules/mdl0027.htm
The SQL langauge is not good at handling this kind of relation, so
ultimately it can get messy. More reading: http://www.intelligententerprise.com/001020/celko.shtml http://www.dbmsmag.com/9603d06.html http://www.dbmsmag.com/9604d06.html http://www.dbmsmag.com/9605d06.html http://www.dbmsmag.com/9606d06.html
HTH
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"John E" <n7***@hotmail. com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.com.. . I have a question about how to make records in a table reference other records in the same table....
Suppose I'm building a small database to track some basic information on several companies. In addition to the ID and other info, I want to track predecessor and succesor companies, if any.
In other words, a given company may have come into being from the merger of two or more predecessors, may have been spun-off from a single predecessor, or may not have a predecessor as a start-up.
Conversely, a company may no longer exist because it merged with another to form a new company, or may have divided itself to form multiple new companies. (The successors.)
In this scenario my questions are:
1. How do I set things up so that a record in the table references one or more other records in that same table? Keeping in mind that there could be multiples each of predecessors and successors.
2. How would the form be set up, as the number of predecessors and successors will vary? I assume a couple of subforms are in order here. Datasheet style is fine for my purposes.
Typically flat-file databases have served my needs in the past, but I've been trying to get a better handle on RDBMSs, and this is a bit beyond my current experience.
My version of Access 2000.
I don't *have* to do it with a single table. Because I am referencing
exactly the same type of information, I figured that it could stay in
the same table. A predecessor company, for example, would also be a
record with the same kinds of basic information about it, and it could
also have predecessors as well as successors.
The variable number of repeating fields in a record does seem tricky,
though.
I don't *have* to do it with a single table. Because I am referencing
exactly the same type of information, I figured that it could stay in
the same table. A predecessor company, for example, would also be a
record with the same kinds of basic information about it, and it could
also have predecessors as well as successors.
The variable number of repeating fields in a record does seem tricky,
though. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Marc |
last post by:
Hi all,
I was using Tkinter.IntVar() to store values from a large list of
parts that I pulled from a list. This is the code to initialize the
instances:
def initVariables(self):
self.e = IntVar()
for part, list in info.masterList.items():
|
by: Ralf W. Grosse-Kunstleve |
last post by:
******************************************************************************
This posting is also available in HTML format:
http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html
******************************************************************************
Hi fellow Python coders,
I often find myself writing::
class grouping:
|
by: Ralf W. Grosse-Kunstleve |
last post by:
My initial proposal
(http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html) didn't
exactly get a warm welcome...
And Now for Something Completely Different:
class autoinit(object):
def __init__(self, *args, **keyword_args):
self.__dict__.update(
|
by: David Coffin |
last post by:
I'd like to subclass int to support list access, treating the integer
as if it were a list of bits.
Assigning bits to particular indices involves changing the value of
the integer itself, but changing 'self' obviously just alters the
value of that local variable.
Is there some way for me to change the value of the BitSequence
object itself? I've also tried wrapping and delegating using
__getattr__, but I couldn't figure out how to handle...
|
by: marek.rocki |
last post by:
First of all, please don't flame me immediately. I did browse archives
and didn't see any solution to my problem.
Assume I want to add a method to an object at runtime. Yes, to an
object, not a class - because changing a class would have global
effects and I want to alter a particular object only. The following
approach fails:
class kla:
x = 1
| |
by: Andrew Robert |
last post by:
Hi Everyone,
I am having a problem with a class and hope you can help.
When I try to use the class listed below, I get the statement that self
is not defined.
test=TriggerMessage(data)
var = test.decode(self.qname)
|
by: Peter Maas |
last post by:
The Python FAQ 1.4.5 gives 3 reasons for explicit self (condensed version):
1. Instance variables can be easily distinguished from local variables.
2. A method from a particular class can be called as
baseclass.methodname(self, <argument list>).
3. No need for declarations to disambiguate assignments to local/instance
variables.
|
by: braver |
last post by:
Is there any trick to get rid of having to type the annoying,
character-eating "self." prefix everywhere in a class? Sometimes I
avoid OO just not to deal with its verbosity. In fact, I try to use
Ruby anywhere speed is not crucial especially for @ prefix is better-
looking than self.
But things grow -- is there any metaprogramming tricks or whatnot we
can throw on the self?
Cheers,
|
by: Kurda Yon |
last post by:
Hi,
I found one example which defines the addition of two vectors as a
method of a class. It looks like that:
class Vector:
def __add__(self, other):
data =
for j in range(len(self.data)):
data.append(self.data + other.data)
|
by: Bart Kastermans |
last post by:
I am playing with some trees. In one of the procedures I wrote
for this I am trying to change self to a different tree. A tree
here has four members (val/type/left/right). I found that self = SS
does not work; I have to write self.val = SS.val and the same for
the other members (as shown below). Is there a better way to do this?
In the below self is part of a parse tree, F is the parse tree of a
function f with argument x. If a node...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |