MySQL: Tables (Game of Thrones Edition)

In this post, I’ll be talking about MySQL tables using the Feynman Technique using examples from Game of Thrones. This post is part of the Feynman/20-hour challenge. For more information, click here. Also, included in this post are Game of Thrones spoilers, so if you are still going through the backlog of episodes on HBO Max and haven’t gotten to the end of the series, you have been warned.

What is MySQL?

MySQL is a database programming language that can best be described as a bunch of tables, kind of like an Excel workbook, but more involved. In the case of MySQL you can keep a bunch of different databases within one file, and go in and out of them pretty seamlessly, however, you need to tell the program what type of information and what are the requirements of that information should be entered into the fields.

For you Game of Thrones fans out there, we’re talking about Littlefinger depth of manipulation and control.

To give you the breath of the level of information you need to express when making a table, here are the options available through MySQL:

String TypeNumeric TypeData Type
charintdate
varcharsmallintdatestamp
binarymediuminttime
varbinarybiginttimestamp
blobdecimalyear
tinyblobnumeric
mediumblobfloat
longblobdouble
textbit
tinytext
mediumtext
longtext
enum

…and you thought Java datatypes were crazy, huh?

Table Data Samples

For the sake of simplicity, we’re going to be using two of the more common data types: int (integer), and varchar (variable character).

Int(default) are whole numbers in MySQL with a max value of 2,147,483,647. The reason why I mentioned “(default)” is because there are two versions of int: signed and unsigned, and by default, int in MySQL is traditionally “signed”. The unsigned max value is doubled (4,294,967,295). You didn’t need to know that right now, but figured for those that are sticklers, know that I see you.

If we were to create a database and called it “stark_children”, it would look something like this:

varchar(10)intvarchar(50)
ChildrenStart AgeHighest Titles (in Television)
Robb15King of the North
Jon14Aegon of Houses Targaryen and Stark
Sansa11Lady of the North
Arya9Princess of Winterfell
Bran7King of the Andals and the First Men
RickonthreePrince of Winterfell

The first row explains what kind of information would be allowed in the columns after the title. Since our first column would include names, we used varchar(10), which means, it would be a string of letters, nor more than 10 characters that would be allowed in that column. The second column would include the start ages of each of the Stark children, so we used int (integer) to inform our database that the stuff we will be putting inside would be numbered. In our final column, we wanted to include the final titles of each of the characters, so we used varchar(50). Spaces are counted in the 50 character limit.

What if you go over the character limit?

If we were to attempt to add letters beyond the designated character count in the varchar columns, only the first 50 letters would be saved in our database, so if we attempted to put the full title of Jon Snow, which is “Aegon of Houses Targaryen and Stark, Sixth of His Name, King of the Andals and the First Men, Lord of the Seven Kingdoms, and Protector of the Realm“, only “Aegon of Houses Targaryen and Stark, Sixth of His” would show up in our database, since we designated a 50 character limit (varchar(50)).

https://youtu.be/eeNB4uvwieU

Also, if we tried to use a string (a bunch of letters) to represent a number, in this case, for Rickon’s age, which is listed as “three” instead of 3, we’d get a kickback. Since we designated that field to only accept integers (aka numbers), words won’t be accepted, even if they were representing a number.

Kind of like Theon Greyjoy, who may have been born to house Greyjoy, and is only one by name, but isn’t truly one of them.

How Big Can a MySQL Database Be?

One of the beautiful things about MySQL is that it can handle large databases. How large? There are no internal limits to how big a file can be, and is only determined based on the amount of memory of the thing it’s being stored in.

In other words, you can keep going, as long as whatever is housing your MySQL file has the memory, and if you dared, be like Arya and see how far you can go before you hit a wall.

https://youtu.be/B1Bg_2ae8Vk

For more information on MySQL Tables, click on the links below:

Happy programming!