If you are using AID (article ID) and PID (page id) would both of these have to be the primary key?
| SitePoint Sponsor |





If you are using AID (article ID) and PID (page id) would both of these have to be the primary key?





No. Only one of those columns would get the primary key.
Actually, a primary key isn't even required, it only speeds up searching the database.
www.nyanko.ws - My web-, software- and game development company.
www.mayaposch.com - My personal site and blog.





And you can have only 1 primary key! you can have several unique keys though.





In the tutorial offered by sitepoint he uses two primary keys at one point.
I tried using two and it works.
I asked becasue, There would be multiple of PID and AID everywhere, so making both primary says that both must be unique as if they were one





2 Primary keys in the same table??





Well as you were obviously wrongI guessed I would proove it.....
open MySQL...
Apache...
phpMyAdmin...
type type...
ah!.... MySQL will let you have 2 primaries!
So I take it all back ! (again!)
hmmmmmmm...
I'll just clear this one up MySQL does not allow two primary keys in the same table. What it does allow is for you to specift 1 or more columns to be used as a compound primary key which it what you are all getting confused with.
If you specify aid and pid as a compound key then all combinations of aid and pid will be unique.
Karl Austin :: Profile :: KDA Web Services Ltd.
Business Web Hosting :: Managed Dedicated Hosting :: From £250/m
Personal Web Hosting :: Budget Web Hosting :: From £50/y
Call 0800 542 9764 today and ask about our Cloud Hosting Platform





Thanx
Bookmarks