# File lib/dm-core/associations/relationship.rb, line 12
      def child_key
        @child_key ||= begin
          child_key = nil
          child_model.repository.scope do |r|
            model_properties = child_model.properties(r.name)

            child_key = parent_key.zip(@child_properties || []).map do |parent_property,property_name|
              # TODO: use something similar to DM::NamingConventions to determine the property name
              parent_name = Extlib::Inflection.underscore(Extlib::Inflection.demodulize(parent_model.base_model.name))
              property_name ||= "#{parent_name}_#{parent_property.name}".to_sym

              if model_properties.has_property?(property_name)
                model_properties[property_name]
              else
                options = {}

                [ :length, :precision, :scale ].each do |option|
                  options[option] = parent_property.send(option)
                end

                # NOTE: hack to make each many to many child_key a true key,
                # until I can figure out a better place for this check
                if child_model.respond_to?(:many_to_many)
                  options[:key] = true
                end

                child_model.property(property_name, parent_property.primitive, options)
              end
            end
          end
          PropertySet.new(child_key)
        end
      end