Database / Mnesia intermediate to advanced Interview questions
What is the difference between mnesia:match_object/1 and mnesia:select/2?
Both let you query beyond a simple primary-key lookup, but match_object/1 uses a simpler,
pattern-only interface, while select/2 supports full match specifications with guard conditions.
| mnesia:match_object/1 | mnesia:select/2 |
| A single pattern with `'_'` wildcards; returns whole matching records. | Pattern + guard conditions (e.g. comparisons) + a custom result shape. |
| Simple to write for straightforward field-equality matches. | More expressive: supports `>`, `<`, `andalso`, and returning only specific fields. |
mnesia:match_object(#person{age = 30, _ = '_'}). %% vs. mnesia:select(person, [{#person{age = '$1', _ = '_'}, [{'>', '$1', 30}], ['$_']}]).
Use match_object/1 for a quick equality-style filter; reach for select/2 once you
need comparisons, combined conditions, or a projection that returns less than the full record.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
