These lessons will learn how to work with complex data types and how to write queries using these types of data. This lesson will start by working with the array data type. First, an array is defined by multiple values within a single column. Let's review the generic syntax. Become more familiar with this data type. When creating a table with an array data type, we still use the create table statement as well as the table name. Any other columns that meet traditional your data types. But for our text array column, we're going to go ahead and use the text data type. But now we have these square brackets to indicate that this is an array data type. The insert array values into a table will still use the insert into statement followed by the name of the table. The names of the column headers, the values, keyword, any other traditional data types. In this case just a text value. But now when we want to insert an array, we have to use the array keyword followed by square brackets, and then the multiple values within our square brackets. Arrays allow us to streamline data storage by simplifying the schema design and reducing the number of extra tables. Let's say there's a scenario, or we are working for a bookstore who wants to store multiple genres for the same book. We'll go ahead and create this table and name it books. We'll create the book ID, which is serialized, meaning it will increment by one value each time as well as this is the primary key for this table. Then, since the title can only have one value, we'll just go ahead and store this as a text value. But for our genres column, we want this to be an array data type. So we use the text data type with the square brackets to indicate an array. Let's go ahead and create this table by pressing the play button. Now let's go ahead and insert a row into this table by using an insert into statement. What's the name of the table in this case, Books, the column headers, which are the title and the genres our values, keyword and our title will be The Great Gatsby. Now, for our genres, we have to use the array keyword and then we can use our square brackets in the multiple values within this array. Let's go ahead and insert this row by pressing the play button. Now that we've created our table, let's view how this data is stored. Let's go ahead and press the play button and we can see here it has our book ID followed by the title, but now we have multiple values and one column. Let's take it one step further by adding a conditional statement to our query. This time will simply select the title from our books table in our conditional statement to say where fiction and here we'll say, is equal to any of the values within the genres column. In other words, the any operator checks A fiction is present in the genres array. Let's go ahead and run this by pressing the play button. We see here the correct row is returned, but now let's say we like the structure of our table or we want to update the values within our table. So we'll use the update keyword followed by the table. In this case, books, we use the set keyword followed by the column. In this case, the genre column. And since we're using PostgreSQL, we have a function available to us. Name array, append. This function allows us to easily update these records, so the first parameter of this function will be the column, which is the genres column, and the next parameter will be the value. And we want to add mystery to this column. Then we'll use our where clause to signify which row we want to append. And for this scenario, we want to say where the title is equal to The Great Gatsby. Let's go ahead and update this record by pressing the play button. Now let's view our table to make sure this was updated correctly. Go ahead and press the play button. And we can see here mystery has been added to the genres column. Similarly, say we want to remove an array value again. We'll use the update keyword on the books table, the set keyword on the genres column, and we have another handy function. Name the array. Remove function. Once again, we list the column in this case, genres and the value we want to remove, which is classics as well as our conditional statement to define the row, which is The Great Gatsby Row. Let's go ahead and update this record by pressing the play button. And now let's review our books table to make sure this function worked correctly. Go ahead and press the play button again. And now we don't see the classics value. Since we have such a small table, we can perform these types of operations without the risk of slowing or stalling our database. However, I implore you to be mindful of using the array. Append an array, remove functions when dealing with large arrays. It's always best practice to segment out a section of your use case before performing a massive data manipulation operation. Thanks for watching. Stay tuned for the next lesson where we learn how to handle JSON data types and ask you to.