3 ms·
Notice I didn't just say it was elegant, I said why: "There are no tables to mess with and no joins (everything is explicitly joined)." I find elegance in simp
by espeed 15y ago
Notice I didn't just say it was elegant, I said why: "There are no tables to mess with and no joins (everything is explicitly joined)."
I find elegance in simplicity. If you don't need the tabular features of a relational database, why not use a graph DB for relational data? It's like a key value store with directly connected relationships.
This is so much simpler than having to deal with creating tables, DDLs, and migrations:
>>> g = Graph()
>>> james = g.vertices.create(name="James")
>>> julie = g.vertices.create(name="Julie")
>>> g.edges.create(james, "knows", julie)
Futhermore, there's no impedance mismatch so your code is cleaner.
But regardless, this is Hacker News where people explore, build, and share new things. I hope we're not moving to a place where that gets admonished.
- kisielk 15y agoI've actually looked a bit at bulbflow before, being a Python programmer who has had an interest in graph databases for quite some time. That's why I asked my question originally. Can you give an example of the types of relations you're using the DB to represent in a blog?
- espeed 15y agoThese are the base elements: * Nodes/Vertices: Person, Topic, Entry * Relationships/Edges: Tagged, Authored person -- authored --> entry entry -- tagged --> topic Here's the base model: https://github.com/espeed/lightbulb/blob/master/lightbulb/model.py https://github.com/espeed/lightbulb/blob/master/lightbulb/mo... The comment system is a separate, generic component. Marko, the guy who created Gremlin (https://github.com/tinkerpop/gremlin/wiki https://github.com/tinkerpop/gremlin/wiki), just released a Gremlin Tree step (https://github.com/tinkerpop/gremlin/wiki/Tree-Pattern https://github.com/tinkerpop/gremlin/wiki/Tree-Pattern), which makes it really easy to build a threaded comment tree in one quick shot. If you have a large blog or content system, you can use likes and views to make content recommendations using a basic Gremlin collaborative filtering query: // calculate basic collaborative filtering for vertex with user_id def rank_items(user_id) { m = [:] g.v(user_id).out('likes').in('likes').out('likes').groupCount(m) m.sort{a,b -> a.value <=> b.value} return m.values() } If you use Facebook, Twitter, or GitHub to authenticate users you can easily incorporate friends and followers into the recommendations.
- kisielk 15y agoThanks for taking the time to explain, I'll definitely be doing some reading over the code.
- fusiongyro 15y agoI was really responding to mgkimsal, who brought up elegance. I'm all for experimentation, I am not for technical debates short on technical content. Please continue.