Tag Info

New answers tagged

5

A PRIMARY KEY is, by definition, UNIQUE and NOT NULL, so by adding a second UNIQUE keywork on it you are actually creating a different index, and that does not only make things more efficient but, in some cases, it will make your queries less performant. You can check that two index were created by doing: mysql> SHOW CREATE TABLE test\G ...


1

Store the tenant_id first. When you do this you can enable index key compression. See http://docs.oracle.com/cd/B28359_01/server.111/b28310/indexes003.htm#i1106790 for the syntax and http://docs.oracle.com/cd/B28359_01/server.111/b28318/schema.htm#i14618 for the concepts. In your case, you can do it like this: create unique index mytable_idx on ...


1

One thing you need to keep in mind is what you are using PK for. At the logical level (sometimes called the conceptual level), the primary key is simply one of the candidate keys, chosen somewhat arbitrarily. The purpose is to guarantee that each row is unique, that each row has an identifier, and that no part of an identifier is left out (NULL). For ...


6

Yes. It's in the MSDN documentation pages: Foreign Key relationships A FOREIGN KEY constraint specified at the table level must have the same number of reference columns as the number of columns in the constraint column list. The data type of each reference column must also be the same as the corresponding column in the column list. That page does not ...



Top 50 recent answers are included