all groups > sql server programming > june 2004 >
You're in the

sql server programming

group:

A silly question ... just to clarify my concepts



Re: A silly question ... just to clarify my concepts Uri Dimant
6/20/2004 2:31:21 PM
sql server programming: 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
)

[quoted text, click to view]

A silly question ... just to clarify my concepts Learner
6/20/2004 4:15:52 PM
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.

--
Re: A silly question ... just to clarify my concepts Learner
6/20/2004 5:57:03 PM
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.

[quoted text, click to view]

--

--
Re: A silly question ... just to clarify my concepts Joe Celko
6/20/2004 6:16:40 PM
Here is the link on Amazon.com for my new book on "Trees & Hierarchies
in SQL"

http://www.amazon.com/exec/obidos/tg/detail/-/1558609202/qid=1080772873/
sr=1-1/ref=sr_1_1/102-7683601-6345721?v=glance&s=books#product-details

Use a nested sets model for the dimension tables in your data mart.

But frankly, from what you posted, you do not have the experience for a
DW project. Stop using those silly "tbl-" prefixes. It makes you look
like a DW designer who never read ISO-11179; how bad is that?? You are
are really using numbers for states? Do you really know of any city
with a CHAR(50) name or a state that is CHAR(35) and not CHAR(2); tell
the USPS -- they don't know about your discovery!).

You clearly did no research before writing your schema, did you?

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Devdex http://www.devdex.com ***
Re: A silly question ... just to clarify my concepts Steve Kass
6/20/2004 10:13:36 PM
You have to wonder about a book if the only review even the publisher can
come up with was written before the book was written (see below, emphasis
added), especially if the author is prone to posting garbage in the
newsgroups (see "Re: GROUP by, but not exact..." earlier today).


"I want to say clearly that I think that the subject of this *proposed* book
is one for which there will be considerable demand. I think that the topic
is poorly understood in general and a good book on the subject will be
helpful to the SQL community at large. This book should be of great interest
to real-world application programmers, ranging from enterprise-level
application builders down to small business developers....I think that this
book would be used on a day-to-day basis (rather than languish on a shelf
until some special problem arose)." -Jim Melton,

SK

[quoted text, click to view]

Re: A silly question ... just to clarify my concepts Steve Kass
6/20/2004 10:57:44 PM
Also very funny is this excerpt from the Amazon page on your book:

Customers interested in this title may also be interested in:
Sponsored Links ( What's this? ) Feedback

a.. Retro Candy Gift Store
Nostalgic Candy & Classic Gifts, Necco, Zotz, Licorice, Metal Signs
candycrate.com
b.. Smarties - Order Online
Offering a wide variety of Canadian products. Order now!
www.CanadianTreats.com/Chocolate
c.. British confectionery
Economical postage to USA & Europe 1000's British foods & toiletries
www.britsuperstore.com
SK

[quoted text, click to view]

Re: A silly question ... just to clarify my concepts Learner
6/21/2004 9:52:04 AM
Mr. CELKO,

Guess what: You might be doing just fine with this "attitude" of yours
but will you please let me do my learning. I compare you with tons of
others (who have been of great help) and it really makes me wonder and
more importantly feel sorry for you.

I said this in reply to another post (many weeks back) and will say it
again: If you are not willing to help and instead are looking for each
and every opportunity to humiliate and be sarcastic then why don't you
simple add my posts to your ignore list or simply do not read them at
all.


Grow up Mr. CELKO even if you're already 60+. And I mean growing up in
terms of mannerism and a learning to have a little respect for others.


My best wishes and prayers for your speedy recovery!



[quoted text, click to view]

--
Re: A silly question ... just to clarify my concepts Joe Celko
6/21/2004 12:22:15 PM
[quoted text, click to view]
Retro Candy Gift Store <<

I remember when Amazon starting selling clothing on line. They were
able to tell I like chinos because I ordered a math book! Perhaps if I
had ordered a spy novel, I would have gotten a trenchcoat.

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Devdex http://www.devdex.com ***
Re: A silly question ... just to clarify my concepts Joe Celko
6/21/2004 12:53:12 PM
[quoted text, click to view]
can come up with was written before the book was written ... <<

I was running so late on that project! I did not see a copy until the
DAMA show. The 15 copies at DAMA sold out, so I never got one. and
then it was three weeks before I got my author's copies. What we are
doing instead is getting excepts on two websites. I am not sure when
the real reviews will start.

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Devdex http://www.devdex.com ***
AddThis Social Bookmark Button