[erlang-questions] mnesia: composite keys?

David King dking@REDACTED
Sat Jan 10 00:02:39 CET 2009


> Is tuples as keys common practice or A Really Bad Idea(tm)?

The table

line_item :: {order_no,item_no} -> {cost, quantity, comment}

should work just fine, the major downside would be that while there's  
an automatic index on the tuple {order_no,item_no}, and you can make  
an index on 'cost' or 'quantity', you can't make an index on  
'order_no' or 'item_no' (because they aren't really fields), so it  
makes asking for all of the items from a given 'order_no' a little  
harder

You could cheat by copying the 'order_no' or 'item_no' into the record  
and making an index on that, but you'd have to maintain that in the  
application




More information about the erlang-questions mailing list