Hi,

few notes from the top of my head on how we modeled this in the past:

User is a Node
Resource (Document) is a Node
Tag is a Node (having a label, language property, can be connected via 
relationships to other Tag Nodes representing its synonyms, can become a 
concept in (tree-)structured thesauri, etc...)

Scenario: User U tags Resource R with Tag T:
- Create special 'TaggingEvent' TE Node, with timestamp property and connect it 
to U, R and T by creating [TE, U], [TE, R] and [TE, T] relationships
- TE nodes are indexed by timestamp, allowing to easily generate 'Tag activity 
streams' for different contexts - for users, resources or even tags (if it 
makes sense)
- create some additional relationship(s) as needed between [U, T], [U, R] and 
[T, R] to simplify graph traversals and also to aggregate/cache the information 
like 'how many times was given R tagged with given T ~ this is f.e. expressed 
by some 'weight' property on the [T,R] relationship - and comes handy for 
generating things like tag clouds (~ get all [T,R] relationships with their 
weights)

Scenario: User U bookmarks Resource R:
- here it may be enough to create only [U,R] relationship with properties like 
timestamp, but we followed similar model as above - create special 
'BookmarkEvent' Node BE, with timestamp and ralationships [BE, U] and  [BE, R] 
and [U,R]
- this again allows to easily create bookmarking activity streams, or to mix 
tagging+bookmarking events into one stream, if there is a requirement to do so.


That's about it.

Hope this helps.


Regards,

Josef.

-- 
www.subject.cz

______________________________________________________________
> Od: "Max De Marzi Jr." <maxdema...@gmail.com>
> Komu: Neo4j user discussions <user@lists.neo4j.org>
> Datum: 09.06.2011 08:21
> Předmět: Re: [Neo4j] Design question: Del.icio.us
>
>Aseem,
>
>Which users tagged what? SELECT DISTINCT user_id FROM USER_TAGS WHERE
>bookmark_id = x
>Which bookmarks did a user tag? SELECT DISTINCT bookmark_id FROM
>USER_TAGS WHERE user_id = x
>Which bookmarks were tagged with x? SELECT DISTINCT bookmark_id FROM
>USER_TAGS WHERE tag_id = x
>
>What question are you trying to answer that you can't get from a
>relational table?
>
>I think it's better to make your model depending on the questions you
>are trying to answer.
>
>I have a similar model (users tagging users) and I needed to answer:
>Which users have been tagged by me or my network 6 degrees out?
>What is the tagged distance a user is away from another user?
>
>Turns out, all I needed was User nodes with Tagged links.  User ->
>tagged -> User -> tagged -> User
>Everything else I get from the relational db.
>
>When I start to care about which users have been tagged for by me or
>my network 6 degrees out for this KEYWORD, then I'll create a more
>complex model:
>User -> UserKeyword -> tagged -> UserKeyword -> User
>    Keyword  ---/                        Keyword  ---/
>
>Regards,
>Max
>
>On Thu, Jun 9, 2011 at 12:33 AM, Aseem Kishore <aseem.kish...@gmail.com> wrote:
>> Also forgot to add: now if you want to show all links (globally) for a given
>> tag, how do you do that? Are you indexing each tag-link (as a key-value
>> pair) every time a tag is added? Removing from the index every time a tag is
>> deleted?
>>
>> Thanks,
>>
>> Aseem
>>
>> On Wed, Jun 8, 2011 at 10:31 PM, Aseem Kishore 
>> <aseem.kish...@gmail.com>wrote:
>>
>>> I forgot to state this, but a key requirement of tags of course is that you
>>> can apply multiple of them to the same link.
>>>
>>> Would you still go that route then?
>>>
>>> If you want to delete a link from your bookmarks, it's a matter then of
>>> deleting each tag edge?
>>>
>>> Aseem
>>>
>>>
>>> On Wed, Jun 8, 2011 at 10:28 PM, Siddhartha Kasivajhula <
>>> countvajh...@gmail.com> wrote:
>>>
>>>> Couldn't you use edges for "tags" instead of nodes?
>>>>
>>>> user1 --tag--> link1
>>>> user2 --tag--> link1
>>>> user1 --tag--> link2
>>>>
>>>>
>>>> On Wed, Jun 8, 2011 at 10:23 PM, Aseem Kishore <aseem.kish...@gmail.com
>>>> >wrote:
>>>>
>>>> > Hi guys,
>>>> >
>>>> > We're thinking about implementing tags in our system, and we're
>>>> pondering a
>>>> > few ideas for how we'd go about it, and none of them seem perfect. I'd
>>>> like
>>>> > to ask you guys: how would you design an analogous case: Del.icio.us?
>>>> >
>>>> > At the core, *users bookmark links*, so it makes sense to have "users"
>>>> and
>>>> > "links" as types of nodes, and "bookmark" as the type of edge that
>>>> connects
>>>> > them. Now, you can see all the links a given user has bookmarked, and
>>>> all
>>>> > the users that have bookmarked a given link.
>>>> >
>>>> > Now users can also *tag* links, of course, but the most interesting
>>>> > requirement is that, when I'm looking at *my links*, I only want to see
>>>> *my
>>>> > tags*. Thus, tags can't be tied just to links; they have to be tied to
>>>> > users
>>>> > too. But most importantly, you have to maintain *which* user and *which*
>>>> > link *each* tag is for.
>>>> >
>>>> > Thus, it seems most intuitive to us if we could have "tags" be nodes
>>>> > that *point
>>>> > to the "bookmark" edges*. Unfortunately, that's a hypergraph, which
>>>> Neo4j
>>>> > doesn't support.
>>>> >
>>>> > We could use intermediate nodes for bookmarks maybe, but that sort of
>>>> sucks
>>>> > to lose the intuitiveness of the graph and introduce redundant edges,
>>>> more
>>>> > complexity which makes consistency harder, etc.
>>>> >
>>>> > We have some other ideas, but I'm curious if any of you guys have
>>>> thought
>>>> > about this already or have done it, or if you guys have thoughts. Thanks
>>>> in
>>>> > advance!
>>>> >
>>>> > Aseem
>>>> > _______________________________________________
>>>> > Neo4j mailing list
>>>> > User@lists.neo4j.org
>>>> > https://lists.neo4j.org/mailman/listinfo/user
>>>> >
>>>> _______________________________________________
>>>> Neo4j mailing list
>>>> User@lists.neo4j.org
>>>> https://lists.neo4j.org/mailman/listinfo/user
>>>>
>>>
>>>
>> _______________________________________________
>> Neo4j mailing list
>> User@lists.neo4j.org
>> https://lists.neo4j.org/mailman/listinfo/user
>>
>_______________________________________________
>Neo4j mailing list
>User@lists.neo4j.org
>https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to