Categories
Blog

MySQL databases for beginners

A database is a collection of organized data in a way that facilitates easy access as well as good and fast administration and updating. 

It is also made up of tables that store relevant information. For example, you would need a database, if you were to create a web page like Youtube. Which contains a lot of information such as videos, users, keys, and comments. 

USERS VIDEOS   COMMENTS
Table 1Table 2Table 3

In these examples, the information would be videos, comments, and users. And its storage location, which could be seen in the form of even a simple button to click on, would be the database. 

These tables store and display data in a structured format consisting of columns and rows. Which are similar to those seen in Excel spreadsheets. In this way, databases usually contain multiple tables, each designated for a specific purpose. For example, a database table consisting of names and phone numbers

The following table details a simple example of what a database refers to.   

ID   First Name  Last Name  Telephone Number  
1  David  Williams  556-485-965  
2  Lucas  Adams  245-156-784  
3  Camile  Smith  256-874-965  
4  John  Roberts  654-854-951  

Another characteristic of databases is that they require Primary Keys. It is a field in the table that uniquely identifies the records in the table. 

These primary keys must always contain:  

  1. A unique value for each row. 
  2. It cannot contain NULL values. 

In the table above, a clear example of a primary key would be the row of the unique ID value. Since there is always the opportunity for more than one person with the same name. 

Once you understand what a database is, understanding MySQL is easy.  

MySQL is developed under a dual license: Commercial License / General Public License by Oracle Corporation, and is also the world’s most popular open-source database for web development. 

Many well-known websites work under the MySQL system, such as YouTube, Facebook, and Twitter. 

In general, MySQL is an open-source database management system (RDBMS), which works with a client-server model. 

Open-Source  

This means that the user is free to modify them as he wishes. In addition to customizing the source code. However, the GPL (GNU Public License) limits what the user can do under the conditions it sets. 

Client – server model   

Anyone who runs the RDBMS software is considered a client. Every time the client needs to access the database, it connects to the RDBMS server. There, the clientserver relationship is created. 

Keep in mind that although SQL and MySQL have certain similarities, they are not the same. 

MySQL reads the information from the SQL. So how do the client and server communicate? 

These use the language of the domain: SQL. (Structured Query Language) 

MySQL is written in C and C ++, and the processes it performs are essentially the same as SQL, such as: 

  • Create a database to store and manipulate information. 
  • Clients can make requests by writing SQL statements in MySQL. 
  • The server application will respond with the requested information in front of the client. 

How to create a database with MySQL?  

Working with MySQL is quite simple, and it is not extremely necessary to have the very advanced technical knowledge to do it. Here’s how to create a MySQL database step by step: 

  1. The first thing to keep in mind is that the MySQL server installed on the computer must be connected. Otherwise, it will be impossible to create a database. 
  2. Next, you will have to copy the installation path of the folder. This could vary on different operating systems. In Windows it would be: “C: / Program Files / MySQL / MySQL Workbench 8.0 CE /”. If the operating system is IOS, it is copied in this way: “/usr/local/mysql-8.0.13-osx10.13-x86_64/”. 
  3. Then, the computer command line opens. In Windows, it would be “cmd or command prompt”, in Mac “Terminal”. 
  4. Finally, the database file is created. Write the command ‘’ create database ’’, add the name and end with ‘’; ’’. For example, if you want to name the database “Customer Registry” it would be “CREATE DATABASE Customer_Registration;” and press “Enter”. 

Select the database.  

The next thing necessary to create a base will be to select it, it is a very simple but necessary act. If you want MySQL to know which database the client refers to when entering the commands, it must indicate them with the command: 

• USE Table. 

Following up on the previous example, the command would be: 

USE Customer_Registration; 

Create a database table  

Since the database is created and selected, the table can be created. To create the table structure, the command will be: 

CREATE TABLE name (column1 VARCHAR (30), column2);  

Let’s try to visualize this as a mathematical formula where we have to add our values. 

Looking at it this way, if you want to add the columns of the client’s name and age to the table called “Register for Clients” the following should be written. 

CREATE TABLE Registration for clients (Client Name VARCHAR (30), Age INT);  

The next thing is to add a line to the table. To add information line by line, use the command “insert”. 

Check the data table.  

This is a step that is not necessary but we recommend it. When doing this, the user will have no doubts, if they were not sure that the table had been created. 

To check the table, the DESCRIBE command is used together with the name of the table to check. 

DESCRIBE Register_for_clients; 

Adding records.  

After verifying that the table was created successfully, we end up adding content to our database. 

We will add three customer names and three ages to our table. To do this, use the INSERT INTO command followed by the name of the table. Then comes VALUES followed by the values to include. 

An example would be: 

INSERT INTO Register_for_customers VALUES (‘John Smith’, 22);  

INSERT INTO Registry_for_customers VALUES (‘William Harries’, 22);  

INSERT INTO Registry_for_customers VALUES (‘Calvin Stone’, 22);  

In this way, the table will show the three names with their respective ages. 

Checking data.  

Now it only remains to check that the database or rather, the table 

Register_for_clients has all its data well. 

To do this, enter the SELECT FROM command and it will show all the records in the table. 

The command would be placed as follows: 

SELECT * FROM Register_for_customers;  

Note that “*” is placed in the middle, this is to indicate that the selection is being used for a database. 

Everything has gone well, the database should have been created correctly. 

Why is MySQL the most used of all?  

According to Datanyze MySQL has a 48% trading share. Therefore it doesn’t have a direct competitor since Microsoft SQL Server has second place with a share of just 10%.  

MySQL is mainly applied in web sites and many popular CMS. WordPress, Joomla, Drupal, and many others are compatible with this database manager.  

A big plus to this is the fact of being multi-platform. Added to this is the fact that it is used wonderfully in environments that can include Apache or Nginx with PHP or PHP-FPM.  

For this reason, MySQL is the most used since it adapts to any environment, it’s very safe, fast, and reliable. This is more than evident since giants like Google and Facebook use it with complete confidence.