Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



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

Posts: 110
Trades: 0
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 ?
__________________

Please login or register to view this content. Registration is FREE
varunbihani is offline
Reply With Quote
View Public Profile Visit varunbihani's homepage!
 
 
Register now for full access!
Old 12-05-2006, 07:53 PM Re: simple but ip issue in db design
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
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.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 12-06-2006, 01:08 AM Re: simple but ip issue in db design
Super Talker

Posts: 110
Trades: 0
so mean, it should depend on the application requirements?
__________________

Please login or register to view this content. Registration is FREE
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
Defies a Status

Posts: 3,189
Trades: 3
Exactly, there is never a one size fits all database design.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
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
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
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
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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 Visit tripy's homepage!
 
Reply     « Reply to simple but ip issue in db design
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB 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.43352 seconds with 12 queries