Database / Mnesia basics Interview questions
What are the attributes of a Mnesia table?
A table's attributes are simply the ordered field names describing the shape of each record it stores — equivalent to column names in a relational table, though here they correspond directly to an Erlang record's fields.
-record(person, {id, name, age}). %% attributes: id, name, age
The attributes option passed to mnesia:create_table/2 is what declares this list,
almost always sourced from record_info(fields, RecordName). The first attribute in the list is
always the primary key; every other attribute is just a regular field you can read, write, and (if indexed)
query on. Every record written into the table must have exactly this shape — the same tag and field
count as the record definition the table was created from.
More Related questions...