dbTalk Databases Forums  

A silly question ... just to clarify my concepts

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss A silly question ... just to clarify my concepts in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Learner
 
Posts: n/a

Default A silly question ... just to clarify my concepts - 06-20-2004 , 06:15 AM






Hi,

I have the following tables:

CREATE TABLE [tblGeography] (
[ZoneID] Int,
[ZoneName] [char] (10),
[StateID] Int,
[StateName] [char] (35),
[CityID] Int,
[CityName] [char] (50)
)


CREATE TABLE [tblCustomers] (
[CustCode] [varchar] (20) ,
[CustName] [varchar] (64),
[CityID] Int
)


The logic is as follows:

Zone
Quote:
-- State

-- City

What I want to do is "flatten" my data. I am thinking about creating a
view as follows:

1) Add the tables listed above
2) Link the CityID fields between the Two Tables
3) Add all fields from Customer table EXCEPT for the CITYID field
4) Add all Name fields (ZoneName, StateName, CityName) from Geography
table

Is my approach correct and will it yield the correct and desired
results? The reason for asking is because I don't recall exactly what I
did but while trying this out I got a much higher count(*) of customers
than the actual number of customers... I must have done something wrong


Anyway...I'll appreciate your help.

--
Thanks.


Reply With Quote
  #2  
Old   
Uri Dimant
 
Posts: n/a

Default Re: A silly question ... just to clarify my concepts - 06-20-2004 , 07:31 AM






Learner
Why not just to have each table for the data?
CREATE TABLE Zones
(
ZoneId INT NOT NULL PRIMARY KEY,
ZoneName VARCHAR(100) NOT NULL
)
CREATE TABLE States
(
StateId INT NOT NULL PRIMARY KEY,
StateName VARCHAR(100) NOT NULL
)
............

CREATE TABLE Customer_Details
(
CustCode INT NOT NULL REFERNCES Customers (CustCode ),
ZoneId INT NOT NULL REFERNCES Zones(ZoneId ),
StateId INT NOT NULL REFERNCES States(StateId ),..........
.........
CONSTRAINT uid_PK PRIMARY KEY (CustCode ,ZoneId .......) Modify it for your
needs
)

"Learner" <wantnospam (AT) email (DOT) com> wrote

Quote:
Hi,

I have the following tables:

CREATE TABLE [tblGeography] (
[ZoneID] Int,
[ZoneName] [char] (10),
[StateID] Int,
[StateName] [char] (35),
[CityID] Int,
[CityName] [char] (50)
)


CREATE TABLE [tblCustomers] (
[CustCode] [varchar] (20) ,
[CustName] [varchar] (64),
[CityID] Int
)


The logic is as follows:

Zone
|
|-- State
|
|-- City


What I want to do is "flatten" my data. I am thinking about creating a
view as follows:

1) Add the tables listed above
2) Link the CityID fields between the Two Tables
3) Add all fields from Customer table EXCEPT for the CITYID field
4) Add all Name fields (ZoneName, StateName, CityName) from Geography
table

Is my approach correct and will it yield the correct and desired
results? The reason for asking is because I don't recall exactly what I
did but while trying this out I got a much higher count(*) of customers
than the actual number of customers... I must have done something wrong


Anyway...I'll appreciate your help.

--
Thanks.



Reply With Quote
  #3  
Old   
Learner
 
Posts: n/a

Default Re: A silly question ... just to clarify my concepts - 06-20-2004 , 07:57 AM



thanks for the reply... assuming that I go with your approach (which I
understand and agree) this would still lead me to my original question
regarding the view. The data I am referring to is coming in from on OLTP
(to be used for a data mart) terefore I did not focus too much on the
normalization part.

Will appreciate your reply (assuming my question is clear)??

Thanks & Regards.

Quote:
|Learner
|Why not just to have each table for the data?
|CREATE TABLE Zones
|(
| ZoneId INT NOT NULL PRIMARY KEY,
|ZoneName VARCHAR(100) NOT NULL
|)
|CREATE TABLE States
|(
| StateId INT NOT NULL PRIMARY KEY,
|StateName VARCHAR(100) NOT NULL
|)
|...........
|
|CREATE TABLE Customer_Details
|(
| CustCode INT NOT NULL REFERNCES Customers (CustCode ),
| ZoneId INT NOT NULL REFERNCES Zones(ZoneId ),
|StateId INT NOT NULL REFERNCES States(StateId ),..........
|........
|CONSTRAINT uid_PK PRIMARY KEY (CustCode ,ZoneId .......) Modify it for your
|needs
|)
|
|"Learner" <wantnospam (AT) email (DOT) com> wrote in message
|news:MPG.1b3fc7d9df6dba06989708 (AT) msnews (DOT) microsoft.com...
|> Hi,
|
|> I have the following tables:
|
|> CREATE TABLE [tblGeography] (
|> [ZoneID] Int,
|> [ZoneName] [char] (10),
|> [StateID] Int,
|> [StateName] [char] (35),
|> [CityID] Int,
|> [CityName] [char] (50)
|> )
|
|
|> CREATE TABLE [tblCustomers] (
|> [CustCode] [varchar] (20) ,
|> [CustName] [varchar] (64),
|> [CityID] Int
|> )
|
|
|> The logic is as follows:
|
|> Zone
|> |
|> |-- State
|> |
|> |-- City
|
|
|> What I want to do is "flatten" my data. I am thinking about creating a
|> view as follows:
|
|> 1) Add the tables listed above
|> 2) Link the CityID fields between the Two Tables
|> 3) Add all fields from Customer table EXCEPT for the CITYID field
|> 4) Add all Name fields (ZoneName, StateName, CityName) from Geography
|> table
|
|> Is my approach correct and will it yield the correct and desired
|> results? The reason for asking is because I don't recall exactly what I
|> did but while trying this out I got a much higher count(*) of customers
|> than the actual number of customers... I must have done something wrong
|>
|
|> Anyway...I'll appreciate your help.
|
|> --
|> Thanks.
|
|
|
--

--
Thanks.


Reply With Quote
Reply




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.