Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 I got into this..i just need your opinion

Author  Topic 

DiceK-BadMan
Starting Member

12 Posts

Posted - 2007-11-14 : 01:12:53
Well, its kind of tricky, and i got into this.For example i have a column of zip, all US city state name and abbreviation, preffered name and an alternate name of each city in US, and also non-acceptable name of each preffered name..

Can you give me a hint, how many databse should i used?
for example, i search for a zip code, and the result will be the name of city or an acceptable name of city and there are non-acceptable name too..

well.i just need your opinion..hope you could get into this one.tnx

evilDBA
Posting Yak Master

155 Posts

Posted - 2007-11-14 : 04:03:53
You should use only one database :)
May be, you meant, how many tables?
Go to Top of Page

TimmyC
Starting Member

10 Posts

Posted - 2007-11-14 : 10:41:00
Apologies, but I'm totally confused. Say that again? Reread what you write before you post.

Non acceptable name of each preffered name? I'm not American so maybe i'm missing something. Do you mean something like:
State Abbreviation Alt Name Bad alt Name
Florida FLR Orange County Apple County

(assuming "apple county" offends the people of Florida and hence is "bad")
Go to Top of Page

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2007-11-14 : 10:54:39
Maybe you mean something like this:

zip_code state
11111 FL
22222 FL
33333 TX
44444 AZ

Cities:
zip_code city_name acceptable
11111 Miami 1
11111 Mimi 0
33333 Houston 1
33333 Houstn 1
33333 Hstn 0
Go to Top of Page

DiceK-BadMan
Starting Member

12 Posts

Posted - 2007-11-14 : 14:51:26
Oh.I mean how many tables should i used..?thank you for the correction.. well @TimmyC i mean this for example
I search for a US zip code
Search : 98052

Result :

Actual City name in 98052
REDMOND, WA

Not Acceptable
ADELAIDE, WA
AMES LAKE, WA
AVONDALE, WA
EARLMOUNT, WA

..Just like this,if i have to used a one table,should i also assign a PK?..
Go to Top of Page

Van
Constraint Violating Yak Guru

462 Posts

Posted - 2007-11-14 : 15:16:58
Would the layout I gave you not work? You could take the state out of the first table and include it in the 2nd if you like, it just wouldn't be as normalized. Then you could have it all in one table. The key to it all is the "acceptable" field being a 1 or 0. Display the 1's first and then a seperate section for the 0's. There may be a better way though...
Go to Top of Page

DiceK-BadMan
Starting Member

12 Posts

Posted - 2007-11-14 : 15:25:03
I will take your advice..if i have any further question, I'll just post my message here..thanks for the help
Go to Top of Page

DiceK-BadMan
Starting Member

12 Posts

Posted - 2007-11-16 : 18:17:25
Is all tables required to have a primary key?..In my city state table?
Go to Top of Page

TimmyC
Starting Member

10 Posts

Posted - 2007-11-19 : 03:34:21
No its not required, but in most cases I generally just add an ID column of type int and set its identity to true and auto-increment (as a primary key). It helps to have a key particularly when you are deleting or updating records later as you can be 100% sure you get the right one. If you are not intending to change the data in that table at any time then you can probably get away without one.

For example, you add 'Folrida' to your states table. 2 weeks later you are looking for 'Florida' but can't find it, so you add it in. 2 weeks later you spot a spelling mistake with 'Folrida' and correct it to 'Florida'.

Now you have 2 identical records - exactly the same. Which do you delete? Maybe this example was rubbish, but the point is things can get messy without a PK.
Go to Top of Page
   

- Advertisement -