/**
  * {@inheritdoc}
  */
 protected function normalizeDefinition()
 {
     $definition = parent::normalizeDefinition();
     foreach ($this->outerRecords() as $record) {
         if (!in_array($record->getRole(), $definition[RecordEntity::MORPHED_ALIASES])) {
             //Let's remember associations between tables and roles
             $plural = Inflector::pluralize($record->getRole());
             $definition[RecordEntity::MORPHED_ALIASES][$plural] = $record->getRole();
         }
         //We must include pivot table database into data for easier access
         $definition[ORM::R_DATABASE] = $record->getDatabase();
     }
     //Let's include pivot table columns
     $definition[RecordEntity::PIVOT_COLUMNS] = [];
     foreach ($this->pivotSchema()->getColumns() as $column) {
         $definition[RecordEntity::PIVOT_COLUMNS][] = $column->getName();
     }
     return $definition;
 }
 /**
  * Normalize schema definition into light cachable form.
  *
  * @return array
  */
 protected function normalizeDefinition()
 {
     $definition = parent::normalizeDefinition();
     if (empty($this->outerRecords())) {
         return $definition;
     }
     //We should only check first record since they all must follow same key
     if ($this->getOuterKey() == $this->outerRecords()[0]->getPrimaryKey()) {
         //Linked using primary key
         $definition[ORM::M_PRIMARY_KEY] = $this->getOuterKey();
     }
     return $definition;
 }