Generating crosstab-like tables dynamically
From: John Hoge (jhoge123_at_yahoo.com)
Date: 11/30/04
- Next message: raydan: "Re: create a procedure in other server"
- Previous message: Louis Davidson: "Re: Choose function"
- Next in thread: Anith Sen: "Re: Generating crosstab-like tables dynamically"
- Reply: Anith Sen: "Re: Generating crosstab-like tables dynamically"
- Reply: Pike: "Re: Generating crosstab-like tables dynamically"
- Messages sorted by: [ date ] [ thread ]
Date: 30 Nov 2004 10:24:19 -0800
I'm working on a product comparison site that has a table listing all
attributes of all products in this layout:
Create Table ProdAtt(
Product varchar(50),
AttributeID int not null references Attributes,
AttVal varchar(255)
)
This schema is used so that DML is not required to add new attributes
- No table columns need to be added if a site admin wants to add a new
product feature, say heated seats. They just add a new entry to the
attribute table and then add rows to the ProdAtt table to record which
cars have this feature.
The data looks like this:
FORD COLOR BLUE
FORD TRANSMISSION AUTOMATIC
CHEVY COLOR RED
CHEVY TRANSMISSION MANUAL
....
Say the visitor wants to see a comparison between Ford and Chevy. I
would like to use an .net DataGrid to display the data, so it would be
great to have a table like this:
Product Ford Chevy
Transmission Automatic Standard
Color Blue Red
Before .net I would just manually build an html table from the
normalized data as it came out of the database table, but the this
technique would miss out on the presentation layer nicities of the
DataGrid control such as paging and sorting.
It seems like a fairly common problem, so there must be a best
practice for transforming a table this way. Any guess?
- Next message: raydan: "Re: create a procedure in other server"
- Previous message: Louis Davidson: "Re: Choose function"
- Next in thread: Anith Sen: "Re: Generating crosstab-like tables dynamically"
- Reply: Anith Sen: "Re: Generating crosstab-like tables dynamically"
- Reply: Pike: "Re: Generating crosstab-like tables dynamically"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|