Verizon cell phones

Understanding Drupal Nodes

Drupal logo
One of the most basic things in Drupal is the concept of a node. This article will give an overview of Drupal nodes so administrators and developers can get a better sense of it.

What is a Drupal node?

For those who know object oriented programming, this should be easier to grasp. A Drupal node is in essence an object.

Imagine that you wanted to create a website offering reviews of movies. You have access to several standard Drupal node types to create your content. You can write a story, create a blog, or even roll your own custom Drupal movie node.

In object oriented design, you would write down all the nouns in the application like movie title, actors, and producers. You could use the Drupal movie node by creating it with the very handy Content Construction Kit (CCK).

Drupal Node Properties

Every Drupal node has properties, just like objects:

  • node id - a unique identifer
  • version id - a unique identifer that identifies the node of the current version
  • title - the title of the node
  • type - the type of node (story, blog, page, etc.)
  • created date - the date the node was created
  • language - the language the node is stored in
  • user id - the author identifier of the node
  • status - the nodes status (busy, active, etc.)
  • change date - the date when the node's content was modified

Notice that there is no mention of the actual data the node stores. This is because Drupal has a versioning system that lets authors store revisions of the Drupal node. In the node definition above is the version identifier. This identifies the current node.

Drupal Node Revisions

To get a better handle on this, lets say you want to write a story about Drupal programming. If you write a draft of a story you can mark it with revision information "draft" when you add the node the first time. Then when you come back later to polish the story, you can give it version "1.0". In this case, two copies of your story will be stored in the database. But how does Drupal know which version is current?

The last version is the current version and is held in the version identifer in the properties above.

The node_revisions database table holds the node data. It has the following properties:

  • node id - a unique identifer
  • version id - a unique identifer that identifies the version identifier node in the revisions table
  • user id - the author identifier of the node
  • title - the title of the node
  • body - the contents of the node
  • teaser - a small snippet of content used as an intro to a node
  • timestamp - the time the node was modified
  • log - the version number

When nodes are created, the node id and the version id are the same. As revisions are made the version id changes and refers to a version node in the revisions table. You can never delete the current version but can delete older versions.

That's pretty much the basics of Drupal nodes. Many people get confused on what nid and vid is in the database tables. Now you know!

Filed under: