Structured Query Language (SQL)
What is a structured database?
A database stores information. Traditionally databases store information in a ‘structured’ way. So you might have a database ‘table’ called books, which would have ‘fields’ like ‘title’ and ‘ISBN number, and you might have another database table called ‘authors’ which would have fields like ‘first name’ and ‘last name’. In this example database you could expect that the ‘books’ table would also have an ‘author_id’ field that links to a ‘record’ on the ‘author’ table - i.e. each book will have a designated author. The structure of these tables and the relationships between them is well though through in advances in so called ‘Structured’ databases.
What is Structured Query Language (SQL)?
SQL is a language by which you can interact with a structured database. So for example you might run an ‘SQL query’ to retrieve all books written by a particular author from a database. Or you might run a query to add a new book to the ‘books’ table on our example database. There are different types of SQL - such as SQL, MySQL, SQLite, and PostgreSQL. They all follow roughly the same conventions, so when you learn one you can easily learn the others.
Examples of SQL
SQL is intended to be human-readable, so for example to find all books written by a “John Smith” we might first run a query like “SELECT id FROM author WHERE first_name=’John’ AND second_name=’Smith’”. This would get the author’s ID (e.g. 4). We could then run a query like “SELECT title, isbn_number FROM book WHERE author_id=4”. This would return the names and ISBN numbers of all books written by John Smith. These are simple examples, but SQL queries can be very powerful ways to interact with large and complex data, and every budding programmer should ensure they learn it well.