Web Social Applications Modeling Via Tinydb - Presentation Transcript
Web social applications modeling via tinydb.org
Tereza Bandino tereza.bandino@info.uaic.ro
Ionut Andonescu ionut.andonescu@info.uaic.ro
1 Tinydb.org1
Tinydb.org was created by Jason (labs.laan.com) and Kortina (kortina.net) with the
purpose to send structured data along with a tinyurl.
The goals of this platform are:
Serve as a platform upon which twitter applications and JavaScript widgets can be
written.
Provide a simple API for writing and reading small chunks of data from anywhere.
Circumvent crossdomain.xml in interesting and creative ways.
A very important thing to remember when an application is created using stored
data on tinydb, is that those data are not secured and they can be accessed from
anywhere from the World Wide Web.
1.1 Write a new entry in Tinydb.org
To write a new entry in data base, we have to make a POST or GET request
to http://tinydb.org/_write (All link examples in this presentation are GET requests).
One GET example can be the next call:
http://tinydb.org/_write?student=Marin%20Rusu&year=1&group=5&message=I%
20love%20UAIC
‘%20’ – represents the space between words
The earlier call has generated the following answer from the tinydb:
http://tinydb.org/11sj where the 11sj represents the record id.
To view the data stored on tinydb, we have only to enter on the result page (Fig 1).
1 http://www.tinydb.org
Web social applications modeling via tinydb.org 2
Also a good thing with these requests POST or GET is that we can add how many
variables we want, we don’t have a restriction in this way. In the earlier example there
have been used 4 variables: student, year, group and message.
Figure 1: http://tinydb.org/11sj
Tinydb contains only a special field “_url” which is created at each request. This
parameter “_url” is used to redirect the calls from a tinydb link to an actual site.
Ex: If at the earlier example we add the ‘&_url=www.uaic.ro’ the tinydb will
answer with the id, under which it stored the data http://tinydb.org/11sk . When we try
to enter on this page, we will not see the data stored under the id ‘11sk’ but we will be
redirected to www.uaic.ro.
If we want the ‘_url’ parameter to contain the tinydb id, we just have to add the
string ‘__tinydb_id__’ to the url, and automatically when the record is stored in the
database, this string will be replaced with the real id.
Web social applications modeling via tinydb.org 3
1.2 Reading data
To read the data stored on tinydb.org, we have just to enter on the url received after
data was stored; ex: http://tinydb.org/11sj
If we want to receive the stored data in a certain format then we just need to add
‘_f=’ at our request.
The current formats are:
_f = json - returns a json object containing your data
_f = jsonp - returns a json object but in JavaScript, that is fed directly into a
callback function, tinydbCallback, to be called once the script is loaded. use your
own callback with ( &_c=callback )
_f = js - returns a json object but in JavaScript, with an optional callback function (
&_c=callback ) to be called once the script is loaded
_f = xml - returns your data in XML
The default format for read is HTML, so if you provide no _f parameter, you will
receive html.
Examples:
http://tinydb.org/11sj
http://tinydb.org/11sj?_f=js&_c=callwhendone
http://tinydb.org/11sj?_f=json
http://tinydb.org/11sj?_f=xml
1.3 Read and write multiple rows
Tinydb.org also contains the possibility to tie multiple saved rows/records, through
a dependency parent-child. Thus, the first call to tinydb will contain in url the
parameter ‘_i’. This call will create a new field in registration called tinydb_pid, and
its value will be its id (tinydb_id); it will be the parent.
Any new record that we want to add on tinydb, in order to bind it with the previous
one (the parent), we will need to add at the parameter '_i' to the url, which is the
tinydb_pid field value of the parent.
Example: for the next url
http://tinydb.org/_write?student=Marin%20Rusu&year=1&group=5&_i&message
=I%20love%20UAIC
Tinydb has generated as answer: http://tinydb.org/11sq .To add a new record to the
previous information stored, we called
http://tinydb.org/_write?_i=11sq&message=I%20love%20INFO
Where ‘_i’ contains the parent id.
Web social applications modeling via tinydb.org 4
To retrieve the entire list of records, we have to call tinydb only with the parent id,
and to set to true the ‘-i’ parameter.
http://tinydb.org/11sq?_i=true
Very useful for the programmers is that the retrieved list is ordered by the field
timestamp. The most recent will be the first.
The data stored by tinydb can be only accessed, but not edited.
Figure 2 XML representation of parent-child relationship
Web social applications modeling via tinydb.org 5
2 Modeling data/user interaction with Twitter2 via tinydb
Tinydb.org can play an important role in modeling data and user interaction with
Twitter. Because of its robustness and because it is simple to use,
tinydb.org can store the public information of a Twitter user. In this way, during the
user session, we can save on tinydb all his new statuses which he adds,
all his responses at his friends' tweets, all the actions that he executes: adding of new
#followings, researching for some #people, entering some #topics,
searching, etc.
Storing this data on tinydb is not enough; the data should somehow be bound to the
existent user on Twitter. So, it would be necessary also a database on Twitter
which would contain, for each user, besides his personal data, some fields like:
followers_pid, followings_pid, messages_pid which would contain all his 'followers',
all persons which he follows, all his messages.
2.1 Data modeling
2.1.1 Choosing "following"/ Have new "follower"
Figure 3 Twitter option to 'follow' an existing user
In the moment when the logged in user wants to follow somebody and doesn’t
have any other ‘followings’ (so in Twitter additional database, the field
2 http://www.twitter.com
Web social applications modeling via tinydb.org 6
‘followings_pid’
is empty), it is sent to tinydb the following call:
http://tinydb.org/_write?_i&twitter_id=34s0sjd394
Tinydb will answer with the id where it will store this entry: http://tinydb.org/11sz.
This id will be stored in the ‘followings_pid’ field, so that when a new 'following'
is added, the call made to tinydb will look like this:
http://tinydb.org/_write?_i=FOLLOWINGS_PID&twiiter_id=2134sad23
In our case, the call will be
http://tinydb.org/_write?_i=11sz&twiiter_id=2134sad23
All these “followings” tied to the parent id can be found through a single call of
tinydb. In our case, the call will be: http://tinydb.org/11sz?_f=xml&_i=true.
When a new "following" is selected, the "followers" list of the selected "following"
should be automatically updated with the new ‘follower's’ id.
2.1.2 Sending/viewing/deleting messages
The messages should be stored on tinydb too. Each user will have a special field
“messages_pid”, resembling to “followers_pid/followings_pid” fields, which will
contain the parent(owner) of all messages. A new message stored in the database
would have the following link:
http://tinydb.org/_write?_i=MESSAGES_PID&message=Ce%20zi%20frumoasa%
20pentru%20o%20plimbare%20pe%20Copou&answerTo.
This call will generate an id, let's call it formally, MESSAGE_TINYDB_ID.
Because this message has the parent MESSAGES_PID, the parent's messages list can
be taken by calling: http://tinydb.org/MESSAGES_PID?_f=xml&_i=true. It is a
Twitter feature that when a Twitter user posts a new message, all his ‘followers’
receive the posted message. The field MESSAGES_PID will not only be used to store
the messages sent by a user, but also to update the ‘followers’ messages lists. In this
way, when a user posts a message, for each of his 'followers' will be sent a call to
tinydb, which will update their message list with the message from the 'followed' user.
The call would be:
http://tinydb.org/_write?_i=MESSAGES_PID&message=&answerTo=&messageI
d=MESSAGE_TINYDB_ID&userId=TWITTER_I.
This variant was chosen, in order to not store additional data, as we know already
the message id from tinydb and the twitter id of the user which
posted it.
Web social applications modeling via tinydb.org 7
Figure 4 Sequence diagram for adding a new message on Twitter
Because the data stored on tinydb cannot be edited, a method by which we can
delete messages, besides the one in which we remake the messages list without
the message that is wanted to be deleted (not favorable at all when we have a lot of
messages and followers, think of the list number which have to be remade), it
is to add a new message which contains 2 parameters:
&del=true&messageId=TinyDB_ID (del - for deleting and messageId - the id of the
message to be deleted).
The same message will be sent to the 'followers'' messages lists, too. The server
would know in this way, when it loads a user's messages list, to remove the deleted
messages.
2.2 Modeling user interaction / saving user's actions
When logged in on Twitter, a user, besides viewing, writing all existing messages
or " followings' " messages, can search for some persons, can see what they wrote,
click on some links, edit his profile, read some topics.
Web social applications modeling via tinydb.org 8
In order to do the interaction modeling, first we must define the actions that can be
taken by the user. These actions could be stored in Twitter's user database.
ex.:
ACTION
ID NAME
1 Log in
2 Add Follow
3 Search
4 Click on followers
.....
Binding tinydb data with Twitter database can be done in various ways:
1. We can do like we did with: FOLLOWINGS_PID, MESSAGES_PID,
FOLLOWERS_PID -> store the id of the first entry and all the others will be
bound with the first one, by adding parameter ‘_i=’ and the id of the first entry
from tinydb. This case would be the less expensive for Twitter's database. For this
we can create a field called LOGS_PID that will contain the tinydb.org id of the
parent.
2. Store data with time intervals: ex. daily: this implies the existence of a table in
Twitter's database in which, daily, when a user logs in, it is added a new entry. The
table could look like this:
RECORDS
id twitterId tinydbId timestamp
When a user logs in, he is searched for the daily entry in the table RECORDS. In
the case in which it doesn't have an entry, a call will be made to tinydb:
http://tinydb.org/_write?_i&action=1&additionaInfo.
This call generates following answer: http://tinydb.org/11s, so the value tinydbId
which we have to register in our database is 11sE. Let's assume we have logged in on
Twitter with user wadetinydbtest, then in RECORDS table will be saved following
data:
RECORDS
id twitterId tinydbId timestamp
wadetinydbtest 11sE 2009-10-17 21:44:30.291472
Web social applications modeling via tinydb.org 9
Figure 5 Sequence diagram for user login action
If the next user action would be to click on followers, then we search in the Twitter
database tinydbId id from the current day and we make the following call to tinydb:
http://tinydb.org/_write?_i=11sE&action=4&additionaInfo; action=4 means that the
user clicked on ‘followers’, _i=11sE is bound at the entry from this day, and
in additionalInfo parameter we can add any information that we consider to be useful.
In this way we can solve/register any user interaction with Twitter.
Figure 6 Sequence diagram for showing user’s ‘followers’
Web social applications modeling via tinydb.org 10
Utility for data/user interaction modeling described above:
We can see in time which are the most popular user actions
We can see who are the most popular people on Twitter in a particular time
Other statistical reports
0 comments
Post a comment