On 10/14/2014 10:37 AM, Rex wrote:
> Jan,
>
> That's quite helpful! It is very convenient to use dicts here.
>
> One further question is for the case when two or more attributes contain
> multiple values, then we need (m x n x k) lines to represent one record,
> where "m, n, k,.." are the number of multiple values of corresponding
> attributes of a record.
>
> With my early representation as follows,
> tableName(attribute1(PK, value)).
> tableName(attribute2(PK, value)).
>
> it only takes (m+n+k+...) lines to represent a record. But as Jan
> mentioned, this representation will not benefit from the JIT indexing.
>
> Can we store multiple values of an attribute as a list in the dict?
> for example,
> p{a:[A1, A2, A3], b:[B1, B2], c:[C]}.
I didn't suggest using dicts for storing, but for providing a nice
frontend to the programmer. I think you got that though. Yes, you
can store values as
tableName(object, attribute, [value1, value2, ...])
That is fine if you don't want to ask the question "Which object has
value X as attribute?". If you do want to answer that question quickly,
you'll need
tableName(object, attribute, value1).
tableName(object, attribute, value2).
Of course, you also have this, which might be interesting if you have
high-arity tables. It all depends on the data, the ways you want to
access it and the famous time/space tradeof.
tableName(object, attribute, record0001).
value(record0001, value1).
value(record0001, value2).
...
That is why it is wise to abstract the access from the concrete
datastructure. That also allows you to move to an external DB,
the RDF db, etc.
Cheers --- Jan
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
swi-prolog+...@googlegroups.com
> <mailto:
swi-prolog+...@googlegroups.com>.
> Visit this group at
http://groups.google.com/group/swi-prolog.
> For more options, visit
https://groups.google.com/d/optout.