I'm interested to know in which case I should create a primary key on multiple columns and why ? To be more specific about my question, I want to know  what are the advantages and disadvantages of primary key on multiple columns in terms of performance. I did some research and found  where someone is saying  Another good question is SHOULD a primary key be multiple columns. :) – Sonny Boy Nov 17 '09 at 17:31 Well, that's a different question, and the answer is NO, NOT EVER, AND IF YOU DO I WILL HUNT YOU DOWN AND HURT YOU. Just a personal preference, of course :-) – Stu Dec 4 '09 at 16:46  Despite the joke, there should be some good reason on why one shouldn't use primary key on multiple columns but I couldn't find any answer.  I was wondering about this because I have a concrete problem. Consider the following table: CREATE TABLE IF NOT EXISTS `user_travel_data` (   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,   `id_user` int(10) unsigned NOT NULL,   `day` date NOT NULL,   `origin` varchar(8) NOT NULL,   `destination` varchar(8) NOT NULL,   `data` varchar(255) NOT NULL,   PRIMARY KEY (`id`),   UNIQUE KEY `ukey` (`id_user`, `day`, `origin`, `destination`) )   In this table, for each user I have some data for each day and for each  travel from origin to destination. I need this table because it's very easy to use WHERE clause on it. However, the numbers of line in this table are just insane. Usually, a user has ~50 origins and ~100 destinations. With 30 days filled &amp; 200 users, there's ~30 million lines in my table. Because each user has around ~150000 lines, I had to create some tools for them to edit/delete/add lines in group. And, because of these tools, users tends to delete old lines and create a whole bunch of new lines. This leads to a very fast increase of my primary key. While it is not a problem now, it could be one pretty soon. So, since I don't use the id on this table, I was wondering if I could do something like : PRIMARY KEY (`id_user`, `day`, `origin`, `destination`)   is also quite useful but didn't help with my problem
Let's assume you have a table groups and a table item. Each item belongs to exactly one group. It is an inherent part of that group. An item cannot exist outside of a group and it cannot be moved to another group.  When trying to decide on a primary key for the item table, what should I use?  Should I make up an artificial global serial key like this:  CREATE TABLE items (     item serial PRIMARY KEY,     group integer NOT NULL REFERENCES groups(group), );   ... or should I rather use a composite key and per-group item serial like this:  CREATE TABLE items (     group integer NOT NULL REFERENCES groups(group),     item integer NOT NULL,      PRIMARY KEY(group, item) );   The reason why I'm leaning more towards the second solution is that the post URL will always show the group and item, so it makes sense to have both of them as the composite primary key. In case of the first solution, the URL contains superfluous information because the group ID can already be deduced from the item ID alone. The URL structure is given, however, and cannot be changed.  The disadvantage of the second solution is that you have to manage a per-group serial (i.e. each item integer should start from 0 for each group).  What's better in terms of best practices, normalization and performance? Or is it simply a matter of taste?
Etiquette for revision comments Comparing currency values as floats does not work Do we have any other evidence other than red shift? Is anyone trying to disapprove inflation? Also, can red shift occur because of large distance, not only because two objects are going farther from each other? out file with multiple criteria in python? How can I compute the following limit, and is there a general method to resolve problems of this type?  $$\lim_{x\to\infty}x\left[\left(1+\frac{1}{x}\right)^x-e\right]$$ Why don't electromagnetic waves require a medium? As I understand it, electromagnetic waves have two components which are the result of each other, i.e., when a moving electric charge creates a changing magnetic field at point X then a changing electric field is created at point Y and this repeating process is what creates EM waves, so therefore, it requires no medium. Is my understanding correct?  One thing that I'm surprised to know is that light is also called an electromagnetic wave.  Does this include light of any kind, for example: light from a bulb, a tube, and also from the Sun? How do they contain electric and magnetic fields? Flattening a shallow list in Python I have been looking at a few scripts other people wrote (specifically Red Hat), and a lot of their variables are assigned using the following notation VARIABLE1="${VARIABLE1:-some_val}" or some expand other variables VARIABLE2="${VARIABLE2:-`echo $VARIABLE1`}"  What is the point of using this notation instead of just declaring the values directly (e.g., VARIABLE1=some_val)?  Are there benefits to this notation or possible errors that would be prevented?  Does the :- have specific meaning in this context? Virtual Box Won't Accept .ISO To Install OS Does new Star Wars continuity only affect post-Jedi EU? I have read  a couple of times.     In order to give maximum creative freedom to the filmmakers and also preserve an element of surprise and discovery for the audience, Star Wars Episodes VII-IX will not tell the same story told in the post-Return of the Jedi Expanded Universe.   Does this describe material set after Jedi, or published after?  Is it also saying that only things published as "Legends" are now non-continuity?  I have read that it is only films + Clone Wars + Rebels that are now in the main continuity but can't see this sourced by Lucas Film Story Group. Does anyone have a reference for this? setting up subdomain on ubuntu server Show vote counts on activity>comments page It would be helpful to show vote counts on the activity > comments page, and also allow sorting by votes.  This would make it easy to see what comments other people thought were valuable or at least amusing. How to specify an arbitrary (possibly non-integer) font size in LaTeX I may be wrong, but it seems to me that I cannot obtain non-integer (or non-preloaded) font sizes (say, 9.876pt) using \fontsize.  If this is true, how do I do this in LaTeX?  Do I have to resort to the \font ... at ... primitive?  (The reason I need this is that I'd like to implement a more LaTeXy way to do the \diminuendo macro from .) How are java.lang.Object's protected methods protected from subclasses? The keyword protected grants access to classes in the same package and subclasses ().  Now, every class has java.lang.Object as superclass ().  Hence I conclude that every class may access java.lang.Object's methods even if they are protected.  Take a look at the following example:   public class Testclass {   public Object getOne() throws CloneNotSupportedException {     return this.clone();   }   public Object getTwo() throws CloneNotSupportedException {     return ((Object) this).clone();   } }   While getOne() compiles fine, getTwo() gives   Testclass.java:6: clone() has protected access in java.lang.Object         return ((Object) this).clone();   I neither understand why getTwo() doesn't compile nor what's the difference (regarding the access of java.lang.Objects members) with getOne(). ToolStrip sometimes not responding to a mouse click Show  $$\int_0^\infty \frac{\ln(x)}{e^x} = -\gamma$$ (gamma is Euler-Mascheroni constant).  Can anyone please prove this result?  Also  $$ \int_0^\infty \frac{\left( \ln(x) \right)^2}{e^x}\mathrm dx. $$ \sum caused \sqrt to not be slanted How to add a PPA on a server? The server version of Ubuntu does not have the  command. How can I add a  (PPA) to the server without this command? Assume two black holes in the most common size range, spiraling into each other until they merge. The event releases significant amounts of energy via gravitational waves, which warp the space-time.  If the distortion is powerful enough, it would get noticed in daily life, or perhaps even detected by the proprioceptors in the human body.  How close, as an order of magnitude estimate, would you have to be to the merger to perceive it like that, without any instrument? Increasing the maximum number of enumerate environments?