tags:

views:

53

answers:

3

Hi all,

According to normal way, we design the table with fields. Example with an article the table can contain fields as follows: title, content, author.....

But how does everybody think if we add up some fields to a field?

+3  A: 

Holding multiple values in a column is a bad idea. It breaks 1st Normal form.

Mitch Wheat
A: 

I think you mean:

MyTable
-------
int FieldA
int FieldB
int FieldSum

Where FieldSum is a calculated field, defined as the sum of FieldA and FieldB.

Is that correct?

Or do you mean changing this:

MyTable
-------
char LicensePlate
char Make
char Model

to this:

MyTable
-------
char LicensePlate
char MakeAndModel

In that case: why?

egrunin
Sounds like what he meant, but is there an advantage of doing this instead of using SUM?
Pier-Luc Gendreau
in such a case I would prefer to add not the field "FieldSum". By calculating itself (e.g. in C++) this can have a good effect on calculation time.If the sum is really required for searching within the DB, this might be helpful, instead of using aggregate functions like SUM().But this decision depends on the numbers of rows and the programming language.So I wouldn't suggest this in general.
poeschlorn
@Pier-Luc, @poeschlorn: this is a trivial example, we still don't know what the OP really has in mind.
egrunin
A: 

Your question is a bit confusing but if you are trying to hold multiple values in a field Mitch is right. If you REALLY have to do it you could use an XML column.

Here is a link to XML Support information for SQL Server 2005.

Abe Miessler