Week 11 - Containing Data

Week 11 - Containing Data

·

7 min read

This week at bootcamp we started our back-end module with Docker & SQL. It feels a little unsettling to be back at the beginning of something, having worked and studied so hard over HTML, CSS & JavaScript over the past 10 weeks, however, I'm also very interested in how the back-end works!

So, what did week 11 look like?

Containers & Docker

We started to learn about containers, which were still a bit of a misnomer to me until I read this article and I've pulled this quote in particular as I think it illustrates it well:

Instead of shipping around a full operating system and your software (and maybe the software that your software depends on), you simply pack your code and its dependencies into a container that can then run anywhere.

A container is a runtime environment which contains the application and the libraries/frameworks which it depends on, so you can host lots of them on one operating system. The containers talk directly to that one operating system which is hosting them, this keeps the overhead low.

Docker is a container machine, which is an emulation layer between the guest and the host operating system (these are sometimes called 'hyper visors'). It is designed to make containers easier to use. In bootcamp we used Docker to run the container for our SQL exercises.

For a longer read, check out this freeCodeCamp article.

Databases and SQL

First off - what is a database? A database is a collection of information which is organised so the data can be stored, managed, updated and retrieved. Databases exist so data is easier to access and easier to manipulate.

A relational database:

  • has data organised into tables with rows and columns, following a schema
  • provides access to data points which are related to each other
  • allows you to maintain the relationships between tables
  • typically you will work with multiple tables of related data
  • there are multiples types of data relationship (cardinality)
  • typically every row has a unique sequential ID

A non-relational database:

  • has data organised by nesting in a single document
  • has no/few data relationships
  • specifies a unique non-sequential ID
  • doesn't have a schema
  • stores all the data in one place

SQL stands for Standard Query Language and is a language used with relational databases. SQL allows us to interact with the data in the database, using software such as MySQL. It is an efficient way to make queries and modifications to the data, and we do this using CRUD functions:

CRUDSQL Syntax
CreateINSERT, CREATE
ReadSELECT
UpdateUPDATE, WHERE
DeleteDELETE, DROP

To CREATE a record: Use the INSERT statement to create a new record.

To READ a record: Choose a table and use SELECT based on a specified primary key

UPDATE a record: Executes an UPDATE statement on the table based on the specified primary key for a record within the WHERE clause of the statement.

DELETE a record: Deletes a specified row specified in the WHERE clause.

A SQL query (Read in CRUD) might be followed up with another CRUD action to achieve the complex interaction you require. I found a really helpful article on SQL query order here.

SQL also uses operators (with WHERE statements):

OperatorsSQL Syntax
Arithmetic+ - * / %
Comparison= > < >= <= <>
Compound+= -= *= /= %=
LogicalALL, AND, ANY, BETWEEN, EXISTS, IN, LIKE, NOT, OR, SOME

Our bootcamp challenge for the week, now we were up and running with Docker, was to use SQL and MySQL workbench with the northwind database, running queries and manipulating data. You can enjoy a basic MySQL tutorial here and read more about SQL syntax here. I enjoyed learning SQL and I will be sad to leave it behind (at least for a little bit).

Here's to week 12 of bootcamp!

My Key Take Aways

Take your time - When working with data it is important to be consistent and clear. Therefore, familiarise yourself with a database and its schema before getting stuck in. This will help you understand the relationships within the database and avoid mistakes and errors. Also take your time to process big ideas and concepts, like containers.

Consider things in real-life terms - A technique that has really helped me understand some more abstract parts of this course, and especially with back-end, is to think about real-life examples. Websites like IMDB for example, are a great example when thinking about databases, or think about what is happening when you update your details on your Amazon account.