Database / Mnesia basics Interview questions
What is a Mnesia transaction?
A Mnesia transaction wraps a set of reads and writes so they either all succeed together or none of them take effect — the same all-or-nothing guarantee a traditional database transaction provides, implemented here across Erlang processes and, if the table is replicated, across nodes.
mnesia:transaction(fun() -> mnesia:write(#person{id = 1, name = "Ada", age = 34}), mnesia:write(#person{id = 2, name = "Grace", age = 41}) end).
The function passed to mnesia:transaction/1 runs with automatic locking and rollback: if any
operation inside it fails (a conflict, an exception), Mnesia aborts the whole transaction and none of the
writes are applied. This is the safe, default way to interact with Mnesia data, and is what you should reach
for unless you have a specific reason to use faster, less safe "dirty" operations instead.
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...
