Adobe Dreamweaver Forums



Last 10 THreads :         Update HELL for unsupported OS... (Last Post : WTF? - Replies : 0 - Views : 1 )           »          Cannot install Flash Player 10 (not-beta) (Last Post : Darren McNally - Adobe - Replies : 8 - Views : 9 )           »          Full screen flash projector reverts to windowed whenexiting screen saver (Last Post : rbolman - Replies : 0 - Views : 1 )           »          On hitTest go to next frame? Why doesn't this work? (Last Post : kglad - Replies : 1 - Views : 2 )           »          Contribue won't allow Images to be inserted (Last Post : RiderAlberta - Replies : 0 - Views : 1 )           »          This just sucks.... (Last Post : TC2112 - Replies : 11 - Views : 12 )           »          Update from array (Last Post : -==cfSearching==- - Replies : 3 - Views : 4 )           »          PHP Notice Problem (Last Post : UteFanJason - Replies : 7 - Views : 8 )           »          Limited Ammo (Last Post : kglad - Replies : 19 - Views : 20 )           »          Icon Text sticks when returning to home page.. (Last Post : kglad - Replies : 1 - Views : 2 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Cold Fusion
 
Tags: , , ,

Reply
  #1 (permalink)  
Old 07-07-2008, 04:39 PM
krisbrixon
 
Posts: n/a
Diggs:
Default Re: do i always have to have a primary key in a mysqltable?

Technically no.

However, you should always pick one for two reasons.
1. You need something to uniquely identify a row so you can do an update or
delete and only affect that row.
2. A primary key is also an index and without indexes, your database will be
much sloooooower.

Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-23-2008, 10:11 AM
Eivind
 
Posts: n/a
Diggs:
Default Re: do i always have to have a primary key in a mysql table?

krisbrixon skreiv:
> Technically no.
>
> However, you should always pick one for two reasons.
> 1. You need something to uniquely identify a row so you can do an update or
> delete and only affect that row.
> 2. A primary key is also an index and without indexes, your database will be
> much sloooooower.


But note that this doesn't mean that all tables must/should have a
single primary-key column.

For example, if you have three tables, one for classes, one for
students, and one which links students to classes, then;

You probably want a primary key, "studentid" or similar.

You probably want a primary key "classid" or similar.

Assuming one student can only enroll at most -once- in a single class,
you probably DONT need a extra field for primary key on the
student_class table, instead you make a COMPOSITE primary key, that is,
the combination of student and class is unique.

There can be multiple entries for a student (one for each class hes
taking) and multiple for each class (one for each student taking that
class); but there cannot be more than a single record saying that (for
example) student 5 is taking class 3.

These kinds of questions are really database-questions and not
coldfusion-questions though.... (the answer would be exactly the same if
you where using any other language)


Eivind Kjørstad
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 12:20 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk