RE: Data Modeling Question

From: Powell, Mark D <>
Date: Thu, 7 Feb 2008 09:22:53 -0500
Message-ID: <>


Unless your application normally only needs to retrieve a single attribute for an item_code per transaction just add a second attribute table to you application to handle attributes 1001+

Doing this will almost certainly result in better query performance than using a parameter/value attribute table. I say this because we have a vendor provided statistical process system build on just such a scheme. Inserts are great but query performance is not so great.

  • Mark D Powell -- Phone (313) 592-5148

-----Original Message-----
[] On Behalf Of Ahbaid Gaffoor Sent: Wednesday, February 06, 2008 10:52 PM To: oracle-l
Subject: Data Modeling Question

We have a data model which looks like the following:


ITEM_CODE              VARCHAR2(100)     (Primary Key col 1)
ITEM_TYPE               VARCHAR2(100)
ATTRIBUTE_001       VARCHAR2(4000)
ATTRIBUTE_002       VARCHAR2(4000)
ATTRIBUTE_250       VARCHAR2(4000)


ITEM_TYPE VARCHAR2(100) (Primary Key col 1) ATTRIBUTE_NAME VARCHAR2(1000) (Primary Key col 2) ATTRIBUTE_COLNUM NUMBER It's a developer's dream of how we can store attributes for an item, the item type is used to decide which column holds what attributes by storing that metadata in the ITEM_TYPE_LU table. Initially, some 7 years ago the developer only dreamed of no more than 10 attributes per item. Today there are 205 attributes, some fields hold data that's a few characters and some the full 4000 characters.

I informed the development team that we face a max number of columns (1000 when I tested on

Now we are undertaking a redesign to provide a data model that allows us to store an unlimited number of attributes.

The ideas we have in mind so far are:

  1. Switch to a row based schema, so the two tables become one, each attribute and its value taking a row for an item.


ITEM_CODE                VARCHAR2(100)     (Primary Key col 1)

ATTRIBUTE_VALUE VARCHAR2(4000) So a single item would look as follows:


shoe-001   size   10
shoe-001   color   brown
shoe-001   price   15.45
shoe-001   manufacturer   clarks

2) Use a CLOB column and store an XML document in it with all information:


ITEM_CODE                VARCHAR2(100)     (Primary Key col 1)
ITEM_XML                  CLOB

SELECT * from ITEMS where ITEM_CODE = 'shoe-001';

---------- --------------------------------------------------
shoe-001   <item>

3) Use Oracle's XML data types (not sure how this works)

I am partial to the first approach since I would be able to easily parse data when a business request needs it, also I can make use of Oracle partitioning to improve performance.

One other point to consider is that single attributes can be updated for an item, in the row based model this is simple, however in the CLOB based solution I am concerned that we need to replace the entire CLOB for a single attribute value change.

What I'd like is any advice pros / cons of the CLOB (approach 2) and the XML type (approach 3) solutions.

For scale, we are looking at close to 200 million items, each item having about 150 attributes each.

I am proceeding with approach 1 for now.

many thanks for your input



Received on Thu Feb 07 2008 - 08:22:53 CST

Original text of this message