If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Content Manager - adding multiple attribute values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-16-06, 11:02
hnhegde hnhegde is offline
Registered User
 
Join Date: Aug 2006
Posts: 6
Content Manager - adding multiple attribute values

Hi,

We have an item which contains account information as attributes e.g, account number, acct name, itemid, date etc. Is it possible to add multiple values to an attribute? If yes, how? Specifically, I would like to add multiple account numbers to an account name.
Pls. advise...
Reply With Quote
  #2 (permalink)  
Old 10-18-06, 04:47
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,279
Your system wouldn't be even in Normal Form 0 if you would store multiple values in one filed.

Redesign your datamodel.

Go from

TABLE account_item
name VARCHAR(50),
account INTEGER,
....

(with no way to store or retrieve multiple values into/from one INTEGER field. You would have to rely on a CHAR or VARCHAR field to store multiple values, you would also have to convert the number to and from a string to store or retrieve the value, how would you access the third value, .... a real nightmare)

to

TABLE account_item
ID INTEGER,
name VARCHAR(50),
....
with primary key (ID)

TABLE account_item_accNr
ID_account_item INTEGER,
nr_account INTEGER,
....
with primary key (ID_account_item, nr_account)
and foreign key (ID_account_item) that references account_item (ID)

For each account number you want to store, you just add one account_item_accNr record that references to the correct account_item record.

Going from your problem to this solution is a basic datamodelling skill. I'd recommend reading a good book about datamodelling or taking a course. It's not that hard to learn, but you really should master it before proceeding.

You should really have a good grab about normalising tables before doing anything in a production environment. Otherwise you will hit the wall and you will hit it hard. A normalised datamodel is easy(er) to expand, modify, update, query, ... , anything else will make it LOTS and lots harder.
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #3 (permalink)  
Old 10-18-06, 09:04
hnhegde hnhegde is offline
Registered User
 
Join Date: Aug 2006
Posts: 6
Hi Wim,
Thanks for the reply. I appreciate your effort in providing a detailed reply to my question.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On