Home arrow MySQL arrow Page 5 - Data Management Made Easy Using Nennius: Advanced Data Handling

Creating Component Dependencies - MySQL

Welcome to part three of this tutorial introducing application development for the Nennius engine. In this article, we will enhance the News Manager application from part two.

  1. Data Management Made Easy Using Nennius: Advanced Data Handling
  2. Advanced Application Configuration
  3. Expanding Our Application Menu
  4. Creating the User Comments Component
  5. Creating Component Dependencies
  6. Component Notes
  7. Help Files
  8. File Attachments
By: Brian Vaughn
Rating: starstarstarstarstar / 6
August 03, 2005

print this article



Now that we have created an association between our Comments component and the previously created News component, a potential problem presents itself. What happens if a user deletes a News entry which contains one or more Comment entries (attached)?

Nennius offers a simple solution for this scenario as well. Simply update the following data found in the DB Field array in the News component file ('/components/news.php'):

# define primary key attribute for news table

$f_db_info_array['id'] = (

        array (

               'db_field_name'        => 'id',

               'db_field_type'        => 'int',

               'db_field_length'      => 3,

               'db_primary_key'       => TRUE,


               # field is hidden from visibility at all times

               'hidden_all'           => TRUE



        # setup dependency information to clean all associated comments as well upon deletion

        'db_dependency_tables'         => array(

                                              array ( 'db_table_name'        => 'comments',

                                                     'db_field_name'        => 'news_id',

                                                      'db_display_name'      => 'Comment' )


        'db_dependency_flush'          => TRUE


As you can see we've added two array keys to the 'id' descriptor array: 'db_dependency_tables' and 'db_depencency_flush'. The first, 'db_dependency_tables', contains an array of arrays - each array specifying information about a unique record dependency. Since only one dependency exists in our example application, only one array has been specified.

The second variable, 'db_depencency_flush', contains a boolean value that tells Nennius how to act in the event that a News record (with one or more Comments records attached) is deleted. In our case we specified 'TRUE', which means that all associated Comments will also be deleted. (Note: If we had specified 'FALSE' then Nennius would have refused to delete any News releases with one or more User Comments attached.)

>>> More MySQL Articles          >>> More By Brian Vaughn

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates


Dev Shed Tutorial Topics: