Fundamentals of SQL

SQL, or Structured Query Language, was created in 1970 to interact with databases. SQL is pronounced sequel or sometimes ess-queue-ell, and was initially known as the structured English query language (SEQUEL).

Over the years, SQL became a standard way to query and manipulate several databases. Hence, making it possible to use SQL across different database systems. Database systems or Database Management System (DBMS) is a piece of software that uses SQL behind the scenes to manage the data in a database.

Example DBMS are Oracle, Postgres, SQL Server, and MySQL. Using SQL with different DBMS might be slightly different in a few cases, however, it follows the same syntax for most. A typical workflow of DBMS being used to manage customer orders is shown below.

sql-dbms

SQL vs NoSQL

To choose the right type of database, we need to look at both the relationship between the data point and the structure of the whole data. For SQL databases, they organize data into well-defined tables and relationships, like a neatly arranged photo album, making them great for structured data that fits into a fixed format.

sql-vs-nosql

However, NoSQL databases offer a more flexible and scalabale approach, where data can be stored in various ways without a predefined structure. This is ideal for handling a wide range and scale of data types and relationships. Now, let's look at how these two database types differ based on structure, queries, and use cases.

Now that we have an idea of what SQL is and why we need it, we can then dive into writing SQL statements to define and manipulate our datases.

NOTE!: In subsequent lessons, we'll only focus on SQL usage in a relational database context.

👩🏾‍🎨 Practice: Database selection

The following are the TODOs...✍🏾

  • Assume you have a bookstore and needs to annalyse the sales across multiple cities.
  • What type of database will be well-suited to your analysis? SQL or NoSQL?
  • Justify your answer