Unit introduction
Welcome to unit two in course two of Make Basics.
Within this unit you will explore Collections and Arrays.
You will not be building any scenarios in this unit, but will be focusing on these very important concepts – they will help going forward over the next few courses, and with your use of Make going forward.
By the end of this unit you will:
- Gain an understanding of what a Collection and an Array is.
- Identify the difference between the two.
- Know the benefits to using an array.
Overview of Collections and Arrays
We have covered Basic Data Types in previous two units (Text, Numbers, Boolean etc.).
Collections and Arrays are considered complex data types. Both of these contain several data types within them, but are structured differently.
Before we delve into this in more detail, a brief overview for now:
Collection
A Collection is an unstructured set of Data Types. Think of this as a playing card; it has several properties (e.g. the 5 of Spades).
Array
An array stores different Data Types, such as numbers (123), boolean (yes/no) and strings (text / dates) in a structured list. Think of this as multiple decks of cards arranged in a pile.
What is a collection?
Overview
A Collection is a set of properties which describe a specific object. Each of these properties has a value that has a specific Data Type – Text, Number, Date, Boolean, etc.
When multiple properties are combined, you are describing an object; for example, the details of an individual. Objects are the most important factor to remember here. Properties can contain different data types within a collection; they are not limited to a single one.
Example
Let’s use the contact details (object) of a medical record of a patient as an example.
A collection may appear as the following:
- Contact (collection)
- First Name (text)
- Last Name (text)
- Date of Birth (date)
- Place of Birth (text)
- Phone Number (number)
- Notes (text)
This set of properties together make up our collection!
Within Make, this collection would be represented with a structure like this:
Contact_Details (Collection)
First Name: Make
Last Name: Academy
Date of Birth: 22/12/22
Phone Number: 123456789
Notes: The patient visited their doctor following having their mind blown at the potential of Make, that they learned about within the Make Academy. Symptoms include a desire to learn!
Tip: You can identify a collection in Make by the
(Collection)label next to its name.
Collections of collections
A Collection can contain other Collections. For example, if we want to expand on the place of birth of a patient, we can add an Address Collection, with all details (street address, city, etc.).
The patient details Collection will then look like this:
- Contact (collection)
- First Name (text)
- Last Name (text)
- Date of Birth (date)
- Place of Birth (collection)
- Street (text)
- City (text)
- Country (text)
- Phone Number (number)
- Notes (text)
Within Make, this nested collection would be represented as:
Bundle 1 (Collection)
Contact_Details (Collection)
First Name: Make
Last Name: Academy
Date of Birth: 22/12/22
Place of Birth (Collection)
Street: 1 Make Avenue
City: Prague
Country: Czechia
Phone Number: 123456789
Notes: The patient visited their doctor following having their mind blown at the potential of Make, that they learned about within the Make Academy. Symptoms include a desire to learn!
Why are they useful?
Collections can be used to describe what exactly the object is, with as many details as we want.
Within Make, collections of data can be easily used in mappings. If you have created the Make Foundation / Make Basics Use Case, you will have experienced how easy it is to map items from within a collection.
Here’s another example of a collection, representing weather coordinates:
Bundle 1 (Collection)
Coordinates (Collection)
Temperature: 8.25
Atmospheric pressure: 1035
Air humidity: 67
Wind (Collection)
speed: 4.63
deg: 260
Cloudiness: 100
Sunrise: 10 February 2023 07:24
Sunset: 10 February 2023 17:04
Status: Clouds
Code: 804
Description: overcast clouds
When working in Make, you can easily map data from a collection (like the Contact_Details from a JSON → Parse JSON module) to fields in another module’s data structure. For instance, you can drag and drop First Name from the parsed JSON output to a First name field in a target module. This structured approach makes it simple to organize and transfer complex data between different applications and services.
What is an array?
To keep it simple, if a collection is an object, then an array is a list of objects.
An array contains multiple items. For instance, we can have an array of Text, and an array of Numbers. The items themselves can have any data type, but all array items need to have the same data type.
As a very basic example, if you want a list of cities, you can use an Array of Texts. In Make, an array is identified by (Array) next to the item name, and its contents are typically numbered, like city: (Array) followed by 1 London, 2 Paris, etc.
Tip: how to identify an Array
Side by side – Collections and Arrays
An Array can contain more complex objects, such as Collections. Let’s compare the array and collection side by side using books as the example.
Collections
If we want data for an individual book, we would have a collection. A book (object) has several properties: a title, genre, release date, etc.
Here are two separate examples of collections (books), with how they display in Make:
Think of this Collection as: 2 books = 2 objects = 2 bundles
Book (Collection)
Name: Make 101
Number of Page: 213
Genre: History
Date of Publication: 22/02/22
Language: English
Summary: A comprehensive guide to getting started with the Make automation platform. This book is a printed version of the Make Academy.
Book (Collection)
Name: The Automation Man
Number of Page: 322
Genre: Sci-Fi
Date of Publication: 01/01/12
Language: Czech
Summary: It all started with a vision; to create a robot that would automate everything. In 2012, the vision came to life... this is...The Automation Man!
Arrays
As stated, an Array is a list of items, such as Collections. For example, if you want to handle a list of Books, you will have the following Array. The Array is still a list of objects, but this time, each object is a Collection, with multiple properties.
Think of this Array as: 2 books = 1 array = 1 bundle
Books (Array)
1 (Collection)
Name: Make 101
Number of Page: 213
Genre: History
Date of Publication: 22/02/22
Language: English
Summary: A comprehensive guide to getting started with the Make automation platform. This book is a printed version of the Make Academy.
2 (Collection)
Name: The Automation Man
Number of Page: 322
Genre: Sci-Fi
Date of Publication: 01/01/12
Language: Czech
Summary: It all started with a vision; to create a robot that would automate everything. In 2012, the vision came to life... this is...The Automation Man!
What can you do with arrays? (accessing array objects)
You can access array items by the array index. This will be covered in greater detail in a later course. For now though as an overview:
Each Array has its own index – this is a numbered list, the image to the right reflects the index item of each city, for example 1 - London, 2 - Paris…
The most common way to retrieve a specific piece of information from a list, is by accessing the index of the object we want to retrieve.
For example, in the Array for city, if you want to retrieve the second city, you would ask Make to return the following: city[2].
This will return Paris from the example.
The same idea applies to other Arrays. For example using the Array of Books, asking Make to return Books[1], would return the full collection of the first book.
What else can you do with arrays?
Sorting Arrays
With arrays you are able to sort the data using Make, using the SORT function; this will be explored in the next course.
For example, sorting the city Array into an ascending or descending (alphabetical) order:
Ascending will return London, New-York, Paris, Shanghai, Toronto. Descending will return Toronto, Shanghai, Paris, New-York, London.
Extract a range
You can extract a range of elements within an Array.
For example, performing an advanced search specifying the cities of index 3 to 4 will return Paris and Shanghai.
Advanced searches
Performing an advanced search would allow you to return specific results based on the values of properties of your choice.
For example searching for the genre of Sci-Fi (a property of an object) in the book Array would return The Automation Man.
Imagine performing this kind of action on an entire library of books!
Iterate / Aggregate (Optional)
Iterators and Aggregators will be covered later on in Make Basics. At this stage it’s important to gain an understanding of what an array is, before we delve deeper into manipulating data.
To briefly summarize:
An iterator allows you to take an Array, and split this into separate items; allowing you to process them separately one by one.
An aggregator will bundle items together in one or several Arrays.
An iterator performs actions on an Array of books, processing them individually. An aggregator performs actions on an Array of books, combining them into a single array.
Data extraction (optional)
Note: This is considered an advanced function and is optional at this stage. This topic will be covered in Make Basics course 3.
When you have an Array of Collections, you can make advanced data extraction using functions within Make.
For instance, if you want to get the Summary of the Sci-Fi genres in an array, you can use a map function. This will return a new Array that contains only the Summary.
Example function: map(55. Books; Summary; Genre = 'Sci-Fi')
Example output:
- A comprehensive guide to getting started with the Make automation platform. This book is a printed version of the Make Academy.
Why does it return another Array, and not just the Summary Text?
It’s because the map function could return multiple elements, if there were more than one Sci-Fi genre in the array.
For example, if you have a list of Contacts, and you want to return the Last Name of all contacts that live in New-York, there will be more than one contact.
What to remember from this unit
That was a lot of theory, and we recognize that’s a lot of information to learn all at once!
So let’s wrap up this unit with looking at the 3 most important details to remember:
- A property together with the property value describe a specific object: e.g. name (text) / date of birth (date) / phone number (number).
- When multiple properties are combined, this forms a collection. Such as ‘contact details’.
- The description of a collection is also known as an object.
- An array is a list of items; think of this as ‘multiple cities / books’.
We will start to expand on Arrays in the last course of this Make Basics.