Skip to main content
Inspiring
May 22, 2007
Question

MySQL, Keys, and the use of UNIQUE

  • May 22, 2007
  • 13 replies
  • 614 views
I have built a MySQL table containing three fields:

1. RecordNum (Primary Key)
2. Keyword (TEXT)
3. Definition (TEXT)

This table contains data already. I now find that I neglected to consider
what would happen if someone tries to enter a second instance of the same
keyword!

What's the best way to extricate myself from this? 8)

I guess I need to re-index my table on unique keywords, but am not sure of
how to go about that, give that the table already contains data. I suppose
I could export the data, flush the table, and restructure it with the
keyword as the primary index?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



This topic has been closed for replies.

13 replies

Inspiring
May 22, 2007
Hi Murray,

Add a Unique Constraint to that column. This will prevent duplicate values
altogether. I am 99.9% sure that MySQL supports Unique Constraints.

Pat.


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:f2uktu$pml$1@forums.macromedia.com...
>I have built a MySQL table containing three fields:
>
> 1. RecordNum (Primary Key)
> 2. Keyword (TEXT)
> 3. Definition (TEXT)
>
> This table contains data already. I now find that I neglected to consider
> what would happen if someone tries to enter a second instance of the same
> keyword!
>
> What's the best way to extricate myself from this? 8)
>
> I guess I need to re-index my table on unique keywords, but am not sure of
> how to go about that, give that the table already contains data. I
> suppose I could export the data, flush the table, and restructure it with
> the keyword as the primary index?
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
>


Inspiring
May 22, 2007
Hmm - well, that would work, too! Lemme ponder that....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Dave Buchholz" <forums@REMOVETHISi-cre8.co.uk> wrote in message
news:f2ulvr$qvr$1@forums.macromedia.com...
> Why not run a check when inserting a new record to see whether the keyword
> exists, assuming you only allow one keyword much like the std DW check new
> username SB
>
> --
> Dave Buchholz
> I-CRE8
> www.i-cre8.co.uk
> Skype ID: I-CRE8
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:f2uktu$pml$1@forums.macromedia.com...
>>I have built a MySQL table containing three fields:
>>
>> 1. RecordNum (Primary Key)
>> 2. Keyword (TEXT)
>> 3. Definition (TEXT)
>>
>> This table contains data already. I now find that I neglected to
>> consider what would happen if someone tries to enter a second instance of
>> the same keyword!
>>
>> What's the best way to extricate myself from this? 8)
>>
>> I guess I need to re-index my table on unique keywords, but am not sure
>> of how to go about that, give that the table already contains data. I
>> suppose I could export the data, flush the table, and restructure it with
>> the keyword as the primary index?
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>>
>
>


Inspiring
May 22, 2007
Why not run a check when inserting a new record to see whether the keyword
exists, assuming you only allow one keyword much like the std DW check new
username SB

--
Dave Buchholz
I-CRE8
www.i-cre8.co.uk
Skype ID: I-CRE8


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:f2uktu$pml$1@forums.macromedia.com...
>I have built a MySQL table containing three fields:
>
> 1. RecordNum (Primary Key)
> 2. Keyword (TEXT)
> 3. Definition (TEXT)
>
> This table contains data already. I now find that I neglected to consider
> what would happen if someone tries to enter a second instance of the same
> keyword!
>
> What's the best way to extricate myself from this? 8)
>
> I guess I need to re-index my table on unique keywords, but am not sure of
> how to go about that, give that the table already contains data. I
> suppose I could export the data, flush the table, and restructure it with
> the keyword as the primary index?
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
>