Using FluidDB with Django

43
Using FluidDB with Django (making data “social” with FluidDB). Nicholas Tollervey ntoll@fluidinfo.com

description

Slides from my introductory talk to the Django User Group: London (DJUGL) talk in July 2010 at the Guardian.

Transcript of Using FluidDB with Django

Page 1: Using FluidDB with Django

Using FluidDB with Django(making data “social” with FluidDB).

Nicholas [email protected]

Page 2: Using FluidDB with Django

The Agenda:

What?Why?How?

Where?Django?

Page 3: Using FluidDB with Django

What?

Page 4: Using FluidDB with Django

FluidDB is a platform for the web of things,

each represented by an openly writable “social”

object.

Page 6: Using FluidDB with Django

Why?

Page 7: Using FluidDB with Django

http://www.flickr.com/photos/jointhedots/4622191119/

Page 8: Using FluidDB with Django

People I know

Page 9: Using FluidDB with Django

WHERE location NEAR pubs SERVING

SELECT self-catering-cottage FROM

AND pub HAS rating > 7 IN

Page 10: Using FluidDB with Django

Share, annotate, augment and re-use information.

Page 11: Using FluidDB with Django

How?

Page 12: Using FluidDB with Django

There is only one FluidDB. All users and applications share the

same database.

Page 13: Using FluidDB with Django

•Objects - represent things

•Tags - define objects’ attributes

•Namespaces - organise tags

• Permissions - control access

Page 14: Using FluidDB with Django

http://ntoll.org/images/93.jpg

Page 15: Using FluidDB with Django

Data Structure

entity / attribute / value

Page 16: Using FluidDB with Django

Data Structure

object / tag / value(in FluidDB parlance)

Page 17: Using FluidDB with Django

Data Structure

object / tag / value(optional)

Page 18: Using FluidDB with Django

Namespaces/Tags

ntoll/ratingterrycojones/books/reviewamazon.com/book/titleamazon.com/book/authoramazon.com/book/isbnesteve/books/covertimoreilly/has_read

Page 19: Using FluidDB with Django

An object

about = “book:Dune”

id =“e127475b-eb93-48e1-a24f-dde6825b9ed8”

Page 20: Using FluidDB with Django

An object

about = “book:Dune”

ntoll/rating = 5ter

rycojones/

books/rev

iew =

“I love

sandworm

s”

amazon.com/books/title =

“Dune”

amaz

on.co

m/b

ooks

/aut

hor =

“Fra

nk H

erbe

rt”

amazon.com/books/isbn =

“87-418-7517-6”

timoreilly/has_read

estev

e/boo

ks/co

ver =

id =“e127475b-eb93-48e1-a24f-dde6825b9ed8”

Page 21: Using FluidDB with Django

An object

about = “book:Dune”

ntoll/rating = 5ter

rycojones/

books/rev

iew =

“I love

sandworm

s”

amazon.com/books/title =

“Dune”

amaz

on.co

m/b

ooks

/aut

hor =

“Fra

nk H

erbe

rt”

amazon.com/books/isbn =

“87-418-7517-6”

timoreilly/has_read

estev

e/boo

ks/co

ver =

booleanstring (& set)numericopaquenull

id =“e127475b-eb93-48e1-a24f-dde6825b9ed8”

Page 22: Using FluidDB with Django

snoissimreP(seem to be back-to-front)

Page 23: Using FluidDB with Django

about = “book:Dune”

ntoll/rating = 5ter

rycojones/

books/rev

iew =

“I love

sandworm

s”

amazon.com/books/title =

“Dune”

amaz

on.co

m/b

ooks

/aut

hor =

“Fra

nk H

erbe

rt”

amazon.com/books/isbn =

“87-418-7517-6”

timoreilly/has_read

estev

e/boo

ks/co

ver =

Traditional:

id =“e127475b-eb93-48e1-a24f-dde6825b9ed8”

Page 24: Using FluidDB with Django

An object

about = “book:Dune”

ntoll/rating = 5ter

rycojones/

books/rev

iew =

“I love

sandworm

s”

amazon.com/books/title =

“Dune”

amaz

on.co

m/b

ooks

/aut

hor =

“Fra

nk H

erbe

rt”

amazon.com/books/isbn =

“87-418-7517-6”

timoreilly/has_read

estev

e/boo

ks/co

ver =

FluidDB:

id =“e127475b-eb93-48e1-a24f-dde6825b9ed8”

Page 25: Using FluidDB with Django

You control who can see, read or use your tags.

Page 26: Using FluidDB with Django

Anyone can tag information to an object.

http://www.flickr.com/photos/fixe/3415776837/

Page 27: Using FluidDB with Django

Permissions

• Apply to namespaces, tags and tag-values not objects

• Scoped by actions (e.g. “see”, “create”, “read”)

• Either “open” or “closed” with a list of exceptions

Page 28: Using FluidDB with Django

FluidDB’s Query Language• Equality & Inequality: To find objects based on the numeric values or

exact textual values, e.g., tim/rating > 5, or geo/name = "Llandefalle".

• Textual: To find objects based on text matching their tag values, for example, sally/opinion matches “fantastic”.

• Presence: Use has to request objects that have a given tag. For example, has sally/opinion.

• Set contents: The contains operator can be used to select objects with a matching value in a set of strings. The query mary/product-reviews/keywords contains "kids" would match the object with a tag called /mary/product-reviews/keywords and value ["cool", "kids", "adventure" ].

• Exclusion: Exclude objects with the except keyword. For example has nytimes.com/appeared except has james/seen. The except operator performs a set difference.

• Logic: Query components can be combined with and and or. For example, has sara/rating and tim/rating > 5.

• Grouping: Parentheses can be used to group query components. For example, has sara/rating and (tim/rating > 5 or mike/rating > 7).

Page 29: Using FluidDB with Django

{“tagPaths”: [" “twitter.com/username”," “twitter.com/fullname”," “tunkrank.com/score”," “ntoll/met”," “terrycojones/met”," “python.org/member”," “ub.edu/alumni”," “ub.edu/bsc”," “uoc.edu/msc”," ... etc ...]}

Tags attached to the “about:esteve” object.

Page 30: Using FluidDB with Django

https://fluiddb.fluidinfo.com/objects/OBJECT_ID/NAMESPACE(s)/TAG

HTTP ‘GET’ returns the value, HTTP ‘PUT’ adds/updates it etc...

Full API: http://api.fluidinfo.com/fluidDB/api/*/*/*

A RESTful API

Page 31: Using FluidDB with Django

Social data?

Page 32: Using FluidDB with Django

http://www.flickr.com/photos/8001265@N08/2259250324/

Let me demonstrate!

Page 33: Using FluidDB with Django

Where?

Page 34: Using FluidDB with Django

http://fluidinfo.com/

Page 35: Using FluidDB with Django

• Twitter: @fluidDB @terrycojones @esteve & @ntoll

• http://youtube.com/fluiddb

• #fluiddb on Freenode IRC

• http://groups.google.com/group/fluiddb-users

• http://groups.google.com/group/fluiddb-discuss

Page 36: Using FluidDB with Django

Lots of 3rd party libraries:

Java, Clojure, Lisp, .NET, Perl, Python, Ruby, PHP & Javascript (all open-source)

http://fluidinfo.com/developers/libs

Page 37: Using FluidDB with Django

Django?

Page 39: Using FluidDB with Django

Familiar Models

from django_fluiddb import models

class Foo(models.Model): bar = models.CharField(‘test/namespace/bar_tag’) baz = models.IntegerField(‘test/namespace/baz_tag’)

Page 40: Using FluidDB with Django

Familiar Forms

from django_fluiddb.forms import ModelForm

class FooForm(ModelForm): class Meta: model = Foo

Page 41: Using FluidDB with Django

It’s only the FOM underneathhttp://bitbucket.org/aafshar/fom-main/

Page 42: Using FluidDB with Django

We’re listening to youthough the usual caveats apply ;-)

Page 43: Using FluidDB with Django

Questions..?