/**
  * Constructor.
  *
  * @param   string                    $table  Table name.
  * @param   string|array              $pk     Primary key.
  * @param   DatabaseAdapterInterface  $db     Database adapter.
  */
 public function __construct($table = null, $pk = 'id', DatabaseAdapterInterface $db = null)
 {
     // Implement JObservableInterface:
     // Create observer updater and attaches all observers interested by $this class:
     $this->observers = new \JObserverUpdater($this);
     \JObserverMapper::attachAllObservers($this);
     parent::__construct($table, $pk, $db);
     $this->relation = new Relation(new Table($this->table, $this->pk, $this->db->getDb()));
     $this->attachObserver(new RelationObserver($this));
     $this->observers->update('onAfterConstruction', array());
 }