Reply
simple but ip issue in db design
Old 12-05-2006, 07:12 PM simple but ip issue in db design
Skilled Talker

Posts: 95
Most of the registration process on websites, ask you for the country name from drop down. My question is , should we design our db like this:
Table 1: Country (countryID, countryName)
Table 2: Registration(Name, email ... Country(Id/Name) .

So, it should be countryId in the registration table or countryName ?

Which is the best approach ?
varunbihani is offline
Reply With Quote
View Public Profile Visit varunbihani's homepage!
 
When You Register, These Ads Go Away!
Old 12-05-2006, 07:53 PM Re: simple but ip issue in db design
Republikin's Avatar
Super Moderator

Posts: 3,191
That really depends on if you will be making frequent queries to just the countries. If you seperate them then your db wouldn't have to filter through all the other stuff so in essence it would speed things up a bit, however if you will only be pulling the country info in correlation to someones profile or in other words with every thing else, then if the countries table is seperate you would either have to do two queries or use a join which starts to get confusing.
Republikin is offline
Reply With Quote
View Public Profile
 
Old 12-06-2006, 01:08 AM Re: simple but ip issue in db design
Skilled Talker

Posts: 95
so mean, it should depend on the application requirements?
varunbihani is offline
Reply With Quote
View Public Profile Visit varunbihani's homepage!
 
Old 12-06-2006, 09:41 AM Re: simple but ip issue in db design
Republikin's Avatar
Super Moderator

Posts: 3,191
Exactly, there is never a one size fits all database design.
Republikin is offline
Reply With Quote
View Public Profile
 
Old 12-09-2006, 07:18 AM Re: simple but ip issue in db design
chrishirst's Avatar
Super Moderator

Posts: 16,467
Location: Blackpool. UK
Using the country ID and a join makes for a better DB design.

It's a process called "normalisation". Where the DB designer reduces the amount of redundant (duplicated) data in the tables.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-06-2007, 08:56 AM Re: simple but ip issue in db design
tripy's Avatar
Fetchez la vache!

Posts: 2,253
Name: Thierry
Location: In the void
I totally agree with chrishirst.

I usually use 3 tables for that.
There is a typical mysql schema.

One table with a country list:
Code:
create table country(
  iso char 3,
  name varchar(255),
  
  primary key (iso)
);
One table with my user infos, but no direct links with the country table
Code:
create table user(
  id number not null,
  username varchar(50) not null,
  password varchar(200) not null,

  primary key (id)
);
And finally one last table who link the users and the country:
Code:
create table countryLink(
  userId number not null,
  iso char(3) not null,

  primary key (userId,iso)
);
tripy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to simple but ip issue in db design
 

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13424 seconds with 12 queries