lua-users home
lua-l archive

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

> From:          Waldemar Celes <>
> Subject:       Re: Persistence
> To:  
> Date:          Wed, 19 Feb 1997 09:32:20 -0500 (EST)


I have been working away developing on the basis of your previous suggestions and 
have solved a number of problems.  I want to have a persistent database where 
the objects can reference each other.  In the example so far there are 
two types of object, books and authors, so one book may have several 
authors and also an author may write more than one book.  It is easy 
enough if there is a limit of one on each type of field, but I 
wanted to be more general than that.

I wanted to be able to save and restore the cross references and keep 
only one copy of the data in the database.  I have been able to do this up to a 
point.  The problem is with the lack of general persistence mechanism 
for numeric keys, on which I have posted to the Lua list today.   
This means that I can only tolerate numerically indexed tables with 
known names.  At the moment all mine are called 'entries' and I can 
have a structure as follows, omitting other nonnumeric keys.

FirstObject = {
entries = {}
SecondObject = {
entries = {}

FirstObject.entries[1] = SecondObject
SecondObject.entries[1] =FirstObject

BaseData {
entries[1] = FirstObject
entries[2] = SecondObject

The most vital thing is that an object exists, even as an empty 
table, before any reference to it is created, otherwise it is left 
out of the database.

I have some example code on this basis which is nearly complete.  I 
have not yet tackled deletion from the database.

I will cross post this to the list, although the previous discussion 
predates the list.  Somebody else may be interested in this 

John Fletcher
Dr John P. Fletcher          Tel: (44) 121 359 3611 ext 4625
Department of Chemical Engineering and Applied Chemistry (CEAC),
Aston University,            Fax: (44) 121 359 4094
Aston Triangle,              Email: J.P.Fletcher@ASTON.AC.UK
CEAC Web site