Url resource
Relational databases using SQL are king. In my recent poll, nearly two-thirds of viewers said that SQL was their go-to database, that’s despite the fact that it’s 40 year old tech with billions of dollars invested in disruptive technologies that try to knock sql off the throne.
Today you’ll learn everything you need to know about mysql and open source database(开源数据库) that powers content management systems lik wordpress, ecommerce plantforms like shopify, and social media giant twitter.
We’ll take a hands-on approach by recreating airbnb’s database, which happens to use mysql in real life. In the process, you’ll learn why mysql is so popular, how to install and interact with database using modern tooling vscode.
The essential syntax to create, read, update and delete data, and most importantly, how to model and join relational data (关系型数据)
There’s also another give-away with this video, the mysql pillow, all you have to do is to be a subscriber and leave a comment below; to start things off, let’s travel back in time 50 years to meet Ted Codd, the author of the legendary paper, a relational model of data for large shared data banks (大型数据库中中的数据关系型模型). , to be completed in future if possible
, to be completed in future if possible
We now have access to mysql in command line. And the first thing we’ll want to do is create a database, we can do that by executing an sql statement, that says create database followed by the database name, which in this case will be airbnb,
We can then verify that it was actually created by typing show databases,
[root@iZ2vc5lqzt23aweti4j777Z ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> CREATE DATABASE airbnb;
Query OK, 1 row affected (0.00 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| RECOVER_YOUR_DATA |
| airbnb |
| mysql |
| performance_schema |
| sys |
+--------------------+
6 rows in set (0.00 sec)
***********************************TDL multiple sql lines commands
The first thing I want to point out is that you can create a comment in sql using double dash
Show databases; --annotation
+--------------------+
| Database |
+--------------------+
| information_schema |
| RECOVER_YOUR_DATA |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
Firstly we need to add the first table to it, which can be accomplished with a ‘create table’ statement (通过create table 语句声明实现), now a couple of things to note here;
A statement is code that does something, and we know this is statement (我们知道这是语句), because it ends with semicolon (结尾有问号); The words highlighted in purple are SQL key words, they’re reserved words (是保留字) that language