No, actually, the model that has a $has_one
relationship set will have a field ending in _id,
which refers to the object with the $has_many
relationship set.
So, for example:
class Recipe extends DataMapper {
var $has_many = array('product', 'rating', 'recipe_category');
var $has_one = array('recipe_source', 'user');
(...)
}
class Recipe_Source extends DataMapper {
var $has_many = array('recipe');
(...)
}
In this case, DataMapper made a table recipes
with a recipe_source_id
column, and a recipe_sources
table that required no extra fields.
Now, for many-to-many relationships, a join table will be created, and it follows a strict convention.
The join table name will be the two plurals of the joined models, separated by an underscore, in alphabetical order.
So, using this model:
class Product extends DataMapper {
var $has_one = array('cheese_style', 'butter_style', 'cheese_flavor');
var $has_many = array('product_size', 'recipe');
(...)
}
Now, I end up with a join table in my database called products_recipes.
This is how it is handled by the DMZ DataMapper library (http://www.overzealous.com/dmz/), which is supposed to be a drop-in replacement for the old stensi DataMapper library, so I'm going to assume the conventions are the same.
Even so, I highly recommend making the switch to DMZ.