Last updated 28 April 2017. Created on 16 September 2012.
Edited by ursula, yogeshchaugule8, BehradKhodayar, rpayanm. Log in to edit this page.

Drupal 5

...

Drupal 6

...

Drupal 7

See Database API for a detailed documentation. For a quick reference, the following Drupal 7 database entity relationship diagram might be helpful (for another more up-2-date version see https://www.drupal.org/node/2360815):
db_schema_drupal_7 Credits: http://upsitesweb.com/blog/2011/06/drupal-7-database-schema.

Drupal 8

Detailed information is available at the Drupal 8 Database API page. For a quick reference, see the Drupal 8 database E/R diagram below (Drupal 8 from 10/19/2013):D8 Database Schema

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

ssoulless’s picture

I have a question, in the D7 entity relation ship diagram, there is a relation between users and comments but that relation is one-to-one

why? if an user can have from 1 to many comments, that is confusing me a little bit. If someone can ask my question would be appreciated.

And also how is the fields connected with the nodes? I cannot see the connection of fields and nodes or node types, souldn't exist a relation one-to-many between the node type and fields?

Srry if my questions are stupid Im just still learning

bart atlas’s picture

Hi ssoulless, it's a good question. I notice that other relationships are not according to usage in Drupal, for example the diagram (D7) shows many users involved in one users_roles record (crowsfeet on users table) and many roles involved in one users_roles record.

I believe the correct way to show those relationships would be to have crowsfeet on the users_roles and double bar on the users table end; and crowsfeet from users_roles to double bar on roles table. One user can have multiple user-roles and one role can participate in multiple users-roles.

This page has some good info and better diagrams, also a downloadable MySQL model to play with:
http://posulliv.github.io/2012/08/02/drupal-er-diagram/

I realize this reply is late, but hopefully it will be helpful to others.

ClemensM’s picture

The one from posulliv.github.io is in fact more thoroughly and fixes that mistake.

However, I still don't unterstand why it is a "only one ←→ one or more" relation? Isn't it in real a "only one ←→ zero or more" relation??
Since after all a user CAN ALSO HAVE made zero comments.

Same is the case for '[node]←→[comment]' and would guess some more (...in fact both diagrams show no "zero or more" symbol at all :o)

( if it would be '[person]←→[birth place]' the "1/more" would be the right connection, beause a person MUST have been born somewhere )

Who can solve this confusion?

ursula’s picture

This was my first stab at mysql workbench, and I didn't know how to use the tool, specifically how to access the options for relationships. As you can see, it was years ago. The raw file is available through the upsitesweb link.

hondaman900’s picture

Do you have a version of your site where the database schema diagrams you created are larger/legible, or are linked to the larger versions to allow for reading?

Thank you for your work on this.

ursula’s picture

@hondaman900 when I right click and download the image, I get the full-size version.
Also: If anybody wants to correct errors in the diagram: The mysql workbench file is available on the upsitesweb link (in the credit line). Edit, save, and replace the current image.

hondaman900’s picture

Thank you for the quick reply.

When I right-click and download the image I get all_drupal_7_er.png which is a small 402x384 px image. Perhaps I'm missing something. I'm doing this on the first image in your article.

Thanks for the assistance :)

ursula’s picture

You should be able to get the full size image using https://www.drupal.org/files/er_db_schema_drupal_7.png
If you still don't get it, just email me at upieper@gmail.com, and I'll send it back by email.

yogeshchaugule8’s picture

Is there any documentation available regarding detailed database structure in Drupal8. I'm looking for details on which table is used for storing what details. Many tables are easy enough to understand what they store, except key_value, and key_value_expire. It would be good if we can have something like "Drupal 7 core tables" for Drupal 8 tables as well.

bwinett’s picture

Seems to be out of date. For example, after installed 8.2, I see that the node table contains a column named langcode, which is not in the above diagram.

parth.kukadiya’s picture

Above diagram is out of data as in latest Drupal 8 installation we have changes in the users and users_data table. users table contains only uid, uuid and langcode columns while users_data contains uid, module , name , value and serialized columns.