1

I am using the C# web-service to get data from salesforce,

After calling the "sforceService.describeSObjects()" function, I am running on the object and get they ChildRelationships.

For example, I try to get the relationship between Account<--->AccountShares

The values in the object are: currentSObject.name ="Account" (This is the Primary table) relationship.relationshipName ="Shares"
relationship.childSObject = "AccountShare" (This is the foreign Table) relationship.field = "AccountId" (This is the foreign Key on AccountShare)

My Question is, from where if get the Primary Key column in the Account table?, there is no column "Shares" in Account table, so the relationship.relationshipName is not the Primary Key (I try to build a basic 1:Many relationship).

Thanks for the help!

Update: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_erd_majors.htm

From this ERD, I understand that almost every table have "Id" column that is the PrimaryKey on that table, but that's not right for all the tables (for example Contract table dosent have Id column)

1 Answer 1

0

I think you are being misled by an error in the diagram - Contract does have a primary key "Id" column and so do all SObjects and the field is always called "Id".

To create a relationship between a child and a parent, you set the "Id" of the parent in the child object's relationship field, "AccountId" in your example.

When you query a parent and child together, there are also relationship fields available on the parent and each child. The parent reference ("Shares" in your example) is a list of references to the child objects. Each child also has has a reference to the parent ("Account" in your example). These make it simple for code to traverse the relationships.

You might find this Data Modelling Trailhead useful reading as it includes material such as:

If you are familiar with other databases you may have been surprised to see no indication of primary key columns, or identity columns. The database in Force.com takes care of these for you, and automatically assigns an identity field (called ID) to every object, and manages the identity data in every record.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .