0

I don't really know how to ask that question, in Salesforce we have objects, and if I want to update some object (for example) I use an soql query like

Account a = [select name from Account where id = :someId];
a.someField__c = "test";
update a;

I don't really understand how the acces to the database is made, for example in java we have to use some database access component like jdbc, but in salesforce how does the connection to the database works ?

Sorry if the question is not clear...

3

The specifics of how the database connects to the application layer are abstracted away from us. In Java, a generic interface had to be provided to allow access to the database, which means that even though there's a handful of classes for interacting with databases, it involves things like selecting drivers, writing database-specific SQL statements, and so on. This is because Java was meant to run on a variety of hardware and software, to allow maximum portability.

In Apex Code, the language was purpose built to translate our queries into just one specific underlying SQL syntax (Oracle SQL, in this case), using just one driver, and so on. We're not forced to learn Oracle SQL, nor do we have to learn how the drivers operate, etc. We're given all the tools we need so we can focus on writing business logic, not learning the specifics of the underlying platform.

You'll notice how we also have similar constructs elsewhere. There's one standard interface for sending emails, one for calling REST services, one for call SOAP services, and so on. Instead of working with sockets or streams, we're given a simple "go to this URL and give me the results" API. Instead of writing POP3 or SMTP messages, we can handle incoming and outgoing email requests using just a handful of objects.

In other words, we don't need to know, because we have a team of developers and engineers that are constantly monitoring the database and tweaking the system to deliver the best performance, without us having to select drivers or driver options, heavily focus on optimizing Oracle SQL calls, and so on. Our purpose is to build applications that serves our business' needs instead of catering to the platform's tuning and maintenance.

| improve this answer | |
1

Reading from and writing to the database use completely separate processes. You read from the database with SOQL or SOSL.

If you are unclear on how queries work in Salesforce, you should read through more of the Force.com SOQL and SOSL Reference.

You write to the database with DML. You have a variety of syntax options available to you for both writing to and reading from the database.

DML

Static Operation

update myRecords;

Dynamic Operation

Database.update(myRecords, /*allOrNone*/ false);

SOQL

Static Query

List<MyObject__c> myRecords = [SELECT Id FROM MyObject__c];

Dynamic Query

List<MyObject__c> myRecords = Database.query('SELECT Id FROM MyObject__c');

SOSL

Static Query

List<List<SObject>> results = [FIND 'term' RETURNING Account (Id)];

Dynamic Query

List<List<SObject>> results = Search.query('FIND \'term\' RETURNING Account (Id)');
| improve this answer | |
  • thank you for the answer, and do you know how does it work, is it with the salesforce api ? I don't really understand the mechanism with the api or how the acces to the database is made (I don't mean the sosl or soql or dml ) – dou Dec 15 '16 at 15:54
1

Database in Salesforce is tightly integrated with the Apex/VF language itself. As this is the platform we don't have to think about the technicalities related to the database or underlying server used by Salesforce.

You can read more about it here in the trailhead data modelling module. https://trailhead.salesforce.com/en/modules/data_modeling

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.