admin管理员组文章数量:1435534
I have decided to redesign a plug I developed to use custom post types and custom fields instead of custom tables in the database.
I have some questions about abstracting data into new post types. These questions are based on the assumption that I should essentially be trying to replicate a relational database.
It's a dictionary feature for a language learning blog. Here are the tables from the original. Simplified for readability.
CREATE TABLE words (
ID int(),
word varchar(),
parent_id int()
);
CREATE TABLE nouns (
word_id int(),
plural varchar(),
[...]
);
CREATE TABLE verbs (
word_id int(),
pres_part varchar(),
past_part varchar(),
[...]
);
CREATE TABLE definitions (
ID int(),
word_id int(),
definition varchar(),
[...]
);
CREATE TABLE examples (
ID int(),
defintion_id int(),
example varchar(),
[...]
);
Words will obviously be the first custom post type.
I've decided to use custom fields for the noun and verb information as they are 1:1 relationships and only existed to reduce null entries in the words table. I believe WordPress will only create an entry in the postmeta table if the fields are actually used. So that would solve that problem.
Now the main question is; should I store definitions and examples as custom post types as I would in a relational database or just use ACF repeaters? These are both genuine 1-many relationships. Although a single definition will probably only ever have a maximum of 3 examples.
The reader might wish to search for keywords within the definitions and/or examples but they would never want to view a single definition as page.
Definitions and examples might however be used outside the context of their respective word in the future. With a flashcard app for example. Is it easy to uniquely identify and request a single entry from a repeater?
本文标签: custom post typescustom fields and normalization
版权声明:本文标题:custom post types, custom fields and normalization 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744538214a2611443.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论