Database.com the SF way

You can found a good collection of workbook to start working on SF, a good start would be this one on data, at least following the advice of Niklaus Wirth in his Algorithms + Data Structures = Programs

The idea behind this post is to focus on the common concept regarding the database (table, column, PK, FK relationship, triggers etc) and how they are managed in database.com…

What is Database.com

First you need to have clear that all your data is stored in the cloud, that means you have nothing to install on your pc/server your data (and all other SF customers) are kept on their web farm with an high level of security.

First step is to signup and login on database.com to get access your account, as said all is done through DDL and DML…

image

Core terminology

Database.com uses different terminology compared to a relational database, the first thing to memorize is the following association:

a Database is called Organization
a Table is called Object
a Column is called Field
a Row is called  Record

Some mental anchors to remember them and stamp in you mind:

You enter a big build of a megaOrganization, inside the hall there is a big old mainframe that remember you the old way to save data, you proceed to tale the elevator, inside it you see a red table with a big O in the middle of it. You look to the display to push the button and you scroll on it with your finger up and down with a sense of fear as you don’t know where to go, at then end you click on the top most and you reach the penthouse. When the elevator doors open you see a fantastic green Field where your best friend Rowan Atkinson (Mr Bean) is running on the big circuit built on the penthouse with a fast car and you see the time… it’s a Record time and he goes faster and faster…

Now close you eyes and repeat this strange story, you’ll remember all the association easily, just write the association on a paper while imagining the story content…

 

Why this names? I think because a database usually is connected to the organization of your business, each object or entity of your business is mapped to a table and Field because each extra column you add is a field or attribute to describe better you object; finally record is more generic of Row to represent a tuple of data.

 

Database.com Fundamental

A Custom object is a business entity of the Organization, usually is related to other objects and has special field we want define to enrich our data with meaningful information.

Ex Define a Car object of our car showroom..

image

 

First thing to notice we have some field added by default such as Created By, Last Modified By, and Owner. Database.com automatically manages these fields.

The  API Name Car__c is the internal name a __c tells us it’s a custom object (you’ll see we have different suffixes)

The Database.com query language is SOQL. Notice that SOQL is similar to SQL, so getting started with SOQL is easy if you already understand SQL

Ex of SOQL….(from the workbook)

SELECT Description__c, Id, Name, Released_On__c
FROM Album__c
ORDER BY Released_On__c ASC NULLS FIRST

If you have ever wrote any sql… it will look familiar 8-P

 

Creating and Relating Object

In Database.com, you don’t work with primary and foreign keys, the way is to declare a field in an object with a relationship type, well … not so different to define a FK in a table to refer a PK in another table, here is just more explicit you say that field what kind of relationship has and with which object…

Database.com supports two types of relationships: lookup relationships and master-detail relationships. In
master-detail relationships, you can think to the Track and Album, the detail (Track) derives its significance from the master (Album). In other words, tracks can’t exist without albums, and an Album is a container for Tracks.

 

Ex a Showroom object that has Master-Detail with Car object…

image

Note the Details is related to the Master (I did the same mistake first time… th other way 8-P)

Data Sharing and Users

Why CreatedBy is added by default to our objects? Easy, to support the Database.com extensions to the traditional database models by offering users, permissions, data sharing, and other features that give you fine control over data visibility. You can hide complete objects from groups of users, a field of an object, or just particular record….don’t forget we are on the cloud here and security is a priority…

Workflow Logic

Database.com workflow rules are sets of actions that fire when conditions are met on a record. You can specify criteria based on formulas or field conditions, as well with a time-based mechanism. For actions, you can update a field or send an outbound message to a URL of your choosing… cool, it looks like the DB has not to be so stupid anymore…

Changeset

A change set is the feature of Database.com that you employ to move database metadata changes (object definitions and modifications, code, profiles, and so on) from one database to another. Changesets do not contain data records… call it a schema compare made easy….

Conclusion

I think is enough, I strongly suggest to you and myself to actively work on the UI, to practice and to understand the whole picture, of course all the UI uses an API; in real life projects you call it directly to skip all this steps and to be faster, but at the beginning let’s consolidate the ideas first… the will not change soon…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s