gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnumed-devel] gmrecalls.sql


From: Horst Herb
Subject: Re: [Gnumed-devel] gmrecalls.sql
Date: Sun, 12 Jan 2003 10:25:18 +1100
User-agent: KMail/1.4.3

On Sat, 11 Jan 2003 19:25, Ian Haywood wrote:
> > create view identity as select
> >       int dblink_tok (t1.ptr, 0) as id,
> >       dblink_tok (t1.ptr, 1) as pupic,
> >       dblink_tok (t1.ptr, 2) as gender,
> >       date dblink_tok(t1.ptr, 3) as dob,
> >       dblink_tok (t1.ptr, 4) as cob
> > from (select dblink ((select conn from remote_dbs where
> > service='demographica'), 'select id, pupic, gender, dob, cob from
> > identity') as ptr) as t1;
>
> I have realised this is unworkable: it would transfer the whole table just
> to find one tuple. dblink () needs to be called each time we need it.

Perhaps we should use some middle ware after all.
Curently, I am considering writing a high level interface to the demographic 
part of the database, which then would get a XML-RPC plug-on that would allow 
gnumed's "address book" in a very generic way.

Referential integrity could be achieved by whatever entity requesting 
information from the demographic database, posting a reference count 
increment to the demographic database if that entity refers to the requested 
information internally.

Like:
server = xmlrpclib.Server('http://localhost:8000')

id = server.search("Horst", "Herb", "24.02.1963")
#returns a list of ids that match the search criteria
if len(id) > 1:
        #handle ambiguous result

person = server.retrieve("full details", id)
#returns a dictionary conatining all demographic details of a person 
identified by the id

#do something that references id in another database
response = server.secure_external_reference("identity", "id", id)
if response:
        print "Can't ensure external reference integrity!"

# changed my mind, don't need this reference
response = server.release_external_reference("identity", "id", id)
#this decreases the reference counter


What happens on the backend:

1.) there is a table "external_refcount":
create table external_refcount (table oid, refcnt integer);

2.) There is a trigger function "on delete" for any table that may be 
referenced externally, that checks the refcount for this table and refuses 
the delete as long as the refcnt is not down to 0.

Of course, functions that add something to a database will automatically 
increase the external reference count.

Comments? I need to do this anyway, in order to facilitate data exchange with 
"Oscar". I promised David Chan in L.A. I would do it, simply to state an 
example how such differently desingned projects could exchange data.

Horst




reply via email to

[Prev in Thread] Current Thread [Next in Thread]