custom post types - Should wp_postmeta meta_key always be unique for a given post_id?

I am trying to figure out a good way to establish relations between various post types.For instance, consider a post typ

I am trying to figure out a good way to establish relations between various post types.

For instance, consider a post type lessontopic and another post type forumtopic. A Lesson Topic can have several Forum Topics. But a Forum Topic only is related to one Lesson Topic.

Seems I have 3 options if I want to use meta data to keep these relations straight (I use lt = lesson topic, ft = forum topic):

  1. Use a meta_value to store string of id's. This would be
post_id   meta_key             meta_value
lt_id     related_forumtopics  ft_id1,ft_id2,ft_id3
ft_id1    related_lessontopic  lt_id1
ft_id2    related_lessontopic  lt_id1
ft_id3    related_lessontopic  lt_id1
  1. Use meta_key itself to store relations for one to many situation
post_id   meta_key                   meta_value
lt_id     related_forumtopic_ft_id1
lt_id     related_forumtopic_ft_id2
lt_id     related_forumtopic_ft_id3
ft_id1    related_lessontopic        lt_id1
ft_id2    related_lessontopic        lt_id1
ft_id3    related_lessontopic        lt_id1
  1. Use key value pairs (where in the case of one to many like lesson topics to forum topics a given lesson topic post_id will have repeated key)
post_id   meta_key                   meta_value
lt_id     related_forumtopic         ft_id1
lt_id     related_forumtopic         ft_id2
lt_id     related_forumtopic         ft_id3
ft_id1    related_lessontopic        lt_id1
ft_id2    related_lessontopic        lt_id1
ft_id3    related_lessontopic        lt_id1

What do you think is better approach?

thanks!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744941071a4602325.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信