Database / Mnesia basics Interview questions
How do you write a record to a Mnesia table?
mnesia:write/1 inserts or updates a record inside a transaction — if a record with the
same primary key already exists, it's overwritten; otherwise a new one is added.
-record(person, {id, name, age}). mnesia:transaction(fun() -> mnesia:write(#person{id = 1, name = "Ada", age = 34}) end).
Because mnesia:write/1 must run inside a transaction context (typically via
mnesia:transaction/1 or mnesia:sync_transaction/1), Mnesia can guarantee the write is
applied consistently across every replicated copy of the table, or not at all if the transaction aborts. Trying
to call mnesia:write/1 outside of any transaction context raises an error, since there's no
transaction for it to participate in.
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...
