Hi,

I'd like to add some data to my drupal forum, and i dont really undertand the database model/scheme. Can somebody point me to some documentation? For example i need to understand the role of node, vocabulary, term_data tables and what is tid,vid,nid fieds... Then i could add data the sql way.

Regards,

Jam

Comments

agentrickard’s picture

Best bet is the online API: http://api.drupal.org/ and reading through the Forum.module code.

See also the general module overviews here: http://drupal.org/handbook/modules

--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.

cog.rusty’s picture

I don't think complete documentation for Drupal's database schema exists. Here are a few things that I have found:

An ongoing attempt with comments for Drupal 6
http://drupal.org/node/79874

An analysis with SchemaSpy
http://webdevgeeks.com/schemaspy/index.html

About the taxonomy part (important for the forum module)
http://blog.riff.org/2005_11_27_grokking_drupal_the_taxonomy_system
http://blog.riff.org/files/Taxonomy8.png

Now, the forum module relies heavily on taxonomy and comments.

  • The whole forums structure is a dedicated single-hierarchy taxonomy vocabulary (vid)
  • Forum containers and sub-containers are terms (tid) from this vocabulary, but tid is still unique.
  • Forum topics are nodes (nid), which can have revisions (vid again -- watch out)
  • Forum replies are comments (cid).

The forum vocabulary is not replaceable by the user -- its ID and its required settings are in the 'variable' table, and these required settings are greyed out or removed in the taxonomy categories GUI.

There is also a forum table (tid, nid, vid). 'vid' here is the node revision ID and it is the primary key. The same data are also stored in 'term_node' (tid, nid) -- which however is "many to many" -- and in 'node_revision' (nid,vid).

This is by no means a thorough description. Besides the obvious tables involved here, there are other, more or less obvious for tying this to the whole system. For example, the 'files' and 'file_revision' tables are more obvious while the fact that the max ID added for a nid, tid etc must be recorded in a variable in the 'sequences' table is not so obvious.