Re: How do we create Multiple hierarchies in sql 200 as -
03-18-2005
, 06:34 PM
Look up the nested set model for hierarchies or (better) buy a copy of
my book TREES & HIERARCHIES IN SQL. Each zip code grouping will be in
a table that looks like this:
CREATE TABLE AlphaRegions
(region_name CHAR(10) NOT NULL PRIMARY KEY,
start_zip CHAR(5) NOT NULL,
end_zip CHAR(5) NOT NULL,
CHECK (start_zip <= end_zip));
CREATE TABLE BetaRegions
(region_name CHAR(10) NOT NULL PRIMARY KEY,
start_zip CHAR(5) NOT NULL,
end_zip CHAR(5) NOT NULL,
CHECK (start_zip <= end_zip));
Etc. You can do any reporting hierarchy you wish with these tables. |