Normalizing a MYQL database

Robert Mann robmann at gp-racing.com
Thu Jan 4 17:28:02 CST 2007


Ok did some searching on "transpose columns into rows"
There seems to be some way of doing this using SQL but it is above my sql
knowledge, I found this example I just don't know how to change to input the
columns into a new table anyone know how to do this? I would prefer to have
the new table created by this same sql statement if possible. 

----------------------------
ID     Attribute     Value
----------------------------
10    username    user1
10    password    pass1
11    username    user2
11    password    pass2
---------------------------

I want to rotate this table as follows:
--------------------------------
ID     username    password
--------------------------------
10    user1          pass1
11    user2          pass2
--------------------------------

Select T1.ID, T1.Value as UserName, T2.Value as Password from TableName T1
Inner Join TableName T2 On T1.ID = T2.ID And T2.Attribute = 'password'
Where T1.Attribute = 'username'


Thanks
Rob

-----Original Message-----
From: valentina-bounces at lists.macserve.net
[mailto:valentina-bounces at lists.macserve.net] On Behalf Of Ruslan Zasukhin
Sent: Thursday, January 04, 2007 5:03 PM
To: valentina at lists.macserve.net
Subject: Re: Normalizing a MYQL database

On 07/4/1 11:58 PM, "Robert Mann" <robmann at gp-racing.com> wrote:

> Ok then if I create the new normalized tables how I will I get the
existing
> data in the right table locations and matched up to the FK and labels?

Almost unsolvable task ...

    Because you need rotate your columns into records.

May be exists some tools for such redo for mySQL
But I doubt. Try make google.



-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]


_______________________________________________
Valentina mailing list
Valentina at lists.macserve.net
http://lists.macserve.net/mailman/listinfo/valentina



More information about the Valentina mailing list