× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I have always tried to do normalized tables (except where performance might be an issue) but recently I just read that for tables that could be used by BI or query packages and by end-users and are being built just for that purpose (e.g. a data warehouse) that you should not normalize too much as it just makes it more confusing for the end-user to need to know how to join all the tables together.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Nathan Andelin
Sent: Thursday, October 08, 2009 1:09 PM
To: Midrange Systems Technical Discussion
Subject: Re: SQL Table Design

That looks good. The only other thing that comes to mind is that some folks add a sequence_number integer to allow sub-categories to be sequenced within category.

-Nathan.



----- Original Message ----
From: James Perkins <jrperkinsjr@xxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Sent: Thu, October 8, 2009 9:58:13 AM
Subject: Re: SQL Table Design

Thanks to all that replied. I think you have all solidified that the old
non-normalized database table should be a thing of the past :-) Just what I
wanted to here.

So here is the DDL for my table:
CREATE TABLE WEBVISION.ITEM_CATEGORIES (
CATEGORY_ID FOR CAT_ID INTEGER ,
CATEGORY_DESCRIPTION FOR CAT_DESC VARCHAR (128) ,
PARENT_CATEGORY_ID FOR P_CAT_ID INTEGER DEFAULT NULL ,
INCLUDE_CATEGORY FOR INC_CAT CHARACTER (1),
PRIMARY KEY (CATEGORY_ID),
CHECK(INCLUDE_CATEGORY IN('N', 'Y')) )
NOT VOLATILE RCDFMT ITEMCATR ;

Here is the SQL statement to find the children categories.

WITH temp_cat(category_id, parent_category_id, iteration) AS (
SELECT item_cat.category_id, item_cat.parent_category_id, 0
FROM mylib.item_categories AS item_cat
WHERE item_cat.category_id = ?
UNION ALL
SELECT item_cat.category_id, item_cat.parent_category_id, temp.iteration
+ 1
FROM webvision.item_categories AS item_cat
JOIN temp_cat AS temp ON temp.category_id = item_cat.parent_category_id)

SELECT *
FROM temp_cat

--
James R. Perkins
http://twitter.com/the_jamezp

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.