Wrap my mind around NoSQL (Mnesia)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Wrap my mind around NoSQL (Mnesia)

Silas
Hi!

(This is mainly a question about NoSQL conceptions.  If it is the wrong
place to ask, sorry for that and, please, let me know).

After years using RDBMS (with structured and OO paradigms at the
programming language side) I'm diving into functional programming.  When
choosing a programming language to practice, I immediately fell in love
with Erlang for this simplicity and beauty.

After reading some documentation, some chapters of a book and trying
simple projects I decided to try a more complex project with Mnesia.  It
is a social bookmarks website (something similar to what del.icio.us is)
where user can bookmark a URL and associate one or more tags with it.  
For instance, some could bookmark "erlang.org" to tags
"functionalprogramming", "programminglanguage" and others.  Users also
can query other users bookmarks, see what links are associated with a
tag and what tags are associated with a given bookmark.

In my mind, an RDBMS is a perfect solution for this problem.  I'm trying
to fit it into the key -> value model, though.  My first question is: is
this possible or I'm just doing the wrong thing by forcing the wrong
solution?

For what I understood, I need to get rid of normalization rules.  So I
devised something more or less like that:

User table: {username, {urls, [tags]}} % set
UserTag table: {user, [tags]} % set
TagUrls table: {tag, url} % bag
TagUsers table: {tag, user} % bag
Urlusers table: {url, user} %bag
UrlTags table: {url, tag} %bag

It is still a bit confusing where I'd use a set, a bag or an ordered_set
but I think you got the whole picture.

Any help?

Thanks!

--
Silas
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Wrap my mind around NoSQL (Mnesia)

Roman Galeev
You can think about Mnesia as a multi-table key-value store, with some features added like transactions. And you can use Erlang terms as keys (say, a tuple). So, just tailor lookups to your needs, and it would be clear do you need a set or a bag.

On Fri, Nov 24, 2017 at 3:50 PM, Silas <[hidden email]> wrote:
Hi!

(This is mainly a question about NoSQL conceptions.  If it is the wrong place to ask, sorry for that and, please, let me know).

After years using RDBMS (with structured and OO paradigms at the programming language side) I'm diving into functional programming.  When choosing a programming language to practice, I immediately fell in love with Erlang for this simplicity and beauty.

After reading some documentation, some chapters of a book and trying simple projects I decided to try a more complex project with Mnesia.  It is a social bookmarks website (something similar to what del.icio.us is) where user can bookmark a URL and associate one or more tags with it.  For instance, some could bookmark "erlang.org" to tags "functionalprogramming", "programminglanguage" and others.  Users also can query other users bookmarks, see what links are associated with a tag and what tags are associated with a given bookmark.

In my mind, an RDBMS is a perfect solution for this problem.  I'm trying to fit it into the key -> value model, though.  My first question is: is this possible or I'm just doing the wrong thing by forcing the wrong solution?

For what I understood, I need to get rid of normalization rules.  So I devised something more or less like that:

User table: {username, {urls, [tags]}} % set
UserTag table: {user, [tags]} % set
TagUrls table: {tag, url} % bag
TagUsers table: {tag, user} % bag
Urlusers table: {url, user} %bag
UrlTags table: {url, tag} %bag

It is still a bit confusing where I'd use a set, a bag or an ordered_set but I think you got the whole picture.

Any help?

Thanks!

--
Silas
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



--
With best regards,
     Roman Galeev,
     +420 702 817 968

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Wrap my mind around NoSQL (Mnesia)

Avinash Dhumane-4
In reply to this post by Silas
Separate (and postpone) the data representation (i.e. tables) concerns from the data access (CRUD).

The access needs of the application will determine the tables (whether set or bag or ordered) and objects & attributes (keys and values).

That is, form follows the function.

On Fri, Nov 24, 2017 at 8:20 PM, Silas <[hidden email]> wrote:
Hi!

(This is mainly a question about NoSQL conceptions.  If it is the wrong place to ask, sorry for that and, please, let me know).

After years using RDBMS (with structured and OO paradigms at the programming language side) I'm diving into functional programming.  When choosing a programming language to practice, I immediately fell in love with Erlang for this simplicity and beauty.

After reading some documentation, some chapters of a book and trying simple projects I decided to try a more complex project with Mnesia.  It is a social bookmarks website (something similar to what del.icio.us is) where user can bookmark a URL and associate one or more tags with it.  For instance, some could bookmark "erlang.org" to tags "functionalprogramming", "programminglanguage" and others.  Users also can query other users bookmarks, see what links are associated with a tag and what tags are associated with a given bookmark.

In my mind, an RDBMS is a perfect solution for this problem.  I'm trying to fit it into the key -> value model, though.  My first question is: is this possible or I'm just doing the wrong thing by forcing the wrong solution?

For what I understood, I need to get rid of normalization rules.  So I devised something more or less like that:

User table: {username, {urls, [tags]}} % set
UserTag table: {user, [tags]} % set
TagUrls table: {tag, url} % bag
TagUsers table: {tag, user} % bag
Urlusers table: {url, user} %bag
UrlTags table: {url, tag} %bag

It is still a bit confusing where I'd use a set, a bag or an ordered_set but I think you got the whole picture.

Any help?

Thanks!

--
Silas
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Wrap my mind around NoSQL (Mnesia)

Grzegorz Junka
In reply to this post by Silas
Hi,

You need to consider the impact that storing a list of user tags or urls
in one filed can have on query times, i.e. {username, {urls, [tags]}}
would require that you read and store the complete list of urls and tags
when you need to add or remove one element. I would rather have a table
with records {userId, url}. It will automatically have an index on
userId. And then I would construct a select to query all urls for the
given userId. Then a separate table {userName, userId}. Then a separate
table {{userId, url}, tag} where {userId, url} is the key. I could also
have {url, urlId} since multiple users can store the same url. That
would save memory on having to remember the same url string multiple
times. Then for any user I would have {userId, urlId} and {{userId,
urlId}, tag}.

I hope that helps.

GrzegorzJ


On 24/11/2017 14:50, Silas wrote:

> Hi!
>
> (This is mainly a question about NoSQL conceptions.  If it is the
> wrong place to ask, sorry for that and, please, let me know).
>
> After years using RDBMS (with structured and OO paradigms at the
> programming language side) I'm diving into functional programming. 
> When choosing a programming language to practice, I immediately fell
> in love with Erlang for this simplicity and beauty.
>
> After reading some documentation, some chapters of a book and trying
> simple projects I decided to try a more complex project with Mnesia. 
> It is a social bookmarks website (something similar to what
> del.icio.us is) where user can bookmark a URL and associate one or
> more tags with it.  For instance, some could bookmark "erlang.org" to
> tags "functionalprogramming", "programminglanguage" and others.  Users
> also can query other users bookmarks, see what links are associated
> with a tag and what tags are associated with a given bookmark.
>
> In my mind, an RDBMS is a perfect solution for this problem.  I'm
> trying to fit it into the key -> value model, though.  My first
> question is: is this possible or I'm just doing the wrong thing by
> forcing the wrong solution?
>
> For what I understood, I need to get rid of normalization rules. So I
> devised something more or less like that:
>
> User table: {username, {urls, [tags]}} % set
> UserTag table: {user, [tags]} % set
> TagUrls table: {tag, url} % bag
> TagUsers table: {tag, user} % bag
> Urlusers table: {url, user} %bag
> UrlTags table: {url, tag} %bag
>
> It is still a bit confusing where I'd use a set, a bag or an
> ordered_set but I think you got the whole picture.
>
> Any help?
>
> Thanks!
>

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions