473,406 Members | 2,390 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,406 software developers and data experts.

"you should define a primary key for this table" - why?

CAH
I once wrote on usenet and got a very good answer . This one

JN wrote:
| Should one place all the text in one big table, or is i better to place
| it in several tabels. Should one make 4 colums one for each language,
| or 4 rows one for each language?


I use:
CREATE TABLE `usr_languages` (
`pageName` varchar(25) default '',
`itemNo` int(11) default '0',
`en` text,
`fr` text,
`it` text
) TYPE=MyISAM COMMENT='different languages';


which I used, and it works just fine, except that I just discovered
that if I place just a litle more than a few line of text - in the TEXT
fields then i get an "error" in phpmyadmin. There is a small question
mark were thre is normally a pen and a cross - and when I move the
cursur above the question mark i get this. "you should define a primary
key for this table" .

Do you have any suggestions as to what the problem might be?

Thanks for any help you can offer.

Best regards
Cah

Sep 23 '05 #1
7 1824
Have you tried...what the error says...as defining a primary
key...joint key with pageName and itemNo??

Rgds,
Gerard

Sep 24 '05 #2
CAH wrote:
I once wrote on usenet and got a very good answer . This one

JN wrote:
| Should one place all the text in one big table, or is i better to place
| it in several tabels. Should one make 4 colums one for each language,
| or 4 rows one for each language?


I use:
CREATE TABLE `usr_languages` (
`pageName` varchar(25) default '',
`itemNo` int(11) default '0',
`en` text,
`fr` text,
`it` text
) TYPE=MyISAM COMMENT='different languages';

which I used, and it works just fine, except that I just discovered
that if I place just a litle more than a few line of text - in the TEXT
fields then i get an "error" in phpmyadmin. There is a small question
mark were thre is normally a pen and a cross - and when I move the
cursur above the question mark i get this. "you should define a primary
key for this table" .

Do you have any suggestions as to what the problem might be?


I don't use phpmyadmin, but I assume that it would like to use the
primary key to make sensible select/update-statements. Apart from
that, it is just an advice for your own good.

Primary keys are to ensure integrity, but you get performance gains as
an added bonus, because you get the table indexed. In other words,
without a primary key (when applicable), you risk making a mess of
your data and having a crappy performance. But the choice is still up
to you. :)
/Bent
Sep 24 '05 #3
CAH
Gerard wrote:
Have you tried...what the error says...as defining a primary
key...joint key with pageName and itemNo??

Hi Gerard
Thanks a lot for the tip, - but how do I make a joint key ? I seams
strange to me that the problem only arises on a row, when there is a
lot of text in the TEXT field.

Cah

Sep 24 '05 #4
CAH
> I don't use phpmyadmin, but I assume that it would like to use the
primary key to make sensible select/update-statements. Apart from
that, it is just an advice for your own good.

Primary keys are to ensure integrity, but you get performance gains as
an added bonus, because you get the table indexed. In other words,
without a primary key (when applicable), you risk making a mess of
your data and having a crappy performance. But the choice is still up
to you. :)


Thanks for the tip, I will try to make one.

I see what you mean, I will try to make the kind of joint ket mensionen
above.

Cah

Sep 24 '05 #5
CREATE TABLE `usr_languages` (
`pageName` varchar(25) default '',
`itemNo` int(11) default '0',
`en` text,
`fr` text,
`it` text
PRIMARY KEY ( `pageName` , `itemNo` )
) TYPE=MyISAM COMMENT='different languages';

I guess this should help in you with this table definition.

Regards,
Gerard

Sep 24 '05 #6
CAH

Gerard wrote:
CREATE TABLE `usr_languages` (
`pageName` varchar(25) default '',
`itemNo` int(11) default '0',
`en` text,
`fr` text,
`it` text
PRIMARY KEY ( `pageName` , `itemNo` )
) TYPE=MyISAM COMMENT='different languages';

I guess this should help in you with this table definition.


Hi Gerard

Thanks a lot - I did it with "alter table" since i alredy have the
table, and it did the trick. I do however think it my be a bug in
phpmyadmin that causes the error, but anyhow it worked.

Thanks for the help.

Cah

Sep 24 '05 #7
>JN wrote:
>| Should one place all the text in one big table, or is i better to place
>| it in several tabels. Should one make 4 colums one for each language,
>| or 4 rows one for each language?
I use:
CREATE TABLE `usr_languages` (
`pageName` varchar(25) default '',
`itemNo` int(11) default '0',
`en` text,
`fr` text,
`it` text
) TYPE=MyISAM COMMENT='different languages';


which I used, and it works just fine, except that I just discovered
that if I place just a litle more than a few line of text - in the TEXT
fields then i get an "error" in phpmyadmin. There is a small question


I doubt it is an ERROR. It is a suggestion to improve your database,
much like a grade of A is a suggestion that you didn't do well enough
to deserve an A+.
mark were thre is normally a pen and a cross - and when I move the
cursur above the question mark i get this. "you should define a primary
key for this table" .
Conventional wisdom says you should have a primary key for every
table. Among other things, this gives you the ability to delete
one specific record without possibly getting others in the process.
An index also speeds lookup.

Sometimes your primary key is an "artificial" one, maintained
by the database, such as:
id int not null auto_increment
Do you have any suggestions as to what the problem might be?


Bad style.

Gordon L. Burditt
Sep 24 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Scott | last post by:
Does anyone know what DiskSetID and ID refer to for the following registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\dmio\Boot Info\Primary Disk Grou DiskSetID ...
2
by: Alienz | last post by:
Lets say I have a form called Planet_Systems and a form called Species. I then want to link the primary key "Planet" to bring up it's various species in the corresponding subform. So, I created a...
1
by: James | last post by:
Hi all, How do you #define (as in C++) in C#? Many thanks, James
4
by: chrisek | last post by:
Hello, I have a table 'customers', with 2 records: SELECT * FROM customers; customerID | customerName ------------------+------------------------- myFriend | myFriend's Name test |...
14
by: Chen Shusheng | last post by:
CSS white here: Simply strange, I found "define" can not work with "malloc". Together my complier will say "parse error". Could anyone tell me why? ------------------------- #define MAX 10000...
17
by: Chen Shusheng | last post by:
Hi all, In fact, I want to let my memory run out. And see what will happen. My system is windowsXp. Memory is 256M.I think my cdes will apply more memory than I have. Codes are below: ...
5
by: kiask2343 | last post by:
Ok before I get started let it be known I am the definition of a newbie when it comes to access and VBA. I know very little about access and nothing about VBA. I am in the Army and am tasked with...
3
by: ogkid101 | last post by:
hi there!! i am trying to find out what are primary expressions and also can u help me on on the following line in this C program where the compiler is telling me that a primary expression before...
6
jinalpatel
by: jinalpatel | last post by:
I am getting this error when I try to enforce referencial integrity from Harvest II table to tractsum table I have attached the relationship diagram. Please give me the hint about possibilities of...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.