A common problem when dealing with relational databases is how to store additional data that might not be used for every record in a main table. For example: you might have a products table with the common main elements, but how do you store those specific bits of information that only relate to digital content, or dimensions, or available finishes or external specifications etc.
One solution (of many!) is to use a properties or parameters table. This is very basically a key:value table of properties (or parameters if you prefer) that allows for arbitrary information to be stored for a particular master record.
Scorpio comes bundled with a pre-rolled class called: baseTableParamSet that can work directly with these types of tables without requiring repetitive coding.
This tutorial will look at how to setup a database table for use with this object, the available options and possible issues you might encounter and then how it can be integrated into a main object that has been generated by the Scorpio class generator component.
For this tutorial you will need a copy of the Scorpio framework that has been configured and is ready to run. See the "Creating a Dev Environment" tutorial if this is your first project with Scorpio.
In addition you will need a database that has been configured for use with Scorpio. This tutorial uses MySQL. The database wll need at least one table. If you are struggling for an example, this tutorial will use the following table schema in a database called "crm":
- id int(10) PRIMARY KEY, AUTO INCREMENT
- username varchar(50) UNIQUE
- password varchar(64)
- email_address varchar(255)
- active tinyint(1) DEFAULT 0 KEY
- create_date datetime
- update_date datetime
- Building a DAO Object
- The baseTableParamSet
- Integrating baseTableParamSet into a DAO
- Conclusion and Extra Credits
This work is licenced under a Creative Commons Licence.