Admin issue: how to add many relations to one

Dear all,

I have one burning question. All replies are most welcome.

I have a "content type" which has quite many relations. Views are OK, but how tha hell can I create a admin module/site interface for this kind of content?

My initial idea was to have a different "content type"(work) for this one extreme content type, which could have many more different contents "attached" to that one spesific page. All of these extra fields are for one page "content page" only. Easy relations and all. Untill trying to figure out a proper Admin interface.

If I am going to use the sample schema as attached, I must force the "admin" user to save the blank page first, and then attach more content items. Does not sound so clever after that.

Have you implemented a similar "content type" / dilemma? All answears are most welcome.

Attached you can find a simplified schema of the problem I have.

DB schema:




CREATE TABLE `xxxx_work`

(

  `id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,

  `author_id` INTEGER DEFAULT NULL,

  `title` VARCHAR(128) NOT NULL,

  `content` TEXT NOT NULL,

  `tags` TEXT DEFAULT NULL,

  `image` VARCHAR(255) DEFAULT NULL,

  `thumbnail` VARCHAR(255) DEFAULT NULL,

  `created` DATETIME NOT NULL,

  `modified` DATETIME NOT NULL,

  CONSTRAINT `FK_author_work` FOREIGN KEY (`author_id`) REFERENCES `xxxx_user` (`id`) ON DELETE SET NULL ON UPDATE RESTRICT

) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


CREATE TABLE `xxxx_work_category`

(

  `id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,

  `author_id` INTEGER DEFAULT NULL,

  `name` VARCHAR(128) NOT NULL,

  `created` DATETIME NOT NULL,

  `modified` DATETIME NOT NULL,

  CONSTRAINT `FK_author_work_category` FOREIGN KEY (`author_id`) REFERENCES `xxxx_user` (`id`) ON DELETE SET NULL ON UPDATE RESTRICT

) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


CREATE TABLE `xxxx_work_award`

(

  `id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,

  `author_id` INTEGER DEFAULT NULL,

  `work_id` INTEGER NOT NULL,

  `title` VARCHAR(128) NOT NULL,

  `description` TEXT DEFAULT NULL,

  `image` VARCHAR(255) DEFAULT NULL,

  `created` DATETIME NOT NULL,

  `modified` DATETIME NOT NULL,

  CONSTRAINT `FK_author_award` FOREIGN KEY (`author_id`) REFERENCES `xxxx_user` (`id`) ON DELETE SET NULL ON UPDATE RESTRICT,

  CONSTRAINT `FK_work_award` FOREIGN KEY (`work_id`) REFERENCES `xxxx_work` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT

) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


CREATE TABLE `xxxx_work_image`

(

  `id` INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,

  `author_id` INTEGER DEFAULT NULL,

  `work_id` INTEGER NOT NULL,

  `title` VARCHAR(128) NOT NULL,

  `description` TEXT DEFAULT NULL,

  `image` VARCHAR(255) DEFAULT NULL,

  `thumbnail` VARCHAR(255) DEFAULT NULL,

  `created` DATETIME NOT NULL,

  `modified` DATETIME NOT NULL,

  CONSTRAINT `FK_author_image` FOREIGN KEY (`author_id`) REFERENCES `xxxx_user` (`id`) ON DELETE SET NULL ON UPDATE RESTRICT,

  CONSTRAINT `FK_work_image` FOREIGN KEY (`work_id`) REFERENCES `xxxx_work` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT

) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;



You can define a relation array in Model class.




public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

		'cityName'=>array(self::BELONGS_TO, 'City','city'),

		'stateInfo'=>array(self::BELONGS_TO, 'State','state'),

		);

	}



And also refer this link