belongs_to :post # defaults to :required => truebelongs_to relationships will be required by default (the parent resource must exist in order for the child to be valid). You can make the parent resource optional by passing :required => false as an option to belongs_to.
How would one specify the the combination of two fields must be unique? For example categories must have unique names within a domain:
class Category include DataMapper::Resource property :name, String, :unique_index => :u property :domain_id, Integer, :unique_index => :u belongs_to :domain endSource: stackoverflow.com