# Step 1: Create the Customers Entity

The first step is to create the Entity for storing customer account records.

* To go to the Entity database section, click “Entity database” under the “Database” menu on the left side panel.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5entitiesdbmenu.png>" %}

* To create a new entity, click the \[+ Entity] button on the displayed page.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_2/ch2whatisanentity_addentity.png>" %}

* The New Entity settings page is displayed. To label the entity, enter the Entity name as “UserName\_Acc\_customers”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5entityname.png>" %}

* Optionally add a description.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5ntitydesc.png>" %}

* The Field tab is preselected with one field created by default.\
  To add a field, click the \[+ Field] button.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5addfield.png>" %}

* To store customer details in the Entity “Username\_Acc\_customers”, add and define corresponding fields following the steps below.
* To define a field storing the primary key for this entity, define the field for Customer ID as follows. (The relation of this Entity with the Activities Entity will also be established through this field.)
  1. Enter the field name as “Customer\_ID”.
  2. Select Data Type as “GUID”.
  3. Select “Primary Key”. This field will contain the primary key for this entity.
  4. Select “Auto Generate”. This value of this field will be auto-generated with each new record.
  5. Select “Display”. This field will be displayed in the entity.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5custidfield.png>" %}

* Add another field.
* To store the customer’s first name, define the field as follows:
  1. Enter field name as “First\_Name”.
  2. Select Data Type as “string”.
  3. Select “Default Field”. This is the default field to be displayed.
  4. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5fnfield.png>" %}

* To store the customer’s last name, add and define the field as follows:
  1. Enter field name as “Last\_Name”. This contains the customer’s last name.
  2. Select Data Type as “string”.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5lnfield.png>" %}

* To describe the status for the customer as Active or Inactive, add and define the field as follows:
  1. Enter field name as “IsActive”. This contains information on whether the customer is active or inactive.
  2. Select Data Type as “Boolean”. This field can either be true or false.
  3. By default, this value is set to “false”.
  4. Select “Display".

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5isactivefield.png>" %}

* To store the customer’s phone number, add and define the field as follows:
  1. Enter the field name as “Phone”.
  2. Select Data Type as “string”.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5phonefield.png>" %}

* To store the customer’s email address, add and define the field as follows:
  1. Enter the field name as “Email”.
  2. Select Data Type as “string”.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5emailfield.png>" %}

* To store the customer’s joining date, add and define the field as follows:
  1. Enter the field name as “Join\_Date”.
  2. Select Data Type as “DateTime”. A template of the date and time will be populated as Default Value.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5joindatefield.png>" %}

* To store the customer’s address, add and define the field as follows:
  1. Enter the field name as “Address".
  2. Select Data Type as “string”.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5addressfield.png>" %}

* To store the customer’s city, add and define the field as follows:
  1. Enter the field name as “City”.
  2. Select Data Type as “string”.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5cityfield.png>" %}

* To store the customer’s Zip Code, add and define the field as follows:
  1. Enter the field name as “Zip\_Code”.
  2. Select Data Type as “string”.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5zipcodefield.png>" %}

* To store the customer’s country, add and define the field as follows:
  1. Enter the field name as “Country”.
  2. Select Data Type as “string”.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5countryfield.png>" %}

* A customer value is the amount of business that a customer provides to a company. This can be measured as the amount of expenditure a customer makes to procure the company's products or services. Create and define the field as follows.
  1. Enter the field name as “Customer\_Value”.
  2. Select Data Type as “integer”. Enter Default Value as “1”.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5custvalfield.png>" %}

* A customer rating is the number allotted to a customer reflecting the number to measure the customer loyalty level and is denoted by a range of numbers e.g. 1=Beginner, 2=Average, 3=Top Profile. To store the rating of the customer, create and define the field as follows.
  1. Enter the field name as “Rating”.
  2. Select Data Type as “integer”. Enter Default Value as “1”.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5ratingfield.png>" %}

* To store only day and month of the joining date of the customer, create and define the field as follows:
  1. Enter the field name as “DayMonthJoinDate”.
  2. Select Data Type as “string”.
  3. Select “Display”.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5daymonjdfield.png>" %}

* To save the Entity, click the \[Save] button.

<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5saveentity.png" alt=""><figcaption></figcaption></figure>

* To close the Entity, click the \[Close] button.

<figure><img src="https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5closeentity.png" alt=""><figcaption></figcaption></figure>

* To open the created entity, in the list of Entities, click on “Username\_Acc\_customers”. The list will show the records created if any, and the columns are the fields that are selected with display option.
* Additional fields such as Modified Date, Created Date and the Actions column will also be populated for additional information on the record. These dates are when the record was created, updated. The Action column is for any action needed to be taken for entity record such as deletion.
* In this exercise, the record is added through the API (to be created in Step 2). However, users can add a record directly into the Entity. ⠀1.To create a record directly in an Entity, click on the created entity in the Entities listing
  1. To create a record directly in an Entity, in the Entities listing, click on the created entity.
  2. Click the \[+ Record] button.
  3. In the displayed form, enter the relevant information to be stored as a record.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5addrec.png>" %}

* Click the \[Save & Close] button. One record will be updated in the Entity.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_5/ch5savencloserec.png>" %}

* To create a record in the Entity through an API, proceed to Step 2 of this exercise.
