Friday, March 31, 2017

which method is better to store meta-data (keywords and description) in Mysql (Laravel)?

There are "Articles", "News" tables. I want to allow admin to add meta tags like keywords and description when creating new articles or news. I have used laravel Polymorphic Relations and have two methods in mind to implement :

Method 1

meta_data Table:

id   metable_type   metable_id    meta_type      meta_content

1    news           4             description    php is a good...
2    articles       7             keywords       laravel,relation,tag
3    articles       2             keywords       php,developer,html

.

Method 2

meta_data Table:

id   metable_type   metable_id    meta_type      meta_content

1    news           4             description    php is a good...
2    articles       7             keyword        laravel
2    articles       7             keyword        relation
2    articles       7             keyword        tag
3    articles       2             keyword       php
3    articles       2             keyword       developer
3    articles       2             keyword       html

My Questions:

Is there a better approach than these two methods ? Which method is better?

User should be able to edit kewwords and descriptions for and article or news.



via Ahmad Mobaraki

Advertisement