[erlang-questions] mnesia: composite keys?

Peter Sabaini peter@REDACTED
Sat Jan 10 00:39:57 CET 2009


On Saturday 10 January 2009 00:02:39 David King wrote:
> > 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

Yep, I thought so -- but this won't be an issue for my app. 

Thanks, all.
peter.

> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090110/f0b2afd6/attachment.bin>


More information about the erlang-questions mailing list