DML Operations in detail:<\/strong><\/p>\n Data manipulation language operations mainly consist of insertion of record and committing it to the database, but we can also do following operations.<\/p>\n Inserting and updating the records<\/strong><\/p>\n Records can be inserted and updated in the database. Records can be created individually or in bulk using the apex collection.<\/p>\n For ex: To insert an account just type the below line of code<\/p>\n Insert Acc; (Where Acc is an account sObject)<\/p>\n Similarly to insert if we want to update a record we write below line of code<\/p>\n Update Acc;<\/p>\n Inserting Related record, where the relationship is already been established between the objects, they are associated together through a foreign key for example while creating a contact record we can specify its account by providing the account Id which is the foreign key in this scenario.<\/p>\n Ex:<\/p>\n Account parentContactAcnt = new Account(Name=\u201dAccount for Contact\u201d);<\/p>\n Insert parentContactAcnt;\u00a0\u00a0 \/\/\/\/ using the id generated from this account and provide as a foreign key.<\/p>\n ID idforForeignKey = parentContactAcnt.Id;<\/p>\n Contact newCon = new Contact(<\/p>\n Firstname = \u201cTest\u201d;<\/p>\n LastName = \u201cContact\u201d;<\/p>\n Phone = \u201c111.222.333\u201d;<\/p>\n AccountId = idforForeignKey;<\/p>\n );<\/p>\n Insert newCon;<\/p>\n Updating related records, is a bit more tricky then inserting related records and therefore we have to make two separate update call to update the related records. For example if we are updating a contact and we also want to update its account information, then to update account we have to make a separate DML call, see below for more detail :-<\/p>\n Ex:<\/p>\n Account parentContactAcnt = new Account(Name=\u201dAccount for Contact\u201d);<\/p>\n Insert parentContactAcnt;\u00a0\u00a0 \/\/\/\/ using the id generated from this account and provide as a foreign key.<\/p>\n ID idforForeignKey = parentContactAcnt.Id;<\/p>\n Contact newCon = new Contact(<\/p>\n Firstname = \u201cTest\u201d;<\/p>\n LastName = \u201cContact\u201d;<\/p>\n Phone = \u201c111.222.333\u201d;<\/p>\n AccountId = idforForeignKey;<\/p>\n );<\/p>\n Insert newCon;<\/p>\n newCon.Phone = \u201c223.334.445\u201d;<\/p>\n newCon.account. Industry =\u00a0‘Technology’;<\/p>\n update newCon;<\/p>\n update newCon.account;\u00a0\u00a0\u00a0\u00a0 \/\/\/\/ Separate DMl call to update parent record<\/p>\n Records can be related to each other using external Id as well, but this relationship has to be defined beforehand to relate any records.<\/p>\n\n