Forum OpenACS Q&A: Difference between Data Model & Data Source

I'm not quite sure of the difference between a data model and data
source... can somebody explain?


A data model is the way you describe the data you want to store.  For example, a simple data model could be described in SQL as:  CREATE TABLE EMAILS(name varchar(100), email_addr varchar(100) ).

A data source usually refers to a way to describe the exact database you are talking to.  For instance, there may be multiple databases running on a machine, so in order to specify which database you want, you might use a string like "localhost:5432:patrick" to specify that the machine name is "localhost", the TCP/IP port to connect to is "5432" and the name of the database is "patrick".

Usually there are slight differences in the format of the data source depending on which database server (Postgres, Oracle, Sybase) you are using.

In OACS templating terminology a "data source"  means the .tcl script (associated with an .adp) that queries the database or otherwise computes the values & variables that the graphic designer can then use in the .adp.
Posted by Andrew Zeon on
How does the adp file determine/find/locate the associated tcl file?
Perhaps by looking for a .tcl file with the same file name (e.g.
cal-item.adp will look for cal-item.tcl)?
Posted by Brian Fenton on
It's the other way around, Andrew! ;-) You tell the .tcl file where to find the .adp by including this line in your .tcl:

ad_return_template "cal-item"

If the .adp has the same name as the .tcl, just type:

ad_return_template ""

This way you can have more the same .adp used by more than one .tcl.

I found it useful to study other people's code i.e. look in packages/ticket-tracker/www/admin

While we're on the topic, does anyone care to nominate any individual package as the Oscar winner for Best Coded Package? People new to OpenACS could then be pointed at that as a good example of OpenACS coding.