Record-relational mapping support
It would be very nice to have the possibility to create joins/have the mechanism of changes propagation and cascade deletes. As the first step to have tune mnesia to act like a standard relational DB, we have to define at least 3 types of behaviours.
The data used in the proposal is as follows:
#boss{id = integer(), cars}
#car{id = integer(), owner}
One to One
One car can belong to one boss only. The car knows about its owner, the owner knows about the car (only the ids are stored in the db).
One to Many
One boss can possess multiple cars: the car does not know about the owner, so the data is stored only on the boss side.
Many to Many
Cars can belong the multiple owners, owners can have multiple cars. Ids are stored on the both sides of the records.
Implementation
Since only ids of the particular entities are stored, we have to define some additional operations that will allow us to use this extension:
read/2 and read_flat/2 - both operations are used for the database reads, the first one reads the data with one-level deep (while reading #boss it will also read the cars contents, but if car has e.g. multiple drivers, the ids won't be expanded to the full record versions). The latter function would be 0-level deep read.
- the basic type one_to_many (and other related types) should provide some parameters for:
- displaying the connected item
- switch for specifying the cascade delete behaviour (enabled/disabled)
