Drupal: Namespace your CCK fields

Not aware of this until it was too late. All CCK field was stored in a flat container in table node_field. It's not unique per content type. That means you cannot have two fields with a same name although that field was used in different content type. From the UI, if you create field with a same name, it'll just append an arbitrary number such as _0, _1 to make it unique. Until you look at the db table or need to use that field within your code, you'll not aware of that.
Solutions:-
- If that particular field serve similar purpose, such as
addresswhich stay the same across content type, you can use shared field instead of creating new one. - If above not applicable, put a namespace (prefix) such as content type name to clearly identified to which content type that field belong. So instead of creating field
kategorifor both content typestoryandpagewhich would result infield_kategori_0,field_kategori_1, named the field asstory_kategoriandpage_kategori.
Consequence that we have right now which is too late to be fixed:-
db_name > SELECT field_name, type FROM node_field; field_borang | file field_objektif_0 | text field_fungsi_dan_aktiviti_0 | text field_piagam_pelanggan_0 | text field_misi_0 | text field_dokumen_artikel | file field_visi_0 | text field_alamat_jabatan | text field_nama_fail | file field_dokumen_0 | file field_negeri | text field_negara | text field_no_syarikat | text field_tarikh_daftar | date field_deskripsi_2 | text
Related: Understanding CCK data storage

