NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Trying to prove him wrong, ( my database teacher )

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

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 02-15-2007, 12:22 PM THREAD STARTER               #1 (permalink)
Straight from Sweden
 
Jawn's Avatar
Join Date: Oct 2006
Location: Sweden
Posts: 202
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, 12:38 PM   #2 (permalink)
Senior Member
 
netzilla's Avatar
Join Date: Aug 2005
Posts: 1,717
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, 01:48 PM THREAD STARTER               #3 (permalink)
Straight from Sweden
 
Jawn's Avatar
Join Date: Oct 2006
Location: Sweden
Posts: 202
Jawn has a spectacular aura aboutJawn has a spectacular aura aboutJawn has a spectacular aura about
 


Animal Rescue
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.
????: NamePros.com http://www.namepros.com/programming/294634-trying-prove-him-wrong-my-database.html
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, 02:06 PM   #4 (permalink)
NamePros Member
Join Date: May 2006
Posts: 160
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, 04:15 AM   #5 (permalink)
JFS
NamePros Regular
 
JFS's Avatar
Join Date: Oct 2005
Location: Portugal
Posts: 800
JFS is a name known to allJFS is a name known to allJFS is a name known to allJFS is a name known to allJFS is a name known to allJFS is a name known to allJFS is a name known to allJFS is a name known to all
 



the main diference is on size, the speed is same basically
__________________
Joćo Fernandes Silva
JFS is offline  
Old 02-16-2007, 04:42 AM   #6 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
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, 06:05 AM   #7 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
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, 06:07 AM   #8 (permalink)
Senior Member
 
Shorty's Avatar
Join Date: Sep 2005
Location: England
Posts: 1,034
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, 07:13 AM   #9 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
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
 




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, 09:47 AM   #10 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
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..?
Last edited by beaver6813; 02-16-2007 at 02:18 PM.
beaver6813 is offline  
Old 02-16-2007, 02:04 PM   #11 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
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
Originally Posted by beaver6813
im guessing im not the only one using intergers as my primary keys... right..?
Right.
????: NamePros.com http://www.namepros.com/showthread.php?t=294634

I sometimes make some word columns as indexes.. but my primary keys are always integers.
Dan is offline  
Old 02-17-2007, 02:40 AM THREAD STARTER               #12 (permalink)
Straight from Sweden
 
Jawn's Avatar
Join Date: Oct 2006
Location: Sweden
Posts: 202
Jawn has a spectacular aura aboutJawn has a spectacular aura aboutJawn has a spectacular aura about
 


Animal Rescue
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
????: NamePros.com http://www.namepros.com/showthread.php?t=294634
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, 01:29 PM THREAD STARTER               #13 (permalink)
Straight from Sweden
 
Jawn's Avatar
Join Date: Oct 2006
Location: Sweden
Posts: 202
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, 03:33 PM   #14 (permalink)
NamePros Regular
 
Tree's Avatar
Join Date: Feb 2006
Location: Atlanta, GA, USA
Posts: 335
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, 03:49 PM   #15 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




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
beaver6813 is offline  
Old 02-17-2007, 04:29 PM   #16 (permalink)
NamePros Regular
Join Date: Mar 2006
Location: Connecticut, USA
Posts: 281
Darkneoboi is an unknown quantity at this point
 



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, 08:11 AM   #17 (permalink)
Professional Monkey
 
Amnezia's Avatar
Join Date: Jul 2005
Location: Escaped from the zoo
Posts: 907
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
__________________
Webmaster Words
Amnezia is offline  
Old 02-19-2007, 08:42 AM   #18 (permalink)
Senior Member
 
RickM's Avatar
Join Date: Sep 2005
Location: Herts, UK
Posts: 3,796
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).
__________________
RickM

Web Design Forums - Over 22,000 Web Designers & Programmers just like you!
WSDReg - Affordable Domain Registration. Serving NP members since 2006!
RickM is offline  
Old 02-19-2007, 09:07 AM   #19 (permalink)
The original NP Emo Kid
 
liam_d's Avatar
Join Date: Jan 2005
Location: Plymouth, UK
Posts: 1,693
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


Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:24 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger