[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 02-15-2007, 11:22 AM   #1 (permalink)
Straight from Sweden
 
Jawn's Avatar
 
Join Date: Oct 2006
Location: Sweden
Posts: 206
100.00 NP$ (Donate)

Jawn has a spectacular aura aboutJawn has a spectacular aura aboutJawn has a spectacular aura about

Animal Rescue
Trying to prove him wrong, ( my database teacher )

He claims that using words as a unque key in databases is more of general standard.
But how does that affect speed if the database is pretty big.
My self prefer counters as id 1 2 3 4 5 6 etc its easy much easier than using words.
Has anyone done any research on this?


Best Regards
Jawn
__________________
Second place in seoworldchampionship 2007.
Jawn is offline  
Old 02-15-2007, 11:38 AM   #2 (permalink)
Senior Member
 
netzilla's Avatar
 
Join Date: Aug 2005
Location: Ohio
Posts: 1,704
223.80 NP$ (Donate)

netzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to beholdnetzilla is a splendid one to behold


If you are using the primary keys in other tables as a foreign key which is very likely given you are using normalization. I think words or letters would be easier to understand and identify. I don't think either would be faster than the other.
netzilla is offline  
Old 02-15-2007, 12:48 PM   #3 (permalink)
Straight from Sweden
 
Jawn's Avatar
 
Join Date: Oct 2006
Location: Sweden
Posts: 206
100.00 NP$ (Donate)

Jawn has a spectacular aura aboutJawn has a spectacular aura aboutJawn has a spectacular aura about

Animal Rescue
Quote:
Originally Posted by netzilla
If you are using the primary keys in other tables as a foreign key which is very likely given you are using normalization. I think words or letters would be easier to understand and identify. I don't think either would be faster than the other.
Im aware of the normalization rules and if you follow em straight out there wont be a problem.
Imagine you have a database with 1 million lines, one with words as primary key and one with a plain counter 12345 etc
If you want to select one row using the word primary key database, the database "server" will have no idea where to look and it will go through whole database until it finds the correct row.
But using the counter one it will know exactly where to look?
But i might be wrong hehe


It would be intresting if someone who has actually done a test on this to post a input


Best Regards
Jawn
__________________
Second place in seoworldchampionship 2007.
Jawn is offline  
Old 02-15-2007, 01:06 PM   #4 (permalink)
NamePros Member
 
Join Date: May 2006
Posts: 160
81.00 NP$ (Donate)

TwistMyArm is on a distinguished road


If the string key was indexed, I would guess that it wouldn't be *that* much different.

However, I don't know if you can 'autoincrement' a string like you can with an integer key.
TwistMyArm is offline  
Old 02-16-2007, 03:15 AM   #5 (permalink)
JFS
NamePros Regular
 
JFS's Avatar
 
Join Date: Oct 2005
Location: Portugal
Posts: 760
56.85 NP$ (Donate)

JFS is just really niceJFS is just really niceJFS is just really niceJFS is just really niceJFS is just really niceJFS is just really nice


the main diference is on size, the speed is same basically
__________________
Joćo Fernandes Silva
Selling :
19P.ORG - ARCADEHITS.ORG - AZIAN.NET - COREFANS.COM - CTUTORIALS.NET - DEDISEEK.COM - HITCHECK.COM - HOST15.COM - HOSTCUSTOMER.COM - LARGETIPS.COM - SCRIPTCANDY.COM - VISUALBOOK.NET - VOXVPS.COM / .NET - WALLPAPERSARENA.COM
JFS is offline  
Old 02-16-2007, 03:42 AM   #6 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
 
Join Date: Feb 2006
Posts: 2,801
56.00 NP$ (Donate)

Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future

Autism Autism Autism Autism Autism Autism Autism
Couldn't a bigger size "potentially" slow it down?

Just make some databases and make a couple million rows and test it. >_>
Dan is offline  
Old 02-16-2007, 05:05 AM   #7 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold


I'd have thought that using integers would be more of a standard - im doing databases in school now (teacher dosn't have a clue, we are using an ancient textbook for another version of the software) and we have about 3 tables in this database, all with numeric keys.
Barrucadu is offline  
Old 02-16-2007, 05:07 AM   #8 (permalink)
Senior Member
 
Shorty's Avatar
 
Join Date: Sep 2005
Location: England
Posts: 1,035
102.05 NP$ (Donate)

Shorty is just really niceShorty is just really niceShorty is just really niceShorty is just really nice


Are we talking about column headings for tables here?

If so, all that would effect is the speed of the query manipulating the database. You would be talking about the difference of a few dozen bytes worth of data, which depending on the word size of your processor would be a matter of milliseconds.
Shorty is offline  
Old 02-16-2007, 06:13 AM   #9 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold


Quote:
Originally Posted by Shorty
Are we talking about column headings for tables here?
No, primary keys:

Code:
primary_key | field1 | field2 | field3 | field4 | etc
------------|--------|--------|--------|--------|------
     0      | value  |  value | value  |  value | value
     1      | value  |  value | value  |  value | value
     2      | value  |  value | value  |  value | value
Barrucadu is offline  
Old 02-16-2007, 08:47 AM   #10 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough


Personally i always use integers as my primary keys simply because it makes the database smaller and makes it easier to cross-reference and use foreign keys. So if he says that most primary keys are text/words i wouldn't assume he is right.. im guessing im not the only one using integers as my primary keys... right..?
__________________
-Beaver6813.com V5 Soon!

Last edited by beaver6813; 02-16-2007 at 01:18 PM.
beaver6813 is offline  
Old 02-16-2007, 01:04 PM   #11 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
 
Join Date: Feb 2006
Posts: 2,801
56.00 NP$ (Donate)

Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future

Autism Autism Autism Autism Autism Autism Autism
Quote:
Originally Posted by beaver6813
im guessing im not the only one using intergers as my primary keys... right..?
Right.

I sometimes make some word columns as indexes.. but my primary keys are always integers.
Dan is offline  
Old 02-17-2007, 01:40 AM   #12 (permalink)
Straight from Sweden
 
Jawn's Avatar
 
Join Date: Oct 2006
Location: Sweden
Posts: 206
100.00 NP$ (Donate)

Jawn has a spectacular aura aboutJawn has a spectacular aura aboutJawn has a spectacular aura about

Animal Rescue
Quote:
Originally Posted by beaver6813
Personally i always use integers as my primary keys simply because it makes the database smaller and makes it easier to cross-reference and use foreign keys. So if he says that most primary keys are text/words i wouldn't assume he is right.. im guessing im not the only one using integers as my primary keys... right..?
Word, i personally use integers aswell but thats not the standard hehe
The normalization standard says that your supposed to stay away from "counter/integer" way as long is its possible.
If the primary key isnt strong enough you should pick several primary keys to make it a strong identity.
This can be hard sometimes thats why people use counter/integer way, you dont have to worry about weak identities.
__________________
Second place in seoworldchampionship 2007.
Jawn is offline  
Old 02-17-2007, 12:29 PM   #13 (permalink)
Straight from Sweden
 
Jawn's Avatar
 
Join Date: Oct 2006
Location: Sweden
Posts: 206
100.00 NP$ (Donate)

Jawn has a spectacular aura aboutJawn has a spectacular aura aboutJawn has a spectacular aura about

Animal Rescue
I would like to put up a test on this question.
Anyone know a good scenario to use?
__________________
Second place in seoworldchampionship 2007.
Jawn is offline  
Old 02-17-2007, 02:33 PM   #14 (permalink)
NamePros Regular
 
Tree's Avatar
 
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
13.25 NP$ (Donate)

Tree will become famous soon enoughTree will become famous soon enough


Set up two tables, one that uses an integer as its primary key, and another that uses random characters. Throw in 2 million rows and then query each table a few thousand times, average the results and compare.
Tree is offline  
Old 02-17-2007, 02:49 PM   #15 (permalink)
NamePros Regular
 
beaver6813's Avatar
 
Join Date: May 2005
Location: England
Posts: 349
65.50 NP$ (Donate)

beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough


Quote:
Originally Posted by Tree
Set up two tables, one that uses an integer as its primary key, and another that uses random characters. Throw in 2 million rows and then query each table a few thousand times, average the results and compare.
Thats not a bad idea for a script... i have a cunning plan :P
__________________
-Beaver6813.com V5 Soon!
beaver6813 is offline  
Old 02-17-2007, 03:29 PM   #16 (permalink)
NamePros Regular
 
Join Date: Mar 2006
Location: Connecticut, USA
Posts: 286
71.76 NP$ (Donate)

Darkneoboi is an unknown quantity at this point


Quote:
Originally Posted by Tree
Set up two tables, one that uses an integer as its primary key, and another that uses random characters. Throw in 2 million rows and then query each table a few thousand times, average the results and compare.
That sounds like a good idea, lol. I should just do that for fun. See if anything happens to my host... Of course he might get pissed at me for it.
__________________
DarkNeoNetwork
Darkneoboi is offline  
Old 02-19-2007, 07:11 AM   #17 (permalink)
Professional Monkey
 
Amnezia's Avatar
 
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 908
13.25 NP$ (Donate)

Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about

Cancer Survivorship Save a Life
won't make much difference to the speed of the database
__________________
[http://www.webmasterwords.com/python-split-and-join-examples]Python Tutorials[/url]
Amnezia is offline  
Old 02-19-2007, 07:42 AM   #18 (permalink)
Senior Member
 
RickM's Avatar
 
Join Date: Sep 2005
Location: Herts, UK
Posts: 3,769
62.06 NP$ (Donate)

RickM has a brilliant futureRickM has a brilliant futureRickM has a brilliant futureRickM has a brilliant futureRickM has a brilliant futureRickM has a brilliant futureRickM has a brilliant futureRickM has a brilliant futureRickM has a brilliant futureRickM has a brilliant futureRickM has a brilliant future

Cancer Survivorship Save The Children Save The Children Cancer Animal Cruelty Child Abuse Cancer Survivorship 9/11/01 :: Never Forget Animal Cruelty Child Abuse Animal Rescue Animal Cruelty Protect Our Planet Protect Our Planet Protect Our Planet Animal Cruelty Save a Life
The chances are he is referring to Access databases...MSSQL, and not MYSQL.

Teachers generally know naff all when it comes to modern technology...My IT teacher thought that for several rows in a table that you had to do each row as a singular table (She didn't know <tr> tags existed).
__________________
I am no longer a NP moderator -- please do not PM me with moderation requests!

~ VPSSpeed.com - Unmanaged VPS Hosting from $9.95
Get a FREE Mach-1 VPS PLAN with any order - Use the coupon FREEWHIZ
RickM is offline  
Old 02-19-2007, 08:07 AM   #19 (permalink)
The original NP Emo Kid
 
liam_d's Avatar
 
Join Date: Jan 2005
Location: Plymouth, UK
Posts: 1,648
0.00 NP$ (Donate)

liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all


You should always use a Unique Number when it comes to keys, using a word is just stupid.

It is a standard to use A number, i have been programming everday for 6 years and all scripts/programs i've ever used have numbers for the key.
liam_d is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 05:24 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85