Re: MultiValue Databases
Date: 9 Jun 2005 11:50:57 -0700
Message-ID: <1118343057.074542.68230_at_g47g2000cwa.googlegroups.com>
> > What enforces the integrity between multiple 222-2222?
> Can you please answer these about your own system, Neo?
The db-engine enforces the referential integerity between the one and only original phone# instance named 222-2222 and the remaining references to it. In the 1st line of the script below, xrdb searches for a phone# instances named 222-2222. Not finding one, it create a new phone# instance and names it 222-2222. In the 2nd line, xrdb finds the existing phone# instance named 222-2222 and thus refers to the original. The optional "+" sign before the 222-2222 tells xrdb to search for an existing thing else create it. In the 3rd line, phone# instance named 333-3333 with ext# 777 is created explicitly and then related as bob's phone#.
(CREATE john phone# +222-2222) (CREATE mary phone# +222-2222) (CREATE bob phone# (CREATE phone# inst *333-333 & it ext# +777))
> It doesn't support constraints does it?
The only constraint enforced at the db-engine level is that references to things be valild. Constriants, such as every instance of person must have two arm, are not enforced by db-engine at this time (may be implemented later). Currently it is upto the user/application to enforce such and higher level constraints.
> what stops john from being mary's phone number? nothing!
The user/application utilizing xrdb would need to implement this constraint. The db-engine does not prevent a relation between anything. The following is script (in development) adds a person named John with SS# 111, if he is not in db already. Similar constraint is also possible in user's code when db is managed via API.
// Script to implement a simple constraint. // Create a person named John with ss# 111, // if he does not already exist.
(IF NOT((person inst * & * name john & * ss# 111))
(CREATE person inst * & it name john & it ss# 111) )
// Psuedo c code to implement a simple constraint.
query = NLI_Select("person inst * & * name john & * ss# 111");
if (!X(query)){
NLI_Create("person inst * & it name john & it ss# 111");
}
See www.xrdb.com/example/ex004b.asp for actual similar code. Received on Thu Jun 09 2005 - 20:50:57 CEST