 MySQL, SQL, and the WordPress database. MySQL is one of the most popular database systems for web-based applications. This lesson will introduce you to the MySQL database system, as well as how you can interact with it. MySQL is an open-source relational database management system. It is used to store data in a database and to retrieve that data when needed. SQL stands for Structured Query Language, and it is a programming language that is used to interact with data in a MySQL database. As you learned in the lesson on WordPress and web servers, WordPress uses a MySQL database to store all of its data. This data includes things like posts, pages, comments, and users. One of the tools that you can use to interact with a MySQL database is PHP MyAdmin. PHP MyAdmin is a browser-based tool. It allows you to interact with your MySQL databases using a graphical user interface, but it also allows you to run SQL queries on them. It is often included in the control panel of your web host or local development environment. To create a table in a database, you would use the create table statement. This statement takes the name of the table and the columns that the table should have. For example, to create a table called colors with the columns ID, type, and value, you could use the following SQL statement. This will create the colors table with the relevant columns. If you wanted to add a row to a table, you would use the insert statement. This statement takes the name of the table and the values for each column. For example, to add a row to the colors table, you could use the following SQL statement. If you now browse the colors table, you will see that the row has been added. To read rows from the table, you would use the select statement. This statement takes the name of the table and the row to read. For example, to read the row with the type of header from the colors table, you could use the following SQL statement. And this will return the requested rows. If you just wanted the value of the value column, you could use the following statement. And this would then display only the data from the value column. If you wanted to update a row in the table, you would use the update statement. This statement takes the name of the table, the column to update, the new value, and the row to update. For example, to update the value of the value column in the colors table, you could use the following statement. If you browse the table, you'll see the value of the value column has been updated. To delete a row from the table, you would use the delete statement. The statement again takes the name of the table and the row to delete. For example, to delete the row with the type of header from the colors table, you would use the following SQL statement. Browsing the table will show that that record has been deleted. In the previous example, you may have noticed the use of the type column to update or delete the row. While this works, it's not the most efficient way to update or delete a row. This is because the type column is not unique and there could be multiple rows with the same type. Additionally, if you wanted to update or delete a row, you would need to know the value of the type column, which may not always be possible. For this reason, it's usually a good idea that your database tables have at least an ID column and that that ID is unique and auto-incrementing. It is also a good idea that the ID has an index on it. Indexes allow MySQL to do much quicker selects, updates, and deletes than if a field does not have an index. Unlike PHP and JavaScript, SQL is a query language that is executed on the database. Additionally, because JavaScript is run in the browser, you generally don't make requests to the database from JavaScript and would instead do it using PHP, which is executed on the server. To run an SQL query, you would create a connection from PHP to the database, prepare and then run the query, and the results of the query would be returned to PHP as some type of variable. Fortunately, as you learned in the module on how WordPress works, WordPress includes a database API that allows you to manage the connection to the database and run any queries you need to. Additionally, if you use the default WordPress data types, you won't even need to worry about executing SQL queries. For more information about MySQL and running SQL statements, you can visit the following online resources. There is a MySQL tutorial in the MySQL documentation. There is also the MySQL reference manual on the MySQL website. And Free CodeCamp has a Learn MySQL beginner's course.