Database Compactness?
[1/2] from: robbo1mark::aol::com at: 21-May-2002 9:43
This is one for the guru's or Rt staff,
Which of the following provides a more compact and secure representation for a database?
an object!
db1: context [ group1: [#1 "A Value"] ]
or a block!
db2: reduce [ 'group1 [#1 "A Value"] ]
They both allow path retrieval ie.
>> db1/group1/#1
== "A Value"
>> db2/group1/#1
== "A Value"
>>
As well as insertions / removals
>> append db1/group1 [#2 "A Thing"]
== [#1 "A Value" #2 "A Thing"]
>> probe db1
make object! [
group1: [#1 "A Value" #2 "A Thing"]
]
>> append db2/group1 [#2 "A Thing"]
== [#1 "A Value" #2 "A Thing"]
>> probe db2
[group1 [#1 "A Value" #2 "A Thing"]]
I welcome help / opinions on this matter for the REBOL-TRIPLES project to design and
create REBOL/ASSOCIATES database which aims to produce a "Sentences" like product with
associated model database.
thanx,
Mark Dickson
[2/2] from: ingo:2b1 at: 21-May-2002 23:49
Hi Mark,
[Robbo1Mark--aol--com] wrote:
> This is one for the guru's or Rt staff,
>
> Which of the following provides a more compact and secure representation for a database?
>
> an object!
>
> db1: context [ group1: [#1 "A Value"] ]
>
> or a block!
>
> db2: reduce [ 'group1 [#1 "A Value"] ]
I don't know about the security aspect, but think they'd be equal.
Comparing creation time / space efficency, blocks clearly win
I'd _guess_ that objects are faster for lookups, but I don't know.
(And using hashes instead of blocks is the worst for creation time /
space, but I don't know how it works for lookups.)
> They both allow path retrieval ie.
>
>>>db1/group1/#1
>>
> == "A Value"
<..>
> As well as insertions / removals
>
>>>append db1/group1 [#2 "A Thing"]
>>
> == [#1 "A Value" #2 "A Thing"]
<..>
But there would be a problem when it comes to adding a new group to the
object! case, I don't know if this might pose a problem in this specific
case, though.
I hope that helps,
Ingo