NYCPHP Meetup

NYPHP.org

RFC: I'm building a data management framework

Adam Fields fields at surgam.net
Thu Oct 17 13:10:46 EDT 2002


The following is a high level description of a general system I'm
currently building. I'd love to get some feedback on whether such a
thing is interesting to you, and what features you'd like to see.

----------

Starting from a user perspective, there are a few levels, and at each
level you define the behavior of the system with an XML file (or
generate one from some interactive choices).

At the lowest level, you define datasets, which are made up of fields,
each of which has a data types. Each data set corresponds to a table
in the database, and each field you want to manage must be listed in
the description. I've imposed some restrictions on the structure of
the tables (this makes things a lot easier to dynamically manage, and
corresponds to my style in making relational databases, and I don't
think it's too restrictive, but I'm open to suggestions) :

- currently, you must use mysql. This will change eventually.

- each table must have an autogenerated primary key, named
"<tablename>_id"

- each table must have an integer field called "status"

- foreign keys must have the same field name in both tables

- if you want to support versions, each table must have a
corresponding table called "<tablename>_updates" with id, object
(blob) structure.

Field types correspond to commonly used html structures - text,
textarea, select (you can either specify the options in the definition
or specify a table to read name/value pairs from), date (which pops up
a calendar), image (which gives you a file choose box and saves the
uploaded file on disk).

Relations to other tables are handled in two ways - there's a field
type called "contains" that takes a data set as a parameter. Also,
data set types are supported - currently, I support "item" and
"relation". Item datasets represent single-item tables, which may
reference other tables with contains fields (1:n) relations. Relation
datasets represent n:n mapping tables and must contain references to
exactly two item datasets.

There's a script which will read the xml files and output the db
creation SQL (or connect to the database directly and just do
it). 

So... you've got all these datasets, which represent a relational
database structure. The system defines ways to operate on the
datasets, which are represented currently either by a single-screen or
a two-screen form and form handler. It doesn't currently support field
validation, but because of the structure, it would be fairly easy to
add. So for editing, all you do is hand the renderer a dataset name,
an appropriate mode, and an id for an existing item (unless you're
adding a new one), and it gives you a dynamically generated form for
doing so, based on your data definition. It also lets you do some
traversal of the relations to edit other connected items.

There's a dynamic display component as well, but the details are in
progress.

Any thoughts?

-- 
				- Adam

-----
Adam Fields, Managing Partner, fields at surgam.net
Surgam, Inc. is a technology consulting firm with strong background in
delivering scalable and robust enterprise web and IT applications.
http://www.adamfields.com



More information about the talk mailing list