Showing posts with label cell. Show all posts
Showing posts with label cell. Show all posts

Wednesday, March 21, 2012

multiple values per table cell?

I am converting a site from asp to .net and the previus writer did something I never saw.(I am somewhat new to programming all together). He put multiple values in a single cell of the database. I have always learned to use a seperate column for each value.
Is this a classic asp thing and there are better ways now? Or is this something I should do myself? The columns type is text and the contents look like this:
<Details Expertise="bla bla" Description="We are a three-divisional company ...," WebSite="www.blabla.com" AccountLevel="Free" AccountStatus="Active" WorkHomeZIP="22222" ContractStartDate="01/01/2003" ContractEndDate="12/31/2003"><Address Location="Work" State="Oh" ZIP="22222"/><Email Location="Work" Value=""/><Phone Location="Fax" Code="9801" Ext=""/></Details>
Putting aside the question of the style being used for a moment, the contents of the column is not *really* multiple values, but a single XML string. This allows it to be easily read into a XmlDocument object and parsed.

As for the reason behind this approach, the only one I can thing of would be to store dynamic categories of information that is not known at design time. While none come to mind immediately, I'm sure that there might be times when this approach is quite valid. It is *not*, however, a classic ASP thing, but a database design decision. As to whether you should change the approach, I would if the attributes in the XML string were always the same. Better to use a database to do what databases were intended to do ;)

HTH

Multiple values into single cell

Taking the Northwind database as an example,
I have an order table: 'Orders'
a order details table: 'Order Details'
and a products table: 'Products'

For reasons best ignored, I want to produce a query which has columns:

Orders.OrderID, Products

which has results like:

10248, 'Queso Cabrales, Singaporean Hokkien Fried Mee, Mozzarella di
Giovanni'
10249, 'Tofu, Manjimup Dried Apples'

________
so for those who don't really know what I'm on about and haven't got
access to northwind, I want the second cell to contain the returned
column of a second query (but in text format)

could anyone suggest a way this could be done? am I entering the land
of cursors?

Many thanks,
NeilNAJH (neilonusenet@.yahoo.co.uk) writes:

Quote:

Originally Posted by

For reasons best ignored, I want to produce a query which has columns:
>
Orders.OrderID, Products
>
>
which has results like:
>
10248, 'Queso Cabrales, Singaporean Hokkien Fried Mee, Mozzarella di
Giovanni'
10249, 'Tofu, Manjimup Dried Apples'
>
________
so for those who don't really know what I'm on about and haven't got
access to northwind, I want the second cell to contain the returned
column of a second query (but in text format)
>
could anyone suggest a way this could be done? am I entering the land
of cursors?


If you are on SQL 2000, yes. SQL Server MVP Anith Sen covers the various
methods on http://www.projectdmx.com/tsql/rowconcatenate.aspx.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||

Quote:

Originally Posted by

Quote:

Originally Posted by

>For reasons best ignored, ... <<


Do not ignore the reasons; so, why do you want to write stinking bad
code?|||--CELKO-- wrote:

Quote:

Originally Posted by

Quote:

Originally Posted by

Quote:

Originally Posted by

>>For reasons best ignored, ... <<


>
Do not ignore the reasons; so, why do you want to write stinking bad
code?


At least he isn't talking about storing the data that way, merely
outputting it that way. That said, I would do it in a separate
reporting layer (e.g. Crystal Reports) if at all possible.|||On May 21, 3:27 am, Ed Murphy <emurph...@.socal.rr.comwrote:

Quote:

Originally Posted by

--CELKO-- wrote:

Quote:

Originally Posted by

Quote:

Originally Posted by

>For reasons best ignored, ... <<


>

Quote:

Originally Posted by

Do not ignore the reasons; so, why do you want to write stinking bad
code?


>
At least he isn't talking about storing the data that way, merely
outputting it that way. That said, I would do it in a separate
reporting layer (e.g. Crystal Reports) if at all possible.


I know it's bad practice to do it that way and a seperate reporting
layer like crystal reports etc would be lovely, but I'm in a situation
where I don't have those kind of facilities and budgets at my
disposal. It's just a means to an end. I'm certainly not holding data
like that. It's bad enough dealing with internal politics without
having to deal with it again on here! Thanks to you all for your kind
(or not so kind) input.

Neil