(Tips) What is the Content Construction Kit? A View from the Database

Tips : What is the Content Construction Kit? A View from the Database

The Content Construction Kit (CCK) began as a natural evolution from the popular Flexinode module. The Flexinode module allowed you to define your own content types (a blog entry, a recipe, a poll, etc) with a number of custom fields. CCK also allows you to do this, but in a more powerful way.

  Content types and the content.module  

With Drupal 5, you can create your own content types. The default installation comes with Page and Story content types, which are included for historical reasons. You can delete these and create your own content types, or modify them to suit your needs.

CCK allows you to extend the data model of content types through the addition of fields such as a date, an image, an email address, etc. The core CCK module is the content.module. The content.module is the workhorse that handles CCK's main goal of extending content types with these new fields. Therefore, it is logical that the content.module manages its own database table for every content type you have defined. This includes the built in Page and Story types.

When you install and enable content.module, it creates tables for every content type you currently have. Here is the schema for the table it creates if your Drupal installation has a Page content type:

 

mysql> describe content_type_page;
+-------+------------------+------+-----+---------+-------+
| Field | Type             | Null | Key | Default | Extra |
+-------+------------------+------+-----+---------+-------+
| vid   | int(10) unsigned | NO   | PRI | 0       |       |
| nid   | int(10) unsigned | NO   |     | 0       |       |
+-------+------------------+------+-----+---------+-------+

vid and nid are the bare minimum fields needed to extend a content type.

As you can see, the content_type_page table is an empty shell at this point, only having columns for vid (revision id) and nid (node id).

[Read more..]

Courtesy : Lullabot.com