473,394 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Need to "normalize" table

I currently have a spreadsheet tracking votes on legislation in a matrix
type
format. It is something like this

Name Act1 Veto1 Act1A
Jones yes No Yes
Johnson Yes Yes Ex.

Only with many more members and bills. I want to normalize this so
that i can create reports by both Bill and by member - linking it to tables
with bill descriptions and member profiles. I think what I want is a table
like this:

Name Act Vote
Jones Act1 Yes
Jones Veto1 No
Johnson Act1 Yes

I need help writing a function or a query that can do that.
Jan 24 '06 #1
4 1908
Nathan Benefield wrote:
I currently have a spreadsheet tracking votes on legislation in a matrix
type
format. It is something like this

Name Act1 Veto1 Act1A
Jones yes No Yes
Johnson Yes Yes Ex.

Only with many more members and bills. I want to normalize this so
that i can create reports by both Bill and by member - linking it to tables
with bill descriptions and member profiles. I think what I want is a table
like this:

Name Act Vote
Jones Act1 Yes
Jones Veto1 No
Johnson Act1 Yes

I need help writing a function or a query that can do that.


What's an Act, an Action (what type of action), the member is a
Actor...? Is the Vote on the Veto a vote to veto the bill ?? Wouldn't
that be a yea or nay vote on the bill itself?
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
Jan 24 '06 #2
An Act is and Act - passed and signed by the governor. The Vote on the Veto
is a vote to pass a bill which was passed and then vetoed.

"MGFoster" <me@privacy.com> wrote in message
news:1w****************@newsread1.news.pas.earthli nk.net...
Nathan Benefield wrote:
I currently have a spreadsheet tracking votes on legislation in a matrix
type
format. It is something like this

Name Act1 Veto1 Act1A
Jones yes No Yes
Johnson Yes Yes Ex.

Only with many more members and bills. I want to normalize this so
that i can create reports by both Bill and by member - linking it to
tables
with bill descriptions and member profiles. I think what I want is a
table
like this:

Name Act Vote
Jones Act1 Yes
Jones Veto1 No
Johnson Act1 Yes

I need help writing a function or a query that can do that.


What's an Act, an Action (what type of action), the member is a Actor...?
Is the Vote on the Veto a vote to veto the bill ?? Wouldn't that be a yea
or nay vote on the bill itself?
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

Jan 25 '06 #3
GH
Nathan,

Wouldn't it make more sense to have three tables, one to store the
members, one for the acts, and a join showing the member's vote?

It would look like:

MEMBER table
MemberID MemberName etc.
1 Jones
2 Johnson
etc.

ACT tables
ActID ActTitle etc.
1 Act1
2 Act1A
etc.

VoteTable
MemberID ActID VoteBit
1 1 Y
1 2 Y
2 1 N
etc.

(or something along these lines)

Anyway, I had to do something similar a while back where the table had
columns that really should have been rows in a different table. I
wrote a function that looped through the columns of the table and
looked for key naming structures then populated the new table with the
appropriate values. Of course, this assumes that the columns to be
normalized follow a structured naming convention that can easily be
converted to field values. Unfortunately, I cannot share the specific
function, as it is not available to me now, but the general concept is
to use the FOR EACH loop to loop through the columns of the table or
select the table schema from an ADO recordset.

Dim fld As Field
For Each fld In CurrentDB.TableDefs("YourTable").Fields
If [fld.Name condition to determine which columns to process]
Then
[Build and process a SQL string to update the data to
the new table structure]
End If
Next fld

OR

Dim rs As New ADODB.Recordset

Set rs= [YourADOConnection].OpenSchema(adSchemaColumns, Array(Empty,
Empty,
"YourTableName"))
While Not rs.EOF
If [rs!COLUMN_NAME condition to determine which columns
to process] Then
[Build and process a SQL string to update the data
to the new table structure]
End If
rs.MoveNext
Wend
rs.Close

I still had to customize my function due to irregularities in some
column names, but the names generally followed a pattern that could be
used within a CASE construct or IF statement to convert to field
values.

I hope this helps you.

- GH

Nathan Benefield wrote:
An Act is and Act - passed and signed by the governor. The Vote on the Veto
is a vote to pass a bill which was passed and then vetoed.

"MGFoster" <me@privacy.com> wrote in message
news:1w****************@newsread1.news.pas.earthli nk.net...
Nathan Benefield wrote:
I currently have a spreadsheet tracking votes on legislation in a matrix
type
format. It is something like this

Name Act1 Veto1 Act1A
Jones yes No Yes
Johnson Yes Yes Ex.

Only with many more members and bills. I want to normalize this so
that i can create reports by both Bill and by member - linking it to
tables
with bill descriptions and member profiles. I think what I want is a
table
like this:

Name Act Vote
Jones Act1 Yes
Jones Veto1 No
Johnson Act1 Yes

I need help writing a function or a query that can do that.


What's an Act, an Action (what type of action), the member is a Actor...?
Is the Vote on the Veto a vote to veto the bill ?? Wouldn't that be a yea
or nay vote on the bill itself?
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)


Jan 25 '06 #4
I have three tables, the first two - with member information and with Act
descriptions are done. My problem is with creating the third table in the
format needed. I have played around with the first function a bit, but
need less ambiguity, as my programming knowledge is limited. The table I am
starting from is called "house votes" with fields "Name" for legislator name
and fields for each act "Act 1" , "Act 98", "act 1A", "Veto 1", etc.

I have tried this, but get errors right away.

Function Field()
Dim fld As Field
For Each fld In CurrentDb.TableDefs("House Votes").Fields
If [fld.Name Not="Name"] Then
[SELECT fld.Name as "Act Number", Name As "Name", fld as
"Fld" INTO "Votes" ]
End If
Next fld
End Function
"GH" <bo**************@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Nathan,

Wouldn't it make more sense to have three tables, one to store the
members, one for the acts, and a join showing the member's vote?

It would look like:

MEMBER table
MemberID MemberName etc.
1 Jones
2 Johnson
etc.

ACT tables
ActID ActTitle etc.
1 Act1
2 Act1A
etc.

VoteTable
MemberID ActID VoteBit
1 1 Y
1 2 Y
2 1 N
etc.

(or something along these lines)

Anyway, I had to do something similar a while back where the table had
columns that really should have been rows in a different table. I
wrote a function that looped through the columns of the table and
looked for key naming structures then populated the new table with the
appropriate values. Of course, this assumes that the columns to be
normalized follow a structured naming convention that can easily be
converted to field values. Unfortunately, I cannot share the specific
function, as it is not available to me now, but the general concept is
to use the FOR EACH loop to loop through the columns of the table or
select the table schema from an ADO recordset.

Dim fld As Field
For Each fld In CurrentDB.TableDefs("YourTable").Fields
If [fld.Name condition to determine which columns to process]
Then
[Build and process a SQL string to update the data to
the new table structure]
End If
Next fld

OR

Dim rs As New ADODB.Recordset

Set rs= [YourADOConnection].OpenSchema(adSchemaColumns, Array(Empty,
Empty,
"YourTableName"))
While Not rs.EOF
If [rs!COLUMN_NAME condition to determine which columns
to process] Then
[Build and process a SQL string to update the data
to the new table structure]
End If
rs.MoveNext
Wend
rs.Close

I still had to customize my function due to irregularities in some
column names, but the names generally followed a pattern that could be
used within a CASE construct or IF statement to convert to field
values.

I hope this helps you.

- GH

Nathan Benefield wrote:
An Act is and Act - passed and signed by the governor. The Vote on the
Veto
is a vote to pass a bill which was passed and then vetoed.

"MGFoster" <me@privacy.com> wrote in message
news:1w****************@newsread1.news.pas.earthli nk.net...
> Nathan Benefield wrote:
>> I currently have a spreadsheet tracking votes on legislation in a
>> matrix
>> type
>> format. It is something like this
>>
>> Name Act1 Veto1 Act1A
>> Jones yes No Yes
>> Johnson Yes Yes Ex.
>>
>> Only with many more members and bills. I want to normalize this so
>> that i can create reports by both Bill and by member - linking it to
>> tables
>> with bill descriptions and member profiles. I think what I want is a
>> table
>> like this:
>>
>> Name Act Vote
>> Jones Act1 Yes
>> Jones Veto1 No
>> Johnson Act1 Yes
>>
>> I need help writing a function or a query that can do that.
>
> What's an Act, an Action (what type of action), the member is a
> Actor...?
> Is the Vote on the Veto a vote to veto the bill ?? Wouldn't that be a
> yea
> or nay vote on the bill itself?
> --
> MGFoster:::mgf00 <at> earthlink <decimal-point> net
> Oakland, CA (USA)

Jan 25 '06 #5

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

Similar topics

1
by: Daniel Lim | last post by:
When using XmlSerializer, I notice that it does not normalize the single quote and double quote characters, i.e. does not change ' to &apos; and " to &quot. However, it does normalize other...
7
by: Philip Nelson | last post by:
Folks, I've been exercising my mind recently about the complexities of implementing a "currency" data type within DB2 to cope with multiple currencies. A monetary value is often simply...
8
by: Rob Mazur | last post by:
Hi. I'm trying to create a query that pulls information from 3 seperate tables. Here's how I want it to work: User is prompted for SSN Table 1: SSN Name Gender
5
by: Colleyville Alan | last post by:
I need to import a spreadsheet into an Access table. The spreadsheet has performance for mutual funds for various periods. The problem is that if there is no info for a particular period, the...
4
by: lorirobn | last post by:
Hello, I'd be curious to hear other thoughts on my database and table design. My database is for 'space use' in a lodging facility - will hold all spaces, like rooms (lodging rooms, dining...
1
by: arnold | last post by:
Hi, I've been knocking my head against the wall trying to create an XSL transform to perform "normalizations" of a set of XML files that have a common structure. % XML file before transform
6
by: AndyL | last post by:
Hi, I have a lot of sources with mixed indentation typically 2 or 4 or 8 spaces. Is there any way to automatically convert them in let's say 4 spaces? Thx, A.
3
by: Macbane | last post by:
Hello All, This has been bugging me for too long. I have a database that records medical interventions. I am familiar with the theory behind normalisation but am unsure what to do with the...
9
by: Peter Bengtsson | last post by:
In UTF8, \u0141 is a capital L with a little dash through it as can be seen in this image: http://static.peterbe.com/lukasz.png I tried this: '' I was hoping it would convert it it 'L'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.