..
The purpose of this article is to show how to use Cassandra in our PHP applications.
Cassandra is a project within Facebook with the goal of disengaging from MySQL to store messages in the Inbox.
Cassandra belongs to the family of products nosql, namely those software solutions that store data using SQL syntax and the concept of relationship, so it is not an RDBMS, but a distributed database, designed to work in a cluster and to manage large amounts of data. Instead of using the concepts of table, tuple and relation, Cassandra uses column-oriented approach implemented through the use of Hash and Array, which stores the information in the form {key: value}.
Cassandra is now an Apache project developed java6 therefore completely portable, having only a requirement to install a JRE.

The main features of Cassandra are:
To get all these benefits, however, developers have had to abandon the transaction management.
The columns (column) are the lowest level of organization of data in Cassandra, are tuples that contain a name, a value and a timestamp. They are often represented as an example the JSON notation:
{
"Name": "Name",
"Value": "Cyrus"
"Timestamp": 123456789
}
Name and value are arrays of bytes arranged as UTF-8 strings. The key / value pair is "labels as" with a timestamp. Cassandra uses the timestamp to see what the most recent value (remember we're talking about a cluster) and then to manage conflicts.
The column column are organized into families, which are akin to a table in a relational database. A column family contains an ordered list of columns that can be referenced by their name. Each column family is saved in a separate file and the file is arranged in rows (rows).
The column families are in turn grouped into keyspaces, typically one per application. Less used are superColumns, special columns that contain within them other columns.
The typical size of 4-Cassandra is therefore as follows:
Keyspace -> Column Family -> Family Row Column -> Columns -> ValuesIn the event that we add the SuperColumns:
Keyspace -> Column Super Family -> Family Super Column Row -> Super Columns -> Columns -> Values
Here is the JSON representation of a simple notation:
Users {
"Cyrus": {
"Nickname": "Ci83"
"Name": "Cardone"
}
}
and a more complex uses supercolumns
Users {
"Cyrus": {
"Skills": {
"Java": "Great"
"PHP", "Excellent"
},
"Registry": {
"Nickname": "Ci83"
"Name": "Cardone"
}
}
}
In keyspace "Users" is defined as a key "Cyrus" supercolonne with two "skills" and "registry" each of which contains key / value pairs.
| |
Linux (Course)
Complete guide to open-source system. From 49 €. |
| |
MySQL (Course)
Management of open-source database. From 39 €. |
| |
PHP (Course)
Full course for creating dynamic Web sites. From 49 €. |