/************************************************************/
/*                         emptyo                           */
/************************************************************/

/* :SUMMARY: referential integrity when deleting objects
:PRIORITY: 2
:STATUS: ok
:FEATURE: 
if object a references object b and object b does not exists, it is
created as an empty object. 
acedb automatically keeps referential integrity when the pointed-to
object is deleted. the deleted object is not visibile anymore.
(However the references to it from other objects are kept, see note below)
:HISTORY: 
:MODEL: 
?M T
   N ?N

?N T 
   M ?M

:DATA: 
:RESULT: 
at label rldn:
since object refn1 was deleted, it should not be findable via 
'Query NEIGHBOURS'.
However it is still kept in the data of the M-object:
--- emptyo._.rldn._.write ---
M : "refm1"
N	 "refn1"

NOTE: from a practical point of view this probably a good behaviour,
but it contrast the notion of referential integrity. I would like it
better the have the 'Delete' remove all memories of the deleted object.
Or, even better, to distinguish the two types of delete:
-Clear - would make the object empty and keep its name
-Delete - would completely remove the object, including references to it
This has been a long-discussed issue in ACEDB.

fails in: ace35b  -- shows both objects,
                     even the reference to refn1 is kept:
M : "refm1"
N	 "refn1"

N : "refn1"

fails in: ace950716  -- lists both objects, and additionally to ace35b
                        has the message 
!! No dumper available for object 1995-07-24_19:04:13_
                        which seems to indicate a bad internal pointer

works in: ace950829a4

:SCRIPT: */
emptyo: dbinit wspec.mini  // accessibility of empty objects
  tace
    // create one object via reference
    parse1: do parse $data/mini.ref.ace  // is:
                                   // M : refm1
                                   // N refn1
    rlfm: do find M
          show
    rln:  do Query NEIGHBOURS
          list                // contains only refm1, not refn1
    rlfn: do find N
          show                // finds an empty N-object (created via ref.)

    // fill the empty object created before
    parse2:  do parse $data/mini.refp.ace  // is:
                                     // N refn1
                                     // T
    rlpfm: do find M
    rlpfn: do Query NEIGHBOURS
           show                // contains both refm1 and refn1

    // delete the object that was previously created via refercence
    parse3: do parse $data/mini.refd.ace  // is:
                                    // -D N refn1
    rldfn: do Query find N                                                                            
           count                 // check that refn1 is gone
    rldfm: do find M

    rldn: do Query NEIGHBOURS
          show                 
          write
  exit