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):
- 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
- 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
- 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条)