473,396 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Should I use a string that's varchar (30) (unique) as a primary key?

bugboy
160 100+
I have a table of words which are all unique and will not change.. can i use the words themselves as the primary key or is it better to use an integer?

I think it would simplify my queries a great deal if I didn't have to retrieve the primary key for the word /or the word for the key every time i query. I'm looking for the best efficiency but maybe i'm splitting hairs here?

I've read that strings make lousy keys. But since mine are all unique and never change, i'm just wonder what the common practice would be?

Thanks!

BugBoy
Sep 25 '07 #1
2 1593
forse
7
Hi,

For example, if you are using email addresses, they will surely be unique. But it is better to use a separate field as your primary key (eg. bigint auto_increment values). Just because it is unique, doesn't mean you should use it as primary key.
Sep 25 '07 #2
bugboy
160 100+
Thanks forse!

Is it better because it's faster to query or because it's more stable (less likely to change over time)?
Sep 25 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Brian Murphy | last post by:
<?php /* I need your help. I'd be very thankfull if write me this script.I need a script that displays a list of categories and subcategories like this: <select name="category"> <option...
4
by: balkii | last post by:
hi!!! would appreciate if somebody could let me know the query/algoritham to sort the following values in the column either in asc or desc the values in the column originally 1 1-1/2 1-1/4
2
by: adammitchell | last post by:
I'm trying to create a local copy of a popular CRM database called Salesforce.com. Many of the tables in the DB have FOREIGN KEY references that I want to preserve, but I've run into a chicken and...
5
by: Willem | last post by:
Hello I am quite hopeless and of course a newbe. The situation: Sql2k / query I would like it ot break down the following string: 2004 Inventory:Ex.Plant Farm1:1st Cut:Premium:0094
6
by: shallow | last post by:
Hi all, msaccess (2003) seems to be unable to cope with whitespace strings: let's assume a table with a text field as primary key. now enter a new record that has a number of spaces and only...
2
by: roopeman | last post by:
i need your help, my code as below : //----------------------------------------------------------------------- //Wrote by Michael April 30 2005...
2
by: rootman | last post by:
Hi @all i try to create a ssh public key database on a mysql-5.0.16 DB the problem is the size of the varchar, i want a size 1024... mysql> create table sshkeys ( absid integer unsigned...
1
by: shearichard | last post by:
Hi - I have written some python to insert a row into a table using MySQLDB. I have never before written SQL/Python using embedded parameters in the SQL and I'm having some difficulties. Could...
3
by: vj_dba | last post by:
Hi Group, I have a Primary key in my table. It's clear Primary key wont allow duplicates, this primary key creates one index for retrival. Suppose if my table is having a Unique index also....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.