Database Queries
Once we’ve created our database, we can start playing with it. We’ll start by looking at Mnesia queries. As you look through this, you might be surprised to see that Mnesia queries look a lot like both SQL and list comprehensions, so there’s actually very little you need to learn to get started. In fact, it really isn’t that surprising that list comprehensions and SQL look a lot alike. Both are based on mathematical set theory.
In all our examples, I’ll assume that you have created a database
with two tables called shop and cost. These
tables contain the data shown in Table 8, The shop Table and Table 9, The cost Table.
Item | Quantity | Cost |
apple | 20 | 2.3 |
orange | 100 | 3.8 |
pear | 200 | 3.6 |
banana | 420 | 4.5 |
potato | 2456 | 1.2 |
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