PC Review


Reply
Thread Tools Rate Thread

Primary Key Cascade Question

 
 
Marsh
Guest
Posts: n/a
 
      20th Apr 2010
In an Access 2007 db, I have 5 tables, with Proj_No the Primary Key field in
the main table tblProjID. It has 7 additional fields.
It will be benificial to have Proj_No in the other 4 tables as foreign key
fields. My question is, when a new Proj_No is entered into the main table
to create a new record, how can I get that entry (alpha-numeric) to cascade
to the other 4 tables, thus creating a new record in the 4 child tables.

Thank you
Marsh
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      20th Apr 2010
On Tue, 20 Apr 2010 12:00:01 -0700, Marsh <(E-Mail Removed)>
wrote:

>In an Access 2007 db, I have 5 tables, with Proj_No the Primary Key field in
>the main table tblProjID. It has 7 additional fields.
>It will be benificial to have Proj_No in the other 4 tables as foreign key
>fields. My question is, when a new Proj_No is entered into the main table
>to create a new record, how can I get that entry (alpha-numeric) to cascade
>to the other 4 tables, thus creating a new record in the 4 child tables.


Don't.

It's neither necessary nor helpful to have empty "placeholder" records in your
related tables. If you use a Form based on the main table, with Subforms for
your related tables (using Proj_No as the Master/Child Link Field), the
Proj_No will fill in when you add data to the child table. That's when you
need the foreign key - when there is data to link, not before.

If you're adding data in table datasheets, don't! Tables are VERY limiting and
(despite Microsoft's blandishments) inappropriate for data entry or editing.
Forms are much more powerful and flexible.
--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
 
Jerry Whittle
Guest
Posts: n/a
 
      20th Apr 2010
You shouldn't be creating a record in the other 4 tables unless there is a
real need for it.

The best way to keep the tables linked is to first join them in the
Relationships Window with Referential Integrity enabled. Next create a form
based on the tblProjID table. On this form put subforms based on the other
tables.

It's pretty unusual to have one table linked to 4 other tables in a
hub-and-spoke configuration. What is in the other tables?
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"Marsh" wrote:

> In an Access 2007 db, I have 5 tables, with Proj_No the Primary Key field in
> the main table tblProjID. It has 7 additional fields.
> It will be benificial to have Proj_No in the other 4 tables as foreign key
> fields. My question is, when a new Proj_No is entered into the main table
> to create a new record, how can I get that entry (alpha-numeric) to cascade
> to the other 4 tables, thus creating a new record in the 4 child tables.
>
> Thank you
> Marsh

 
Reply With Quote
 
Marsh
Guest
Posts: n/a
 
      21st Apr 2010
Three very informative answers, and I shall work on this today. If problems
arise, I will be back tomorrow.
Thank you all

"SQLGal" wrote:

> Marsh,
>
> Go into relationships and set up relationships between all of the tables.
> Set the join as one-to-many (parent-to-child), enforce referential integrity
> and cascading updates and deletes.
>
> Also, I like to set the join type to all records in the parent and only the
> matching in the children. You don't have to do this but it is a good way to
> view parent records without children.
>
> Also, it is best to set this up before you have entered data. If you get an
> error while setting it up, I can help you with that.
>
> Finally, this set up will cause cascading updates and cascading deletes. The
> database will provide a warning and tell you how many records are being
> updated or deleted.
>
>
>
> Marsh wrote:
> >In an Access 2007 db, I have 5 tables, with Proj_No the Primary Key field in
> >the main table tblProjID. It has 7 additional fields.
> >It will be benificial to have Proj_No in the other 4 tables as foreign key
> >fields. My question is, when a new Proj_No is entered into the main table
> >to create a new record, how can I get that entry (alpha-numeric) to cascade
> >to the other 4 tables, thus creating a new record in the 4 child tables.
> >
> >Thank you
> >Marsh

>
> .
>

 
Reply With Quote
 
Jerry Whittle
Guest
Posts: n/a
 
      21st Apr 2010
Hi Bruce,

You are correct that there can be many valid reasons for having that many
child tables. Probably because this is the New Users forum, I assumed (and we
know what that can mean) the the OP might have been doing something like a
table for each year or something.

Thanks for keeping me honest!
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"BruceM via AccessMonster.com" wrote:

> Not meaning to be excessively picky, and with respect for your knowledge and
> experience as demonstrated by your posts over the years, is it unusual to
> have four child tables? I have at least one database with four, and several
> with three, and I don't think I'm operating at an especially sophisticated
> level as such things go.
>
> As an example of four child tables, a training database has a main Training
> Session record, with related records for documents (e.g. Standard Operating
> Procedures), PartNumber (we process machine parts, several of which may be
> related closely enough that they are covered by a single training session),
> trainers, and attendees.
>
> That said, I am curious too about the other tables the OP mentioned :-)
>
> Jerry Whittle wrote:
> >You shouldn't be creating a record in the other 4 tables unless there is a
> >real need for it.
> >
> >The best way to keep the tables linked is to first join them in the
> >Relationships Window with Referential Integrity enabled. Next create a form
> >based on the tblProjID table. On this form put subforms based on the other
> >tables.
> >
> >It's pretty unusual to have one table linked to 4 other tables in a
> >hub-and-spoke configuration. What is in the other tables?
> >> In an Access 2007 db, I have 5 tables, with Proj_No the Primary Key field in
> >> the main table tblProjID. It has 7 additional fields.

> >[quoted text clipped - 5 lines]
> >> Thank you
> >> Marsh

>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/For...arted/201004/1
>
> .
>

 
Reply With Quote
 
Marsh
Guest
Posts: n/a
 
      22nd Apr 2010
There were overriding reasons why I needed multiple tables, related as spokes
of a wheel. I like your analogy and will "borrow it" for our next project
meeting.
It had to do with the who/how data entry is to be done, with a form(s) in
individual front ends, differing as job description varies.
It is very possible that better design could be accomplished by someone with
more experience than I, and as I continue my growth with DB skills, I will
improve on past designs.

"Jerry Whittle" wrote:

> Hi Bruce,
>
> You are correct that there can be many valid reasons for having that many
> child tables. Probably because this is the New Users forum, I assumed (and we
> know what that can mean) the the OP might have been doing something like a
> table for each year or something.
>
> Thanks for keeping me honest!
> --
> Jerry Whittle, Microsoft Access MVP
> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
>
>
> "BruceM via AccessMonster.com" wrote:
>
> > Not meaning to be excessively picky, and with respect for your knowledge and
> > experience as demonstrated by your posts over the years, is it unusual to
> > have four child tables? I have at least one database with four, and several
> > with three, and I don't think I'm operating at an especially sophisticated
> > level as such things go.
> >
> > As an example of four child tables, a training database has a main Training
> > Session record, with related records for documents (e.g. Standard Operating
> > Procedures), PartNumber (we process machine parts, several of which may be
> > related closely enough that they are covered by a single training session),
> > trainers, and attendees.
> >
> > That said, I am curious too about the other tables the OP mentioned :-)
> >
> > Jerry Whittle wrote:
> > >You shouldn't be creating a record in the other 4 tables unless there is a
> > >real need for it.
> > >
> > >The best way to keep the tables linked is to first join them in the
> > >Relationships Window with Referential Integrity enabled. Next create a form
> > >based on the tblProjID table. On this form put subforms based on the other
> > >tables.
> > >
> > >It's pretty unusual to have one table linked to 4 other tables in a
> > >hub-and-spoke configuration. What is in the other tables?
> > >> In an Access 2007 db, I have 5 tables, with Proj_No the Primary Key field in
> > >> the main table tblProjID. It has 7 additional fields.
> > >[quoted text clipped - 5 lines]
> > >> Thank you
> > >> Marsh

> >
> > --
> > Message posted via AccessMonster.com
> > http://www.accessmonster.com/Uwe/For...arted/201004/1
> >
> > .
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Do I have to set the primary key to include primary key fields? boooney Microsoft Access Database Table Design 3 15th Apr 2010 12:17 AM
Data Primary key vs. Artificial (Autonumber) primary key M. Microsoft Access Database Table Design 78 14th Dec 2007 10:10 AM
Cascade updates on primary keys.. Aaron Smith Microsoft VB .NET 7 5th Jan 2005 04:54 AM
Cascade updates on primary keys.. Aaron Smith Microsoft ADO .NET 7 5th Jan 2005 04:54 AM
Cannot add primary key constraint since primary key is already set for the table Microsoft VB .NET 1 3rd Dec 2003 02:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:43 AM.