Subject Re: [IB-Architect] Trigger Templates
Author Joseph Alba
>>
>> Delphi is limited to delegation because it does not have multiple
>> inheritance. Now, starting with Delphi 4 we have Interfaces,
>> which provide
>> some semblance of multiple inheritance
>
> I hardly can imagine a multiple inheritance of tables, but it should be
>possible with some restrictions. (I imagine the face of Jim reading this.)

I was refering to Delphi. But object-oriented analysis does present several
opportunities for multiple inheritance (although you'll have to flatten it
out in the implementation stage. Like in the mix-in example, you use mix-ins
if you want to give heterogenous objects a simlar feature. Like for
instance, if you want your tables to have that timestamp feature, you can
define the usual table, then also make the table inherit the "mix-in"
feature of inserted_by, insert_time, updated_by, updated_time, ... )

Illustration:

CREATE DOMAIN USERNAME VARCHAR(50);
CREATE DOMAIN USERTIME TIMESTAMP;

CREATE TABLE TIMESTAMP_MIXIN
(
INSERTED_BY USERNAME,
INSERT_TIME USERTIME
UPDATED_BY USERNAME,
UPDATED_TIME USERTIME
);

SET TERM ^ ;
CREATE TRIGGER INSERT_TIMESTAMP
FOR TIMESTAMP_MIXIN
BEFORE INSERT POSITION 1
AS
BEGIN
NEW.INSERTED_BY=USER;
NEW.INSERTED_TIME=CURRENT_TIMESTAMP;
END^

CREATE TRIGGER UPDATE_TIMESTAMP
FOR TIMESTAMP_MIXIN
BEFORE UPDATE POSITION 1
AS
BEGIN
NEW.INSERTED_BY=OLD.INSERTED_BY;
NEW.INSERT_TIME=OLD.INSERT_TIME;
NEW.UPDATED_BY=USER;
NEW.UPDATED_TIME=CURRENT_TIMESTAMP;
END^
SET TERM ; ^

CREATE TABLE PERSON
(
NAME
ADDRESS
...
);

CREATE TABLE CLIENT INHERIT FROM PERSON, TIMESTAMP_MIXIN
(
CONTACT_PERSON..
BALANCE ...
);

(So, all your non-virtual object tables - meaning the instantiated tables,
can inherit from their own hierarchical / logical ancestry, but you can
place a mix-in as a way to introduce a common feature that is really out of
the way when the ancestry is concerned - like, a Person object does not have
a Time_Stamp, but you want the instantiated rows to have time_stamps for all
your instantiated tables)

Just imagine how much cleaner the server code could be.
>> In fact, triggers can be loosely coupled to tables.
>
> Ah, you want them as Delphi's event handlers, where they can remain
defined
>in code even if no component is using them.
>

Exactly! If you notice, event handlers are just like triggers - if you think
of it, they are triggers.

>Just in case the new code has a bug?
>:-)
Hehe.... again, Teamwork, communication, cooperation... no finger pointing.
Just get the job done.
Here, we have a saying, "Sama-sama, sa hirap at ginhawa" (Together, in
difficulties and prosperity). That's our way of saying, one for all, all for
one.
>
> Me, too. Later, I realized that "internal implementation details" is not
>the best way to refer to the character of a person.
Boys will be boys.

Joseph Alba
jalba@...