I'm going with better to have the id column and maybe a datetime column too. What if the person purchases the same item twice?
If the customer and item combination were unique, then I'd say skip the id column and make "primary key (Customer_ID, Item_ID)" and probably add an extra "index idx_item (Item_ID)" for fast lookups on items as well. On Apr 12, 2011, at 7:03 AM, tedd <[email protected]> wrote: > Hi gang: > > In a simple purchase table that contains only the customer-id and purchased > item-id would it be better to have an index of not? > > In other words, is a Purchase Table > > Customer_ID | Item_ID > > improved by adding an index (ID) > > ID | Customer_ID | Item_ID > > or not? > > Thanks, > > tedd > > -- > ------- > http://sperling.com/ > _______________________________________________ > New York PHP Community MySQL SIG > http://lists.nyphp.org/mailman/listinfo/mysql > > NYPHPCon 2006 Presentations Online > http://www.nyphpcon.com > > Show Your Participation in New York PHP > http://www.nyphp.org/show_participation.php _______________________________________________ New York PHP Community MySQL SIG http://lists.nyphp.org/mailman/listinfo/mysql NYPHPCon 2006 Presentations Online http://www.nyphpcon.com Show Your Participation in New York PHP http://www.nyphp.org/show_participation.php
