473,787 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Flattening relationship tables

Consider first, table "A" :

Plate Make Model
=============== ======
ABC123 Ford F150
XYZ789 Dodge 1500
IJK444 Chev Silverado

Then consider, table "B";

Plate City Start End Person
=============== =============== =============== ============
ABC123 New York 5-May-99 12-Dec-00 DOE, John
ABC123 Seattle 17-Dec-00 31-Mar-01 SMITH, Frank
ABC123 Pittsburgh 4-Apr-01 5-May-03 JONES, Hank
XYZ789 Los Angeles 3-Mar-03 17-Apr-04 SIMPSON, Bart
XYZ789 Detroit 21-Apr-04 31-Dec-05 RODMAN, Dennis
IJK444 Miami 14-Jul-06 17-Jul-06 SIMPSON, OJ
IJK444 Chigaco 29-Aug-06 2-Oct-06 GROUCH, Oscar
IJK444 Cincinatti 4-Oct-06 12-Dec-06 DAHMER, Jeffrey
IJK444 Wichita 25-Dec-06 1-May-07 DOBBS, Bob (Jr)

Tables A and B are relationship tables, joined-up by the plate
column.

Now assume that there are only nine different places that the vehicles
in our database could possibly be. That is, New York, Seattle,
Pittsburgh, Los Angeles, Detroit, Miami, Chicago, Cincinatti, and
Wichita.

Question:

How does one 'flatten' these two relationship tables to obtain the
following query output?:

Plate Make Model a b c d e f g h i j k l m n o p q r s t u v w x
y z z'
=============== =============== =============== =============== =============== =
ABC123 Ford F150
XYZ789 Dodge 1500
IJK444 Chev Silverado

ie) Only one record in the new table for each plate. (I didn't fill-
in the 'guts' content of the table obviously).

For the sake of fitting this on the screen, here are the new fields:

NewYorkStart a
NewYorkEnd b
NewYorkPerson c
SeattleStart d
SeattleEnd e
SeattlePerson f
PittsburghStart g
PittsburghEnd h
PittsburghPerso n i
LAStart j
LAEnd k
LAPerson l
DetroitStart m
DetroitEnd n
DetroietPerson o
MiamiStart p
MiamiEnd q
MiamiPerson r
ChicagoStart s
ChicagoEnd t
ChicagoPerson u
CincinattiStart v
CincinattiEnd w
CincinattiPerso n x
WichitaStart y
WichitaEnd z
WichitaPerson z'

I know that it's crazy to flatten a perfectly-good relationship table,
but here's my rationale. I am using a front-end for the interface
that can only handle a single table at a time. I need to get a few
thousand records of legacy data loaded into the new database. I don't
need realtime/dynamic feed-over. Just a one-time feedover method.

I am open to any solutions using SQL, MS Access, or MS Excel.

Thanks.

May 8 '07 #1
2 2618
On May 8, 1:14 am, cspow...@shaw.c a wrote:
Consider first, table "A" :

Plate Make Model
=============== ======
ABC123 Ford F150
XYZ789 Dodge 1500
IJK444 Chev Silverado

Then consider, table "B";

Plate City Start End Person
=============== =============== =============== ============
ABC123 New York 5-May-99 12-Dec-00 DOE, John
ABC123 Seattle 17-Dec-00 31-Mar-01 SMITH, Frank
ABC123 Pittsburgh 4-Apr-01 5-May-03 JONES, Hank
XYZ789 Los Angeles 3-Mar-03 17-Apr-04 SIMPSON, Bart
XYZ789 Detroit 21-Apr-04 31-Dec-05 RODMAN, Dennis
IJK444 Miami 14-Jul-06 17-Jul-06 SIMPSON, OJ
IJK444 Chigaco 29-Aug-06 2-Oct-06 GROUCH, Oscar
IJK444 Cincinatti 4-Oct-06 12-Dec-06 DAHMER, Jeffrey
IJK444 Wichita 25-Dec-06 1-May-07 DOBBS, Bob (Jr)

Tables A and B are relationship tables, joined-up by the plate
column.

Now assume that there are only nine different places that the vehicles
in our database could possibly be. That is, New York, Seattle,
Pittsburgh, Los Angeles, Detroit, Miami, Chicago, Cincinatti, and
Wichita.

Question:

How does one 'flatten' these two relationship tables to obtain the
following query output?:

Plate Make Model a b c d e f g h i j k l m n o p q r s t u v w x
y z z'
=============== =============== =============== =============== =============== *=
ABC123 Ford F150
XYZ789 Dodge 1500
IJK444 Chev Silverado

ie) Only one record in the new table for each plate. (I didn't fill-
in the 'guts' content of the table obviously).

For the sake of fitting this on the screen, here are the new fields:

NewYorkStart a
NewYorkEnd b
NewYorkPerson c
SeattleStart d
SeattleEnd e
SeattlePerson f
PittsburghStart g
PittsburghEnd h
PittsburghPerso n i
LAStart j
LAEnd k
LAPerson l
DetroitStart m
DetroitEnd n
DetroietPerson o
MiamiStart p
MiamiEnd q
MiamiPerson r
ChicagoStart s
ChicagoEnd t
ChicagoPerson u
CincinattiStart v
CincinattiEnd w
CincinattiPerso n x
WichitaStart y
WichitaEnd z
WichitaPerson z'

I know that it's crazy to flatten a perfectly-good relationship table,
but here's my rationale. I am using a front-end for the interface
that can only handle a single table at a time. I need to get a few
thousand records of legacy data loaded into the new database. I don't
need realtime/dynamic feed-over. Just a one-time feedover method.

I am open to any solutions using SQL, MS Access, or MS Excel.

Thanks.
You need to redesign your front end to properly use a relational
database. Hint, subforms are your friend!

May 9 '07 #2

<cs******@shaw. cawrote in message
news:11******** **************@ y5g2000hsa.goog legroups.com...
Consider first, table "A" :

Plate Make Model
=============== ======
ABC123 Ford F150
XYZ789 Dodge 1500
IJK444 Chev Silverado

Then consider, table "B";

Plate City Start End Person
=============== =============== =============== ============
ABC123 New York 5-May-99 12-Dec-00 DOE, John
ABC123 Seattle 17-Dec-00 31-Mar-01 SMITH, Frank
ABC123 Pittsburgh 4-Apr-01 5-May-03 JONES, Hank
XYZ789 Los Angeles 3-Mar-03 17-Apr-04 SIMPSON, Bart
XYZ789 Detroit 21-Apr-04 31-Dec-05 RODMAN, Dennis
IJK444 Miami 14-Jul-06 17-Jul-06 SIMPSON, OJ
IJK444 Chigaco 29-Aug-06 2-Oct-06 GROUCH, Oscar
IJK444 Cincinatti 4-Oct-06 12-Dec-06 DAHMER, Jeffrey
IJK444 Wichita 25-Dec-06 1-May-07 DOBBS, Bob (Jr)

Tables A and B are relationship tables, joined-up by the plate
column.

Now assume that there are only nine different places that the vehicles
in our database could possibly be. That is, New York, Seattle,
Pittsburgh, Los Angeles, Detroit, Miami, Chicago, Cincinatti, and
Wichita.

Question:

How does one 'flatten' these two relationship tables to obtain the
following query output?:

Plate Make Model a b c d e f g h i j k l m n o p q r s t u v w x
y z z'
=============== =============== =============== =============== =============== =
ABC123 Ford F150
XYZ789 Dodge 1500
IJK444 Chev Silverado

ie) Only one record in the new table for each plate. (I didn't fill-
in the 'guts' content of the table obviously).

For the sake of fitting this on the screen, here are the new fields:

NewYorkStart a
NewYorkEnd b
NewYorkPerson c
SeattleStart d
SeattleEnd e
SeattlePerson f
PittsburghStart g
PittsburghEnd h
PittsburghPerso n i
LAStart j
LAEnd k
LAPerson l
DetroitStart m
DetroitEnd n
DetroietPerson o
MiamiStart p
MiamiEnd q
MiamiPerson r
ChicagoStart s
ChicagoEnd t
ChicagoPerson u
CincinattiStart v
CincinattiEnd w
CincinattiPerso n x
WichitaStart y
WichitaEnd z
WichitaPerson z'

I know that it's crazy to flatten a perfectly-good relationship table,
but here's my rationale. I am using a front-end for the interface
that can only handle a single table at a time. I need to get a few
thousand records of legacy data loaded into the new database. I don't
need realtime/dynamic feed-over. Just a one-time feedover method.

I am open to any solutions using SQL, MS Access, or MS Excel.

Thanks.
Your should be able to build a query to join the 2 tables and format the
data for your other program. Then use that query to export the data.
May 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
7437
by: Andante.in.Blue | last post by:
Hello, I have just inherited a legacy Access 97 database. While going through it, I noticed something strange... its Relationships window (the one accessed by Tools --> Relationships) is almost empty. Now, as I ponder how a relation database could work without any relationships, I noticed that the queries of the database defined some relationships between the source tables and queries. Which leads me to the question, what is the...
2
2066
by: Marco Simone | last post by:
Hi, I have 4 tables, tblCompany, tblA, tblB and tblC. tblA, tblB and tblC contain same type of data, they should be in one table, but since there are many fields, I split it into 3 tables. Each Company can have many records in tblA, so relationship between tblCompany and tblA, tblB and tblC are 'one to many'. tblA, tblB and tblC are in relationship 'one to one' tblCompany has primary key CompanyID tblA, tblB and tblC has same primary...
2
1939
by: Robert Jacobson | last post by:
Hi, If I have an XML file that stores its data in a hierarchical relationship, is there a way to automatically "flatten" this relationship when I deserialize it (using the XmlSerializer) to a collection of objects? For example, assume that I have an XML file that contains the following data for lastnames/firstnames: Anderson
5
2396
by: BrianDP | last post by:
This is a strange one-- I have an Access 2K database with a split front end/back end. There are two tables in the back end - RFile and RLine. There is a one to many relationship from Rfile.Rnumber to Rline.Rnumber. Originally I went in with the Relationships window, drew the line, and clicked the cascading updates and deletes. Everything was fine, for a couple of years. All of the sudden however, this relationship seems to delete...
2
1635
by: gangesmaster | last post by:
as we all know, * (asterisk) can be used to "inline" or "flatten" a tuple into an argument list, i.e.: def f(a, b, c): ... x = (1,2,3) f(*x) so... mainly for symmetry's sake, why not make a "flattening" operator that also works outside the context of function calls? for example:
0
1274
by: wilko | last post by:
Hi, Does anybody have any design ideas for flattening multiple measurement records into fact table columns. Our current design imports the measurement records into a staging table and then uses a set of mappings to select the appropriately grouped measurements into the correct structure for inserting into the fact table. The source measurments are identified by a business ID and they are mapped to different columns in the fact table. ie....
10
4457
by: Richard | last post by:
Hi folks, thanks for taking the time to read this (and hopefully point our where I'm going wrong). The scenario: I have a local Access2007 database which links in several read only mySql tables via ODBC. The problem:
4
1854
by: Phil Stanton | last post by:
Having spent ages sorting out the layout of my relationship window with about 60 tables and getting it all tidy and with enough of the tables visible to show the PK an FK relaionshipsOn a subseqent occassion, on opening the relationship window, I found all the tables had shrunk so that in most cases, only the table names were visible and the fields could only be seen by "expanding" the table again. I know you can print out the relationship...
6
4061
by: NicoleCartrette | last post by:
Going back to school is easier said than done.. This was posted to an older thread earlier but I don't think it got any attention. Your help is appreciated Professor requires we create a simple database and specified what are to be the primary keys and relationships etc. I have created the four tables and established the neccessary one to many and many to one relationships between primary keys in the tables with the exception of one...
0
9655
marktang
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...
0
10363
Oralloy
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...
0
10172
jinu1996
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...
0
9964
tracyyun
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...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
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...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.