Storing Complex Data in Tables
One of the disadvantages of using a conventional DBMS is that there are a limited number of data types you can store in a table column. You can store an integer, a string, a float, and so on. But if you want to store a complex object, then you’re in trouble. So, for example, if you’re a Java programmer, storing a Java object in a SQL database is pretty messy.
Mnesia is designed to store Erlang data structures. In fact, you can store any Erlang data structure you want in an Mnesia table.
To illustrate this, we’ll suppose that a number of architects want to store their designs in an Mnesia database. To start with, we must define a record to represent their designs.
| test_mnesia.erl | |
| | -record(design, {id, plan}). ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access