3

I have been currently learning Drupal while trying to duplicate a Drupal application into CakePHP.

I have been looking at the database tables to know where data is being stored so I can safely migrate any data or study how it is working.

I have researched and have come across questions like:

Where does Drupal store the content of a node's body? Where does Drupal store NODE data?

So far, I have only seen the title in my Drupal (7) installation.

What I have seen in my node revisions table for a recipe content type, which includes fields like, field_ingredients, field_instructions, field_description, field_preptime, field_cookingtime, just the title of the recipe. This is a sample record on my node_revision table.

nid   |  vid  |  title         |  log   | timestamp  | status | comment | promote  | sticky
-------------------------------------------------------------------------------------------
1     |  1    |  Awesome Sauce |        | 1369998600 | 1      | 2       | 1        | 0

As you can see I can only see the title. Where are the other field contents?

3 Answers 3

8

Drupal 6 stored it's content in one table per content type. CCK will adhere to that unless you share a field among several nodes, in which case the fields will be broken out to a separate table.

Drupal 7 creates a new table for every field, so you'll see a lot of tables named field_data_[name_of_field], and field_revision_[name_of_field], the former for the active data, and the latter for tracking any other revisions of the same data. You might be interested in this discussion How to disable the revision feature completely? if you don't need the revision functionality.

Use the entity_cache module to alleviate some of the performance hit from all the joins this causes on complex content types.

If you need an entity that is complex enough to make the D7 approach unusable, consider creating a custom entity where you make properties of your fields. That costs a bit of flexibility, but will make Drupal store the content like the title, which is a property, in the types table.

1
  • @Dudepal Yes, it does.
    – Letharion
    Jun 4, 2014 at 11:29
1

In Drupal 7 all the fields in the base table are known as properties, like the title and other fields in your case. All the other fields like body image and many other which you create are stored in other tables. Actually, Drupal make a separate table for every field in the database and store the primary key of the entity bundle (article, basic page) in that field_table as a foreign key. Basically Drupal make two tables for every field 1: is for storing the data (field_data_[name_of_field]) and 2: is for revision (field_revision_[name_of_field]).

-1

It is stored in node_revisions table. fields are stored in a new table for each field. so field_description would have a table called field_data_field_description

1
  • Your answer is for Drupal 6. In Drupal 7 body is a field just like any other.
    – Mołot
    May 31, 2013 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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