 Hello. Hi, everyone. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So this is day five of Salesforce Learning Bootcamp. And before starting, I just want to confirm whether my voice is audible. Okay. Thank you for confirmation. So I saw two questions in the beginning of the chat. So first one is related to feed and history tracking. So, Mary, I will be sharing them. So not today. In the next session, I will be explaining. So you can just refer the Excel sheet, like those topics which are left, they will be covered, but in different session. So in today's session, I will be covering about lookup and master detail field, roll up summary field, and we'll learn how we can create junction object and what is the purpose. And yes, first video is hidden. So it is due to YouTube guidelines. So like, I will do something about that. Maybe I will rerecord and we'll upload that as per the guidelines. Okay. So we are on time. So let's start this Bootcamp's day five session. So as every day, I ask you to know about your instructor. So this is me helping students, freshers, and professionals to ram their career in Salesforce ecosystem. Now, seven virtual learning best practices. So you just need to focus on live sessions. You need to take proper notes for future reference. You can write down doubts and you can ask them in Q&A part of the session. So I can see many people asking doubts in between the session. So I would suggest to ask all the questions at the end of the session. Don't miss any session because most of the topics are connected. Then practice each session along with the exercises. So if you follow the exercise sheet, so I'm regularly updating exercises and you can follow that so that you can practice. And if you see any doubt during practice, so I can see a few folks are asking questions in the comment section after the session. So you can also ask and keep doing everything which is listed here so that you can build a strong foundation for a successful career. Okay, so like initially I will be explaining the topic and then we'll take Q&As. And you can subscribe, follow and share like all the channels and spread the word so that everybody can learn Salesforce free. So in today's session, we will be discussing about the relationship fields. So there are two types of relationship available. We have one-to-many relationship and many-to-many relationship. So basically till now, what we have done, we have created objects separately. So we created student object, we created instructor object. And under student object, we created some records and under instructor object, we created some records. Now, today I will let you know like how you can link two objects or you can say two records together. So first of all, we will be discussing about one-to-many relationship. So if we talk about one-to-many relationship, so one-to-many relationship means one record can have many related records. So here you need to understand it like your one record will be on parent side, parent mean master record. And that record will be having some child records. So we can do this through two different ways. One is lookup and one is master detail. So first of all, I'm going to show you what relationship is with the help of standard objects. So if I take you to the orb, so here inside the orb, if I open our sales application, so I'm going to open sales application in new tab. So here under the sales application, you can see we have two tabs. One is account and one is contact. So account tab is related to account object and contact tab is related to contact object. Now if I go to contacts and if I open any contact and here you can see every time we are viewing details. So these details are related to account record. Now if I go to related, so here you will see the related records under the objects which are related to account object. So account object is having contact, opportunities, cases, these objects are related to account. So you can consider like account is on one side and contact opportunities and cases are on many side. So we can say one account can have many contacts, many opportunities, many cases related, right? So if I click on new button here, so I will be creating a contact. So here you can see I just need to fill the information and account name is populated by default here. It means this contact will be related to this account automatically, right? So I am creating test contact here and clicking on save. So you can see a test contact is created here. So right now this account record is having two related contacts, right? And this phone number is populated through this account. So this account is provided by Salesforce by default. So these records are provided by Salesforce. I have not created these. So these records are having pre-populated data which is managed by Salesforce internally and it is available for practice purpose publicly, right? So here you can see we have two related contacts, right? Now if I go to contacts and if I try to create new contact, so here I will see this field. So this can be lookup or master detail. It means whenever you are trying to create new contact, so you can link it with any account, right? So I am creating test con 2 and I am going to link it with Burlington textile and saving it, right? So if I go to this account, now I will see three contacts related, right? And if I open any contact and go to details, so here I will see the account name which is related to this. And if I hover, so I will see this layout. So this is basically our compact layout that we discussed yesterday. And these are related records which are related to account. So these are other child objects which are related to this account object. So this way basically relationship is managed, right? So we have one parent record which is having many child records, okay? Now we can create this relationship using lookup and master detail. So we have two different type of relationship fields available and both have different features. So I hope with this you understood like how we can link two objects if they are standard object. Now we will try to do this with custom. So what I am going to do, first I am going to implement lookup relationship. So now you need to understand what lookup relationship is. So it creates a relationship that links one object to another object. The relationship field allows user to click on a lookup icon to select a value from a pop-up list. So this I showed you like when I created contact record. So there I was using a lookup icon and if I clicked so it was showing me account records from which I selected one account record. So the other is the source of the value in the list, right? And this lookup relationship is loosely coupled relationship. It means if you delete your parent record or your like one record which is on one side. So your many side records won't be deleted automatically. So that's why it is loosely coupled relationship, right? Now if you want to see like the field which is already there, it is lookup or master detail. So how we can do that? So I can see one question in the chat. So if I go to contact object, so under this contact object, if I go to fields and relationships. So here you will be able to see what type of field account is where we are populating the values. So you can see it is of type lookup. Lookup to account. So if field is already created, so based on this data type, you can easily identify whether it is lookup or master detail. And yes, Mary, we can add lookup and master detail on standard objects as well. So these are already created. If I want to create new lookup or master details. So here you can see this lookup relationship is available, right? Now I'm going to show you this with custom objects. So I have a requirement for this. If you go to our exercise sheet. So here we need to create a lookup field on student and it should be related to class. So if I take you here, so we need to create this field actually lookup. We need to create lookup field to class. So first of all, we need to create this object. This object is also not created in our org. So if I go here and search for the object class, so it is not available. So first I'm going to create this object. So label will be class, plural label classes. Then I'm leaving it as is. So in previous sessions, someone asked me when to use text. So we already used auto number. This time we are going to use text, right? So auto number won't be there. So a field will be created whose type will be text and its label will be class name. And we need to create a tab. So I'm just checking this checkbox and clicking on save. So now I need to create a tab for this. So I'm selecting tab style and clicking on next, leaving it as is next. Now it is asking me to place this tab on particular application. So I'm going to select the application which we created. So you can see we have two applications. One is standard navigation and one is console navigation. So I'm going to add this class tab on both the applications. And I'm clicking on save. So this way my object is created. If I go here and refresh the page, so along with student and instructors, you will see this class tab as well. So here you can see third tab is available. And if I try to create new record, so you won't see any auto number field. Here class name field is available, which is required. So one field is created automatically of type text because we just selected text instead of auto number. So this way I hope you understood both the data types. Those are available whenever we create objects, right? Now we need to create more fields. So I'm going to create course duration. So course duration will be of type text. So under fields and relationships, I am creating this field. So new from data type, I'm going to select text. Then next. So field label will be course duration length. I'm writing as 100 and clicking on next visible to all the profiles and next. And save. So this way this course duration field is created. It is a custom field. So these two fields are created. Now I need to create one more field that is fees and it will be of type currency. So I'm creating this one as well. And then I will show you how we can create mass, sorry, lookup field. So here I'm going to select currency and here I'm going to fill the details. So fees clicking on next. So it should be visible to all the profiles clicking on next and clicking on save. So this way you can see course duration and fees. All these fields are created. So highlighting it as green, right? Now I'm going to create this lookup field on student. So one more thing that you need to remember, like whenever you want to create lookup or master detail field. So these fields you need to create on the child object, right? And they will look up to parent. So here in our case, what we can say student will be a child where we will be creating lookup field and it will look up to class. It will be parent, right? On parent side, you will see related list. So this is important to know, right? So on parent side, you will see related list and lookup field you need to create on the child side. That is student. Okay. So one class can have many students. This is the idea. So here I'm going to search for student object clicking on fields and relationships. Now clicking on new. And here you can see I have this lookup relationship field. So it says creates a relationship that link this object to another object. The relationship field allow user to click a lookup icon to select a value from a pop-up list. The other object is the source of the values in the list. So I selected lookup relationship clicking on next. Now from here I need to select the object class. So here it is. So this will be our parent object. So here you can see it is saying select the other object to which this object is related. So this is important. This object will always be parent. So sometimes whenever we start implementing lookup or master detail relationship. So people do mistake here. So always remember lookup field will be created on the child side. And while creating this lookup, we need to select the parent object. This is important to understand. Now I'm just clicking on next. And here you can see field label is already populated. If you want to change it, you can. Now here we have few more things. Child relationship name. So the child relationship name is an internal reference. And is used for integration purposes. Be careful when changing the child relationship name as it may affect existing integrations. So basically when we'll be learning about development, then we'll be using this child relationship name. So right now I'm leaving it as is and focusing on other things. So here we have a checkbox which is showing required. So if you want to make this lookup field required, you can check this checkbox. By default it is optional. Then this is also important. What to do if the lookup record is deleted? So if your parent record is deleted, so what you want to do with this lookup field? So first option says clear the value of this field. You cannot choose this option if you make this field required. So if you make it required, you cannot choose this option. In that case, don't allow deletion of lookup record. That's part of a lookup relationship. So if it is required, then you won't be able to delete the parent record. But if you uncheck, then you will be able to delete and the lookup field will be clear. It won't be related to any parent record. So this is the explanation about this. Now I'm moving ahead, clicking on next. Visible to all the profiles, clicking on next. Now here on page layout, like you can see, we have three page layouts. So we have experienced fresher and student layout on student object. So on which layout you want to place this newly created field. So I'm going to place it on all the layouts. Now here you can see numbers like step number six. This is additional, which is available on lookup field creation. It is for related list label. It is for related list label. So I showed you related list at the time of contact record. So if you open any contact record and go to related, so here you see the related list label. So this label, what should be the label of this related list that you can type here, right? So on class record, you will be having a related list named as students. If you want to change it, you can. And later on also you can change this label. So I'm just clicking on save. So this way here you will see a lookup field is created. So I'm just searching for that. Yeah, here it is. Lookup to class, right? And here in the bracket or parenthesis class word is written. So it is representing parent object and the student will be child because on this object we just created this field. Now let's create some records. So I'm refreshing it. So first I'm going to create some class records and then we'll be creating some related students. So I'm clicking on new and creating class. So first class name is, for example, Salesforce admin course duration, two months fees, for example, 10,000 and I'm clicking on save. So this is my first class, right? Now I'm going to create one more class. Salesforce tab duration four months and fee suppose 20,000 and saving it. So this way these two records are created. Here they are visible. If you go to all list view, so from here you can add fields as well. So we can add course duration. We can add fees and save, right? And here you can see the details. If you want to pin this, you can click here. So now if you refresh the page, you won't see recently viewed. You will see all list view. So we have this pin. So whatever list view you pin, you will see that only. So here we have two classes. Now if I open this and go to related, so here you will see student related list. But right now we have zero related student. Okay. Now we have two options to relate students with this record. First, we can create new student records from here only. And if you have created a student record already, you can link them as well with this class. Or if you want to create new students from students tab, so that is also possible. So we'll do all three things. So first time creating student record from this related list. And here we need to select record type then next. And here you can see this class lookup is available, which is having Salesforce admin class pre-populated. And here I can just type the name of student, right? So admin one name of the student, right? And I'm just clicking on save. So validation rule is working. Please populate entrance score. Here I'm entering 80 and clicking on save. So this way you can see a student record is created. Its ID is 007 and it is related to this class. Okay. If I want to open this student record, I can just click on this and it will be opened. And here you will see the parent record information, right? If you want to open the class record, you can just click and it will be opened. If you go to related list, you will see your related student record. Now if you hover on this, you will see the compact layout that we created yesterday, right? So this is your compact layout. So this is the another use of compact layout whenever you hover any record. So it shows. And if you see here, in this compact layout, you are not able to see anything. You just can see the name of the class because compact layout is not configured here, right? So this way we can relate student records. Now if you want to relate existing student records, so if I open this 001. So here you will see that field. So here it is class. If you click, so this is lookup icon. Here if you try to search, we can see both classes. So I'm linking it to Salesforce admin and clicking on save. Now if I go to Salesforce admin class and go to related list so I can see two students here. So this is actually one to many relationship. So class record is on one side and student records are many side. Now if I go to students and try to create new record from here. So I'm labeling it as admin to score. I'm entering as 30 and here I need to fill the class. So one more student record is created and it will be linked to Salesforce admin class. So here you can see three records are related. So this way this lookup relationship basically works. So I can see a few questions. So one question is what if student 007 is in both classes. So in that case you need to create lookup for both. And sorry, it is not possible because if we open this 007. So here you can populate any one class. Right. If you want to relate this record with multiple classes. So for that we will be using many to many relationship through junction object. So there is one more question how to identify which is primary and which is child. So this I already told you. So primary or parent will be where you see related list and wherever you see lookup or master detail field that will be on child side. Okay. So this way I hope you understood the functioning of lookup relationship. Now let's discuss about master detail relationship. So it is little bit different with lookup relationship. So it also creates a special type of parent child relationship between two objects. One is known as child or detail where we create master detail relationship field. And another one is known as parent or master. Right. Now lookup field was optional. Lookup field was optional. So what we can do like if I delete the parent record, if I take you here, if I delete this one, if I delete this class. So all three records will still exist. If I delete that class, all three records will still exist. That's why this is lookup. Sorry. When you will be practicing, so just try to delete this class record. You will realize in case of lookup relationship, these related records won't be deleted. And if you open any of these record, there, this class field will be blank. Right. But in case of master detail relationship, this field is required on all detail records. If you delete your parent record, so all your child records will be deleted automatically. Then ownership and sharing of all of a detailed record is determined by the master record. Right. So owner like who the user who is the owner of parent record that user will be owner of the child record. And if we can access the parent record, then we can also access the child record. Right. Sharing applies. Whatever sharing is available for parent record, it goes with child as well. Then if you're, if the user delete some master record, then all detail records are deleted. And one can create roll up summary field on the master records so that detail record can be summarized. So this feature is available with a master detail record master detail field only. It is not available with lookup. And it is tightly coupled because if you delete parent, so all child will be deleted. So let's try to create this. So what I'm going to do under student. So same relationship I will be using child will be student and parent will be class. And I will try to create a master detail field. Right. So I'm just clicking on new. And I'm selecting master detail relationship. And here also you can see all the description is written. So anytime if you forget about master detail relationship, you can go through with these points. And I'm clicking on next. So there is a question like what is loosely coupled? So loosely coupled means if you delete parent record, so your child record won't be deleted. So they are connected, but but loosely like if parent is deleted child won't be affected. And in case of tightly coupled, if you delete parent, so child record will get deleted automatically. Okay. So now I'm trying to create master detail field on student object and it will be related to class. So class will be on parent side. So right now if I use these names class, so it will be duplicates. I'm adding one into it. And here we have different things sharing settings. So we have two options read only and read write. So you can select the access level from here. So you can go through with this statement as per the requirement we can select. And as I told you this master detail field will be read only like once you select a parent, then it is difficult or it won't you won't be able to modify the parent record. On child side, if you want to change the parent record, so we have this checkbox allow reparenting. So if you check this checkbox, then you will be able to change the parent record for that child record. Right. Otherwise you won't be able to. Okay. So these are some features which are available with master detail field. So I'm just clicking on next. And here you can see all the checkboxes are by default checked because this field is required. You need to populate value. So it should be accessible by all the profiles. And it should be visible on the layout as well. So you can see all the checkboxes are checked. You cannot control these. And next. Then here you can see a related list will be created. But now if I hit save, so you will see an error message. Right. I am trying to create master detail field and I got this error. So quickly review this error so that we understand the problem. So you cannot create a master detail relationship on an existing custom object if records already exist. So this is important. If you have records already available. So there may be possibilities like in some of the fields, like after creation of this master detail field. Those existing records will not be having any parent selected. Let me show you how if I go to students and if I go to all list view and from here if I select a field that we created as lookup. So here you can see this lookup is filled for three records. For rest it is blank. But in case of master detail, what will happen? We have these seven records. So for these existing record master detail field will be created, but that field won't be having any value. And as master detail field is required, so we cannot do so. So if your object is having existing records, you won't be able to create this field. So we have two solutions now. First create master detail field whenever there is no record created. And if there is already records created, so what you can do? You can first create a lookup relationship, then populate the lookup field with data in all records and then change the relationship type to master detail. So this we can do right now. So this way you will understand like if you have a lookup relationship, so how you can convert that lookup relationship into master detail relationship, right? So I hope you understood the requirement. Like if you have existing records on particular object, so in that case, you cannot create master detail relationship field. So you need to convert or you need to first create a lookup field, then you can convert that lookup field into master detail. So we already have created this lookup field, so what I need to do? I just need to fill all these records. So these four records should also have a parent, then only we will be able to convert this lookup into master detail, right? If I don't fill, then I won't be able to do that. So let me show you that as well. If I go here and open this lookup field, if I try to edit, so I won't see... Okay, this change field type option is available if I select master detail relationship from here and click on next and save. So you can see again it is showing the error. Why so? Because on these four records, we don't have any parent record populated. So what I'm going to do one by one, I'm opening these records and I'm going to populate the class. So for these four records, I'm going to populate classes. So I'm going to populate classes Salesforce DAV and I'm going to arrange these so that we can see the details. Okay, so we have Salesforce admin, Salesforce DAV. So these three are pending and I'm pinning this list view so that I can see this every time. So from here, I'm selecting Salesforce DAV, saving it. Again, I'm opening this number four and I'm selecting parent record, saving it. And for this number zero five, I'm going to select a parent record and saving it. So if I go here, so Salesforce admin is having three students, Salesforce DAV is having four students. And if I go to students, here you can see each and every record is having parent record populated. Now, if I try to convert my lookup relationship into master detail relationship, so I will be able to do so. So again, I'm clicking on change field type, clicking on master detail relationship, next. And from here, I'm clicking on save. So you can see our lookup is converted into master detail. So if you see this field, so here, you will be able to see the master detail is available data type, right? And as this is converted into master detail, if I open any student record, so here, if I select it so you can see we have an error message, right? We are not able to change it because now it is master detail. So if you want to change it, so you need to check that checkbox allow reparenting. And if I try to create new student without populating class, I won't be able to do. So you can see here, asterisk is available. So when you will be doing the practice, so do one thing, whenever you will be creating a lookup field. So try to create a record without populating that lookup field. So you will be able to save the record, you won't see this asterisk. But in case of master detail, you will see this, right? So this way, I hope you understood how we can create master detail relationship field. So we have two ways to create it. One, like if you don't have any record, then you can create it directly. If you have record, existing record on particular object. So first create lookup, then a populate lookup field for each of the record, and then you can convert that lookup into master detail, okay? So then we have roll up summary field. So if you have created a master detail field, so for master detail relationship, you can apply roll up summary. So it is a read only field that displays the sum, minimum or maximum value of a field in a related list. This field also can count all records available in related list, and roll up summary field is always created on parent. So if you go to this exercise, so this first and second point I demoed you. Third also I demoed like how to create lookup field. Here child is student and parent is class. Then I converted this lookup into master detail. So you need to create one more, this one. Create a lookup field on instructor object related to class, right? And we need to create these roll up summary fields. So I am going to create this one, total students. I am going to create this one, total students. Rest you can do as per your practice, right? So what we need to do, this time we need to search parent object. That is class. So I am going to open it and under fields and relationship, I just need to click on new and here I will find this roll up summary field, data type. So it is a read only field that displays the sum, minimum or maximum value of a field in a related list or the record count of all record listed in a related list, right? So here I am clicking on next. So we just need to calculate total students, right? So this is the label and API name. Then I am clicking on next. So from here we need to select which object to summarize. So I am selecting student. Then I just need to count. If you want to calculate some min or max, so in this case, you will be able to select the field, right? So as per our exercise, you will be calculating highest entrance score. So what you will do, you will be selecting max and entrance score. So automatically on parent record, all the child records will be checked and whose entrance score is the maximum that value will be populated on parent record in the field that we are creating right now. So I am just going to count. We can apply filter criteria like you want to include all the fields or only selected fields. So here you can apply criteria like age greater than 30 like this, okay? So this way you can apply the conditions. But I am including all the records as of now. Then clicking on next and visible. You can see it is read only by default. Clicking on next and save. So here you can see this roll up summary field is created and we created it on the parent side. So what we need to do, we need to open the parent record. So I am going to classes, opening Salesforce admin and refreshing the page. So this field will be available on this parent record page. So you can see it is having total students as number is three. If we go to Related List, we can see three records are related. If I go to another class Salesforce, so here total students are four. If I go to Related List, records are four. And if I try to edit, so I won't be able to edit this roll up summary field, right? So this way you will be able to create roll up summary on parent side. Okay, so I can see some questions in the chat. So let me take those. So can lookup be converted into master details? So I already demoed it. And can you not converse? Yeah, so Mary's asking, can we convert master detail into lookup? So that we'll do later on. So right now I just created roll up summary on parent in master detail. So we can convert master detail into lookup as well. So I will show you that as well. Can you delete empty records and add master detail relationship after? Yes, this is also right. So if you can delete your existing records, there is no problem in deleting. Then you can just delete all the records and then you can directly create master detail relationship field. Can you fill class values from list view itself, right? Yes, Sunita, we can do. If interviewer ask for type of relationship, we will mention only two. Yes, so we have external lookup relationship as well that is used for integration purpose. But mainly we have these two. Then how to, we have self lookup relationship as well. So what you can do in FAQ, I just provided a document. So I just updated it for previous FAQ. Here you can see we have these two links. So there is consideration for relationships. So you can go through and another is for many to many. So you can just view these are Salesforce official documents which are publicly available. So you can just view and read information from here. Then next is how to identify when to use lookup or master detail. So I already told you if you want loosely coupled relationship, like if you delete parent and your child won't be related, then you can go with lookup. And if you delete parent and you want to delete child as well, you can go with master detail. Then roll up summary is available with master detail. So if you need roll up summary calculations, then go for master detail. Then if you want to apply sharing rules of parent to child, then go for master detail. So this way you can identify. Then if child as records, can we create relationship? Ramya, I didn't get your question. Can you please elaborate? Then we can create relationship on child record only. Sai Krishna, yes, we can create relationship on child. And on parent side, we will be having related list only. Is there a way to change filter logic as or in roll up summary field? Yes. So if I added this, so we can just added the filter logic. So if I select this, let me select this. So here we are not having the option to change this and yes. So it will be and we cannot change it. So next question, if we do max score, then it will show max score, but can we show the name of the student with max score? No. That feature is not available with this roll up summary. Then, okay, Rishabh is asking, please reply should I learn visual force? Yes, you can, but in many, like 99 projects won't use visual force. But if you want to know the language, you can. So what we can do if there are n number of records are there for converting lookup to master detail. So like in real time scenarios, it won't be the case initially when you are building the project. So at that time, it is decided whether to have lookup or master detail, right? What is the difference between if we create lookup relationship with required and MDR? Shubham, can you please elaborate your question? To create master detail relation, can we create when master is custom object? Yes, we did that. So our both objects were custom, right? But in case of standard, I think on standard, we cannot create relationship for parents. So let me just check it. So if you go to account, fields and relationships, new lookup relationship next. So let me search for class. Yeah, I think we can do. Yes. So I would suggest go with this document here. All the considerations are available. So you will get all those answers with this document. Harsh is asking, can we create it on standard object? Yes, we can. So again, there is asking how many lookup we can create for objects. So like it is suggested, you can create two master detail and any number of lookup relationship. So let me just open this document for you. So here you will find those answers. So here you can see it is written each custom object can have up to two master detail relationship and many lookup relationships. So this way you can see everything is available here. If you go through this document, you will find all the specific information. And this is public document, which is provided by Salesforce. And it is available in our FAQ document. Could you provide an example on hierarchical relationship? So basically, hierarchical relationship is available with account and other objects. So if I go here, so if you see here, this is basically hierarchical relationship. So account hierarchy we have and like it goes with same object. So if I open this account and go to details. So here I can select parent account and right now it is recently. Let me view one more. So I'm opening another one moving to details. And here I'm populating parent account as this and I'm saving it. So now you will see hierarchical relationship. So this is parent and this is child for this. So this is basically account hierarchy that you can create and it is standard. So Mary is asking, can you make roll up with pick list or check box? No, basically this roll up is for records. You can count record. You can find out max min or some through numeric or currency fields only. How many roll up summary can be created so that you can check. I don't remember exactly. Please explain cross object formula fields. Yeah. Rekha this cross object formula field we will be discussing when I will be explaining end to end project. So I have planned a project you can see in the Excel sheet. So when we will be discussing about that project, so there are some more features will be available. So we will discuss it there. Roll up summary can be of max min, average and total. Yes, Pankas, you are right. Master detail relationship can be created only on custom object can be created on standard object as well. So I think yes, let's try it out. So if I go to opportunity fields and relationships and if I click on new. Yeah, so I think you are right. Like we cannot create master detail relationship on standard object. So it should be somewhere written in this document. So if you read this master detail relationship, so here you will find this. Yeah. So here it is standard objects can't be on the detail side of a custom object in a master detail relationship. Right. So I already told you everything. Every information is available here. You can go through. Okay. Now, let's understand next thing. Okay. Before converting master detail into lookup, let's see these relationships and schema builder. So we gone through schema builder earlier. So one feature we didn't explore. So if I open schema builder now, so here you will be able to see the relationships. So here we have two object student and instructor. Right. And we need to select class as well. Okay. So if I have it. So right now you can see. So student and class are sharing master detail relationship. So it is showing master detail relationship from student to class. So student is on child and class is on parent. And if you see this diagram carefully, here you see three lines. Right. And here you see one line. So it is one too many. Right. And here is the legend which is showing colorful lines. So red is for master detail and blue will be for lookup relationship. Right. So what you can do when you will be completing this exercise, so you can just go and check your schema builder because you will be creating two lookups between student and class and between instructor and class. And just try to create all these roll up summary fields and other things. Here we need to create a formula field and average of entrance code. So for this, what you can do, you need to divide total entrance code with total student. To calculate the average. Right. So these two roll up summary fields, you can reference in your formula so that you can have average entrance code. Then you need to convert lookup into master detail. Then create roll up summary. Then convert master detail into lookup so that we are going to do right now. So we will be converting. Okay. This we already did convert lookup into master detail. So first we need to populate value in lookup field of each record. And if you want to convert master detail into lookup. So what we need to do if you have created roll up summary field on parent object, so you just need to delete those roll up summary fields from parent object. And when you delete your field, so it goes to recycle bin, so you need to delete it from there as well. And then only you will be able to convert your master detail relationship into lookup. So let me do that. So I'm moving to class subject and here I am selecting fields and relationship. So here I have this roll up summary field. So I'm going to delete it. It is deleted. Now if you see this deleted fields, so here you will find that deleted field. Okay. So Salesforce starts to hard delete these fields after 15 days. The hard delete process permanently removes all metadata and system data for the field. It is kept the 15 day grace period and immediately sets the field to ready for the hard delete process and delete if available restores the field. Right. So if you and delete. So it will be restored. Right. But what we need to do, we need to delete it again. So you can see it is restored. So if you delete again, it will go to deleted fields. And now you just need to click on this erase so that it will be deleted permanently. So now it is asking. Yes, I want to permanently delete the custom field. So you can just click on delete and it is deleted. Now you need to go to your child object that is student. Go to fields and relationships and here you will find your master detail relationship field. So what you need to do added this and you need to click on change field type. Right. And from here you can select lookup relationship. Right. And click on next and save. So this way your master detail field will be converted into lookup field automatically. Right. So I hope you understood everything how to create lookup, how to create master detail, how to convert lookup into master detail and how to convert master detail into lookup. And along with that we created roll up summary field as well. Let me pick some more questions. So what is the difference between account and contact relationship? So difference means it is a lookup relationship and it is standard relationship which is created by Salesforce. What is the need to delete from Recyclebin also? Because if you don't delete from Recyclebin and if you converted your master detail into lookup and after two days let's say if you restore that field, so it won't be restored because relationship is not master detail. It is now lookup. That's why. So Mary is asking where can we reach the bin? So it is here, deleted fields. If you go to deleted fields, so you will find your deleted field. So lookup relationship between account and contact. So this is lookup relationship, but it is a special type of relationship. So here few features are available of master detail as well. So you just need to study it. It is a special relationship. It is created by Salesforce as a standard relationship. So I'm not understanding what exactly you want to know. Anand. And if you have any other question you can just mention in the chat anyone if you want to ask. So I had one more topic many to many relationship. So this I'm going to explain now quickly. So in case of many to many relationship, what we need to do, we need to create new object and that object will be known as junction object. So basically what will happen that junction object will be having two master detail field available. So it will be looking up to two objects so that it can have data for two objects in many to many form. So let's first create it. And then I will show you how it is many to many. And this is the requirement. So I'm going to create a object STD class and it will be having master detail to class and master detail to student. So from object manager, I'm creating this. And here I'm going to pick auto number. So SC for student and class and then 0000. And starting number will be one. I'm going to create a tab for this. Selecting a tab style. Next default on next. And I'm going to place it on two applications. And save it. Now I'm going to create two master detail fields here. So one will be for student and another will be for class. So first I'm going to create for student. Next. Next. Next and save. Now I'm going to create one more. That will look up to class. So one more master detail field I'm trying to create. And it will look up to class. Clicking on next. And save. So this way two relationships are created here. And if you click on new. So you can see now you cannot create one more master detail because we already created two. You cannot create this type of field because this object already has two master detail relationships. So this validates like we can create at max two master detail relationship on one object. Now if I go to the UI and refresh the page so I will be having that junction object. So now what I can do if I try to create a new record. So what we can do we can select a student. So someone asked me like if one student is related to two classes. So how we can identify that. So we can identify that through this junction object. So from here I'm selecting Salesforce DAV. So this S01 is related to this class. Saving it. So one record is created. Now I'm going to create one more record. Selecting the same student and different class. Saving it right. And here I'm going to update this list view so that I can show you the details of student as well as class. And I'm pinning it. So you can see these are auto numbers. Here student information is available and here class information is available. Now if I create one more student five and relating it to Salesforce DAV. So you can see one student like 0001 this is one student which is having two different classes. One to many. And one class is having like Salesforce DAV is having two different students. So that's why it is many to many. So one student can have many classes and one class can have many students. So this way you can manage your many to many relationship. And we have master detail relationship. So it means if I delete any student record suppose I deleted as 0001. So if that students two entries are available here so both will be deleted automatically. Right. And if I delete Salesforce DAV or Salesforce admin class so it's all entries will be deleted from here automatically. So this way we manage many to many relationship and this is basically known as junction object which is having two master detail relationship. Okay. So this was the last topic for today's session. Now I'm going to take some more questions. So can we create junction object with three master detail? No. We can have only two. I already showed you. So how you are identifying classes master I can make class as child and student as master. Yeah. So this depends on the requirement. So asset this depend depends on the requirement. So when you will be working on the project. So architect will tell you which will be the parent object and which will be the child you won't be deciding at your own. Right. So architect will discuss with a client like what is the actual business requirement and according to that we identify. Shubham. I already explained many to many relationship through junction object. Yes. We cannot create master detail on standard object. I already explained this. We cannot create junction object with three master detail. We can only create two. Right now I created a junction object junction object is a special object which will be having two master detail relationship that is basically known as junction. So if you see here this STD classes junction object which is having information of student as well as class. So junction means which is brisk between two objects. So one is student one is class and it is having records for both so that we can have relationship like which student is related to which class if one student is related to more than one classes so we can have records here implemented. And if you go if you go to the student record so here you will see in the related list as well. So the student is having these two junction records. If you open this so it will show you like the student is related to which class. Right. So this way you can open the information. Yeah. The example is correct and next question is many to many objects means both object must be a master object in master object we need child object so we need to create junction object. Yes. Right. What will it show in class field on detail tab of student nothing. So here when we are talking about this junction so student and class are related here only if I open this student so there can be different class. So this you need to select accordingly because here also we have look up to class so this is one to many relationship and this is many to many so you need to work smartly here if you have many to many relationships then in that case you won't be having one to many relationship but if you have both then data will be incorrect. So thank you everyone those who are appreciating my efforts. One question is what does it mean field to aggregate and roll up summary. So field to aggregate means for example on parent record if you want to count how many child records are there so that is meaning to aggregate. So like sorry that that is particularly for counting. Now if you want to calculate some so let's say we have entrance score we want to calculate some of all the entrance scores which are populated on student records. So like field to aggregate means which field you want to calculate as some right so they can be more than one numeric or currency field so you need to select one so that it can be summarized. So plan is asking if suppose we have two object of one child if one object is deleted you cannot delete object if it is referenced somewhere. Yes Mary your example is correct sir how many types of object two or three. Nilesh can you explain can you elaborate your question a little bit more. So so Ramya is asking which objects have junction relationship so right now I created a custom but some standard objects are also having junction so if you go to opportunities so if you open any opportunity record so here you will find some junction object so here if you go to related so here you can see this is contact role so this is basically junction here we need to add contact as well as account so this this can be working as junction so this we will be discussing later on like when we'll be utilizing all the standard objects for different requirements so maybe there you will see yeah there is standard junction object so I will show you later on so right now like you won't be able to understand because we need to understand this platform more than you can understand the standard junction so I will show you that later on yes Rekha we can have more than one junction object in a single project one more good question while conversion of lookup to master if you have 15k records in a particular object how to fill the lookup field so that we can do with the help of data loader so we need to use data loader or data import with art so through that we will be or maybe you can use some automation tool so we can use we can use flow or we can use trigger right so or we can have schedule jobs so we have automations through that we can do so in Salesforce we have two types of objects standard type of object and this junction is not a type of object junction is spatial object which is having two master detail relationship so junction can be of standard type it can be of custom yeah workbench is also an option to a mass update the records okay so if you have more questions you can ask I think I try to answer all the questions still after the session if you have questions so you can mention them in the comment section and do practice this session because it is important to understand so I created lots of exercises for you so just practice so that you understand yeah so the good question so it will take the property or security of primary object the first master detail that you created yes we can create roll-up summary by using trigger so in case of lookup relationship if you want to summarize child data so we can do that with the help of triggers so if you guys have any more questions you can ask otherwise I can wrap the session here and I hope you are liking this bootcamp so please continue attending the sessions and doing practice because I am providing you day wise exercise so that you can implement those and after completion of all the admin related concept we will be doing one hand end-to-end project together so I will be implementing it in my system and together you will be implementing in your system and whatever question answers you will be having so we will be discussing them as well so this way like admin is easy but in-depth knowledge is required so I am trying to give you that in-depth knowledge so that you can understand all the concepts properly thank you Mary yeah I am taking medicines so I will take care thank you everyone so we'll see you tomorrow with new topics