I use SchemeExport to create database scheme. Many-to-many tables creates without primary key (only two foreign keys). Is it possible to create primary key too?
Asked
Active
Viewed 547 times
3
-
1Why do you need a primary key on a many-to-many table? – James Kovacs Nov 17 '10 at 17:58
-
Why not? I can add two (or more) identical rows without primary key and searching operations will be slower. I think each table must have primary key. Am I wrong? – Andy Nov 17 '10 at 19:04
-
1I've found question about it http://stackoverflow.com/q/38870/511041. I have option 2. – Andy Nov 17 '10 at 19:39
1 Answers
0
Can you post something more about your domain? To create a surrogate key on many-to-many associations is hardly a good choice and there may be a more appropriate domain modeling.
If you are concerned about performance, do some comparative tests with indexes or unique constraint on both FK columns. I'm pretty sure that create a surrogate Id is going to result on poor insert performance and will not improve search performance as searchs are almost always based on both FK columns.