| Author |
Message |
|
| mikl at club-internet.fr |
Posted: Mon Apr 26, 1999 8:25 pm |
|
|
|
Guest
|
Sorry to bother you again, but I think I need some explaination about a
particular concept in Mnesia.
In the Mnesia doc, you can read :
"What makes the Mnesia data model an extended relational model is the
ability to store arbitrary Erlang terms in the attribute fields. One
attribute value could for example be a whole tree of oids leading to
other terms in other tables. This type of record is hard to model in
traditional relational DBMSs."
This sentence is particularly abstract to me. Could someone explain this
concept or give me some concret examples.
thanks in advance.
Mickael Remond
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| mikl at club-internet.fr |
Posted: Mon Apr 26, 1999 8:27 pm |
|
|
|
Guest
|
Sorry to bother you again, but I think I need some explaination about a
particular concept in Mnesia.
In the Mnesia doc, you can read :
"What makes the Mnesia data model an extended relational model is the
ability to store arbitrary Erlang terms in the attribute fields. One
attribute value could for example be a whole tree of oids leading to
other terms in other tables. This type of record is hard to model in
traditional relational DBMSs."
This sentence is particularly abstract to me. Could someone explain this
concept or give me some concret examples.
thanks in advance.
Mickael Remond
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| crd at inversenet.com |
Posted: Mon Apr 26, 1999 8:38 pm |
|
|
|
Guest
|
Mickael Remond <mikl_at_club-internet.fr> wrote:
> Sorry to bother you again, but I think I need some explaination about a
> particular concept in Mnesia.
>
> In the Mnesia doc, you can read :
> "What makes the Mnesia data model an extended relational model is the
> ability to store arbitrary Erlang terms in the attribute fields. One
> attribute value could for example be a whole tree of oids leading to
> other terms in other tables. This type of record is hard to model in
> traditional relational DBMSs."
>
> This sentence is particularly abstract to me. Could someone explain this
> concept or give me some concret examples.
Another question for the experts: does the idea of storing "arbitrary Erlang
terms" in the database imply that not only data (numbers, text, lists) but
also executable code (i.e. funs) can be stored in the database?
Craig
Post generated using Mail2Forum (http://m2f.sourceforge.net) |
|
|
| Back to top |
|
| ulf.wiger at etxb.ericsso |
Posted: Mon Apr 26, 1999 8:39 pm |
|
|
|
Guest
|
This is also known as "non-first normal form".
The normal forms are a set of design standards for relational databases.
They are formulated in a way as to ensure the integrity of the database.
Taken from the "SQL Practical Handbook, Second Edition":
"At each row-and-column intersection, there must be one and only one
value"
This is one of the things that make RDBMSes a bit clumsy for
applications like CAD, where you want to be able to store the vertices
of a polygon in one data object, and not as a relation between two
tables.
Another example could be storing phone numbers as a list in one person
object, instead of having a phone_numbers table with objects like
{{person_name, number_type}, number}.
#person{name = "Uffe",
tfn = [{wk, "+4687198195"},{mob, "+4685198195"}]}
/Uffe
Mickael Remond wrote:
>
> Sorry to bother you again, but I think I need some explaination about a
> particular concept in Mnesia.
>
> In the Mnesia doc, you can read :
> "What makes the Mnesia data model an extended relational model is the
> ability to store arbitrary Erlang terms in the attribute fields. One
> attribute value could for example be a whole tree of oids leading to
> other terms in other tables. This type of record is hard to model in
> traditional relational DBMSs."
>
> This sentence is particularly abstract to me. Could someone explain this
> concept or give me some concret examples.
>
> thanks in advance.
>
> Mickael Remond
--
Ulf Wiger, Chief Designer AXD 301 <ulf.wiger_at_etxb.ericsson.se>
Ericsson Telecom AB tfn: +46 8 719 81 95
Varuv |
|
|
| Back to top |
|
| ulf.wiger at etxb.ericsso |
Posted: Mon Apr 26, 1999 9:04 pm |
|
|
|
Guest
|
Craig Dickson wrote:
>
>
> Another question for the experts: does the idea of storing "arbitrary Erlang
> terms" in the database imply that not only data (numbers, text, lists) but
> also executable code (i.e. funs) can be stored in the database?
Actually, with the new BEAM, you should be able to do this reasonably
safely. JAM is not very good at handling funs when a module is
recompiled. Usually, recompiling a module meant that funs could no
longer be called. With BEAM, this is no longer true.
You still have to do this with care, though. As far as I know, the only
thing stored in the database is a reference to a certain function object
in a given module (note: *not* the actual code). While I haven't been
able to break the BEAM implementation of funs, I would like to hear
someone explain exactly what its limitations are.
With the old JAM 4.7, the answer is: don't do it.
%%%%%%%%%%%%%%%% example program
-module(test).
-export([store/1, run/1]).
store(a) ->
mnesia:dirty_write({test, a, fun() -> fun_a end});
store(b) ->
mnesia:dirty_write({test, b, fun() -> fun_b end}).
run(a) ->
[{_, a, F}] = mnesia:dirty_read({test,a}),
F();
run(b) ->
[{_, b, F}] = mnesia:dirty_read({test,b}),
F().
%%%%%%%%%%%%%%%% end example program
(bbs_at_avc343)5> test:store(a).
ok
(bbs_at_avc343)6> test:store(b).
ok
(Recompile test, restart mnesia)
(bbs_at_avc343)3> test:run(a).
fun_a
(bbs_at_avc343)4> test:run(b).
fun_b
It seemed to work even though I moved the fun definitions around.
Further inspection:
(bbs_at_avc343)2> Res = mnesia:dirty_read({test,a}).
[{test,a,#Fun<test>}]
(bbs_at_avc343)3> erlang:display(Res).
[{test,a,{fun,test,0,12375923,{}}}]
When I look at the output of c(test, ['E']):
-----------------------------------------
store(b) ->
mnesia:dirty_write({test,b,make_fun('fun%0'/0, 0, 125669168, [])});
store(a) ->
mnesia:dirty_write({test,a,make_fun('fun%1'/0, 1, 67946889, [])}).
run(a) ->
[{_,a,F}] = mnesia:dirty_read({test,a}),
F();
run(b) ->
[{_,b,F}] = mnesia:dirty_read({test,b}),
F().
'fun%0'() ->
fun_b.
'fun%1'() ->
fun_a.
-----------------------------------------
I don't know how the numbers 125669168 and 67946889 are derived.
Checksums?
/Uffe
--
Ulf Wiger, Chief Designer AXD 301 <ulf.wiger_at_etxb.ericsson.se>
Ericsson Telecom AB tfn: +46 8 719 81 95
Varuv |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|