I’ve determined to revamp a plug I developed to make use of customized put up varieties and customized fields as an alternative of customized tables within the database.
I’ve some questions on abstracting knowledge into new put up varieties. These questions are based mostly on the idea that I ought to primarily be making an attempt to copy a relational database.
It is a dictionary characteristic for a language studying weblog. Listed below are the tables from the unique. Simplified for readability.
CREATE TABLE phrases ( ID int(), phrase 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(), instance varchar(), [...] );
Phrases will clearly be the primary customized put up kind.
I’ve determined to make use of customized fields for the noun and verb data as they’re 1:1 relationships and solely existed to scale back null entries within the phrases desk.
I imagine WordPress will solely create an entry within the postmeta desk if the fields are literally used. So that will clear up that downside.
Now the primary query is; ought to I retailer definitions and examples as customized put up varieties as I might in a relational database or simply use ACF repeaters? These are each real 1-many relationships. Though a single definition will most likely solely ever have a most of three examples.
The reader would possibly want to seek for key phrases throughout the definitions and/or examples however they’d by no means need to view a single definition as web page.
Definitions and examples would possibly nevertheless be used exterior the context of their respective phrase sooner or later. With a flashcard app for instance. Is it straightforward to uniquely determine and request a single entry from a repeater?