Oxyaction / yii2-polymorphic-relation-behavior

Behavior that helps to establish polymorphic relations easily.
MIT License
11 stars 4 forks source link

SQL structure #1

Closed danDanV1 closed 6 years ago

danDanV1 commented 6 years ago

Could I see an working example of what the SQL structure could be for each table in the example?

danDanV1 commented 6 years ago

or just a list of columns for each table would help.

Oxyaction commented 6 years ago

Hi, in example listed in docs for has many relation it will be article table: id, title, banner, text, author_id photo table: id, img_path, author_id comments table: id, comment, author_id, external_id, type where external_id is id of the record in either photo or article table and type is the type of entity to which current comment relates (photo or article) it specified by polymorphicType attribute in behavior configuration

danDanV1 commented 6 years ago

Perfect. Totally makes sense now. Thank you.

For many-to-many would it be as follows: taggable_tag table: id, tag_id, external_id, type

tag table: id, tag_name

article table: id, title, banner, text, author_id

photo table: id, img_path, author_id

Oxyaction commented 6 years ago

yes, it's correct