2

I find Craft 3 to have a very clever database structure which eschews all of the issues I've seen with EAV.

Despite contrasting the differences between Craft 3's model and EAV, I'm having difficulty generating buy-in from the rest of my team who dismisses it as EAV. After so many times around the block, I wonder if it would help to point to a named database structure. I'm not looking for a comparison against EAV, rather a definition to provide my team.

Looked quite a bit and can't seem to pin down a name for Craft 3's database structure, is there one? If so, what?

Anecdote: one particularly snarky team member has taken to calling it "The Junk Drawer" after the content table. I sort of love it!

5

Craft uses a fairly typical relational model, where most1 custom fields have a single column in the content table, set to an appropriate column type chosen by the field type. Unlike EAV, which crams all data into a fixed schema, Craft’s schema will change over time based on the custom fields you’ve configured.

There are both performance and storage benefits to this. However there’s one significant downside, which is that it’s possible to hit row size limits if you have hundreds of custom fields (particularly with MySQL). We’re going to address that in Craft 4 by splitting the content table up into multiple tables – one per field layout.

1There are a couple exceptions: relational fields (like Entries) which store their data in the relations table, and fields that store nested elements such as Matrix and a couple third party field types, which create their own field-specific content-esque tables.

  • Thank you! Is there a downside to breaking the content table into one table per field layout? Part of the cleverness of how Craft uses the content table is there aren't multiple database fields for one admin-defined Craft field. Were customer's running into what seems like a ludicrous field limit? – Jacob Midtlyng Nov 12 '20 at 18:19
  • 1
    No significant downside; most queries should look about the same, possibly with a couple additional JOINs, depending on the number of content types being queried at the same time. Yeah, people do hit it from time to time (there are some pretty intense content models running on Craft). – Brandon Kelly Nov 12 '20 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.