| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Straight from Sweden Join Date: Oct 2006 Location: Sweden
Posts: 202
![]() ![]() ![]() | 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. |
| |
| | #2 (permalink) |
| Senior Member Join Date: Aug 2005
Posts: 1,717
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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. |
| |
| | THREAD STARTER #3 (permalink) | ||||
| Straight from Sweden Join Date: Oct 2006 Location: Sweden
Posts: 202
![]() ![]() ![]() |
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. | ||||
| |
| | #7 (permalink) |
| Senior Member Join Date: Aug 2005 Location: East Yorkshire, England
Posts: 2,689
![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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. |
| |
| | #8 (permalink) |
| Senior Member Join Date: Sep 2005 Location: England
Posts: 1,034
![]() ![]() ![]() ![]() | 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. |
| |
| | #9 (permalink) | ||||
| Senior Member Join Date: Aug 2005 Location: East Yorkshire, England
Posts: 2,689
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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 | ||||
| |
| | #10 (permalink) |
| NamePros Regular Join Date: May 2005 Location: England
Posts: 392
![]() ![]() ![]() | 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 - Web Developer Extraordinaire!
Last edited by beaver6813; 02-16-2007 at 02:18 PM.
|
| |
| | #11 (permalink) | ||||
| Buy my domains. Join Date: Feb 2006
Posts: 2,796
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() ????: 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. | ||||
| |
| | THREAD STARTER #12 (permalink) | ||||
| Straight from Sweden Join Date: Oct 2006 Location: Sweden
Posts: 202
![]() ![]() ![]() |
????: 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. | ||||
| |
| | #14 (permalink) |
| NamePros Regular Join Date: Feb 2006 Location: Atlanta, GA, USA
Posts: 335
![]() ![]() | 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. |
| |
| | #15 (permalink) | ||||
| NamePros Regular Join Date: May 2005 Location: England
Posts: 392
![]() ![]() ![]() |
__________________ -Beaver6813.com - Web Developer Extraordinaire! | ||||
| |
| | #16 (permalink) | ||||
| NamePros Regular Join Date: Mar 2006 Location: Connecticut, USA
Posts: 281
![]() |
__________________ DarkNeoNetwork | ||||
| |
| | #17 (permalink) |
| Professional Monkey Join Date: Jul 2005 Location: Escaped from the zoo
Posts: 907
![]() ![]() | won't make much difference to the speed of the database
__________________ Webmaster Words |
| |
| | #18 (permalink) |
| Senior Member Join Date: Sep 2005 Location: Herts, UK
Posts: 3,796
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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! |
| |
| | #19 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | 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.
__________________ Gaming On Linux - Because Linux is Fun! |
| |