OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: Primary Key question

From: Haisam K. Ido (haisamido.org)
Date: Fri Jul 01 2005 - 11:28:10 CDT


so if I do want 'name' to be unique I must not make it primary, just
simply unique, since my primary key is for id and name simultaneously.

replies-lists-mysqllistmail.innovate.net wrote:
> your primary key is based on your (auto-increment) id and the name,
>
> PRIMARY KEY (`id`,`name`)
>
> so your two entries would be:
>
> 1,winxp
> 2,winxp
>
>
> there's no key conflict/duplication there.
>
> by the way, you do realize what the max range is on the (signed) tinyint
> (for your "id"), correct?
>
>
> ------------ Original Message ------------
>
>>Date: Friday, July 01, 2005 10:04:01 AM -0400
>>From: "Haisam K. Ido" <haisamido.org>
>>To: mysqllists.mysql.com
>>Subject: Primary Key question
>>
>>
>>I've created the following table (server 4.1 in win2k)
>>
>>CREATE TABLE `os` (
>> `id` tinyint(10) NOT NULL auto_increment,
>> `name` varchar(255) NOT NULL default '',
>> `description` varchar(255) default NULL,
>> PRIMARY KEY (`id`,`name`)
>>) ENGINE=MyISAM DEFAULT CHARSET=utf8;
>>
>>and was very surprised that I can do the following twice. Should'nt
>>this be rejected since name is a primary key ad has already been used?
>>
>>INSERT INTO os (name,description) VALUES ( 'winxp','winxp');
>>
>>
>>--
>
>
> ---------- End Original Message ----------

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql