Groups | Blog | Home
all groups > sql server programming > november 2004 >

sql server programming : transform data


Joe Celko
11/11/2004 3:25:58 PM
[quoted text, click to view]

1) This is not even in First Normal Form; you have domain violations and
metadata in this thing. This error is called EAV
(Entity-Attribute-Value) design.

2) Rows are not records. Failure to understand basic concept leads to
problems like this. You simply copied the way you would make a list on
paper into a pseudo-table.

3) Please post real DDL in the future. Your personal narrative is
useless. We have no way of getting the name of the event to which the
begining and ending dates. There is no way to be sure that each
begindate has any enddate and vice versa.

If they alternate odd/even:

SELECT F1.begindate, F2.enddate
FROM Foobar AS F1, Foobar AS F2
WHERE F1.id = F2.id -1;

Throw out this crap and get some help with the design.

--CELKO--
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are. Sample data is also a good idea, along with clear
specifications.


*** Sent via Developersdex http://www.developersdex.com ***
Ezekiël
11/11/2004 11:00:53 PM
Hello,

I've a normalized table where i store items as records like:

id | type | value
1 | begindate | 01-01-2004
2 | enddate | 31-01-2004
etc...

How can i transform it so that the data looks like this:

begindate | enddate
01-01-2004 | 31-01-2004

Can this be done within sql server?

AddThis Social Bookmark Button