A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Splitting a table



 
 
Thread Tools Display Modes
  #1  
Old March 8th, 2009, 01:09 AM posted to microsoft.public.access.tablesdbdesign
sammie
external usenet poster
 
Posts: 45
Default Splitting a table

I want to split out the field TrackingNumber from the table Shipments into a
new table called Consignments. There are a number of other fields related to
the TrackingNumber such as weight, dimensions and ShipDate that should also
be a part of the consignments table. The relationship is many shipments to 1
tracking number
My problems:
1) not every record in the table Shipments has a tracking number
2) Some records in the new Consignments table without a tracking number have
other data in them, and still should be linked to the shipment.

What is the best way to split the table?
Thanks.
Sammie SBS 2003, OFFICE 2003, XP-PRO-SP3, IE7
  #2  
Old March 8th, 2009, 01:32 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default Splitting a table

So one tracking number covers many shipments, but a one shipment will never
be broken into multiple tracking numbers.

You already have the Shipment table, and the TrackingNumber. One approach
would be to add a TrackNumberID field (type Number) to the Shipment table.
It starts out null (so you will need to remove the zero as default value for
this number field. At the point when you put the shipment into the tracking
number, you assign the relevant tracking number to the shipment.

Create a relationship between the primary key of TrackingNumber and
Shipment.TrackNumber. Thus, one tracking number covers multiple shipments.
Use referential integrity. (Even with RI, Access allows the Null in the
foriegn key.)

--
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.

"Sammie" wrote in message
news
I want to split out the field TrackingNumber from the table Shipments into
a
new table called Consignments. There are a number of other fields related
to
the TrackingNumber such as weight, dimensions and ShipDate that should
also
be a part of the consignments table. The relationship is many shipments
to 1
tracking number
My problems:
1) not every record in the table Shipments has a tracking number
2) Some records in the new Consignments table without a tracking number
have
other data in them, and still should be linked to the shipment.

What is the best way to split the table?
Thanks.
Sammie SBS 2003, OFFICE 2003, XP-PRO-SP3, IE7


  #3  
Old March 8th, 2009, 05:28 PM posted to microsoft.public.access.tablesdbdesign
sammie
external usenet poster
 
Posts: 45
Default Splitting a table

Thanks, Allen. Your word "never" got my attention, and I should have thought
it through better. I guess occasionally one shipment will be broken into
multiple tracking numbers. Can you modify your response for me in that case?
--
Thanks.
Sammie SBS 2003, OFFICE 2003, XP-PRO-SP3, IE7


"Allen Browne" wrote:

So one tracking number covers many shipments, but a one shipment will never
be broken into multiple tracking numbers.

You already have the Shipment table, and the TrackingNumber. One approach
would be to add a TrackNumberID field (type Number) to the Shipment table.
It starts out null (so you will need to remove the zero as default value for
this number field. At the point when you put the shipment into the tracking
number, you assign the relevant tracking number to the shipment.

Create a relationship between the primary key of TrackingNumber and
Shipment.TrackNumber. Thus, one tracking number covers multiple shipments.
Use referential integrity. (Even with RI, Access allows the Null in the
foriegn key.)

--
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.

"Sammie" wrote in message
news
I want to split out the field TrackingNumber from the table Shipments into
a
new table called Consignments. There are a number of other fields related
to
the TrackingNumber such as weight, dimensions and ShipDate that should
also
be a part of the consignments table. The relationship is many shipments
to 1
tracking number
My problems:
1) not every record in the table Shipments has a tracking number
2) Some records in the new Consignments table without a tracking number
have
other data in them, and still should be linked to the shipment.

What is the best way to split the table?
Thanks.
Sammie SBS 2003, OFFICE 2003, XP-PRO-SP3, IE7



  #4  
Old March 9th, 2009, 01:16 AM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default Splitting a table

If you do need to handle both ways, you have a many-to-many relation.

So, instead of a TrackNumberID in the Shipment table, you need to create a
junction table. The new table will have fields:
- TrackNumberID relates to the primary key of the TrackingNumber table
- ShipmentID relates to the primary key of the Shipment table

To assign shipment 99 to tracking numbers 22 and 23, you create 2 records in
this table:
22 99
23 99

--
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.

"Sammie" wrote in message
...
Thanks, Allen. Your word "never" got my attention, and I should have
thought
it through better. I guess occasionally one shipment will be broken into
multiple tracking numbers. Can you modify your response for me in that
case?
--
Thanks.
Sammie SBS 2003, OFFICE 2003, XP-PRO-SP3, IE7


"Allen Browne" wrote:

So one tracking number covers many shipments, but a one shipment
will never be broken into multiple tracking numbers.

You already have the Shipment table, and the TrackingNumber. One
approach would be to add a TrackNumberID field (type Number) to the
Shipment table. It starts out null (so you will need to remove the zero
as
default value for this number field. At the point when you put the
shipment into the tracking number, you assign the relevant tracking
number to the shipment.

Create a relationship between the primary key of TrackingNumber and
Shipment.TrackNumber. Thus, one tracking number covers multiple .
shipmentsUse referential integrity. (Even with RI, Access allows the Null
in the foriegn key.)

"Sammie" wrote in message
news
I want to split out the field TrackingNumber from the table Shipments
into a new table called Consignments. There are a number of other
fields related to the TrackingNumber such as weight, dimensions
and ShipDate that should also be a part of the consignments table.
The relationship is many shipments to 1tracking number.
My problems:
1) not every record in the table Shipments has a tracking number
2) Some records in the new Consignments table without a tracking
number have other data in them, and still should be linked to the
shipment.
What is the best way to split the table?
Thanks.
Sammie SBS 2003, OFFICE 2003, XP-PRO-SP3, IE7


 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.