An Introduction to SQL Fundamentals
What is SQL?
Databases are usually controlled using a Database Management System (DBMS). It acts as an interface between the end user and the database.
Some examples of DBMSs include MySQL, MongoDB, Oracle Database and Maria DB.
The Benefits of SQL and Relational Databases:
Here are some of the benefits that come with learning and using SQL:
Speed: Relational databases can return massive batches of data almost instantaneously due to the low storage space and high processing speeds.
Easy to Learn: SQL is written in plain English, making it much easier to pick up. This allows users to focus on learning the functions and syntax.
Reliable: Relational databases can guarantee a level of accuracy when it comes to data by defining a strict structure for data insertion.
Flexible: SQL provides all kinds of capabilities when it comes to querying a database; this allows users to perform vast data analysis tasks very efficiently.
Relational Databases (SQL, MySQL):
A relational database stores information in tables, with rows and columns representing different data attributes and the various relationships between the data values.
You can use SQL (Structured Query Language) commands to store, update, delete, search, and retrieve information from the database.
SQL also helps to maintain and optimize database performance.
Non-Relational Databases (NoSQL):
Unlike relational databases, NoSQL stores data in a non-tabular format. For example, if documents are being scanned, which can contain varying types and quantities of data, and are stored in a database that calls for a non-tabular format.
Common SQL Statements:
Create Database:
Use the following syntax to create a database:
Show Database
Run the following command to show the Database statement. This will return a list of present databases.
Use Database
To set the database we have just created as the active database, we would run the USE statement as follows (make sure to run this on your machine):
领英推è
DROP Database
Once a database is no longer needed (maybe it was created for test purposes, or is no longer required), it can be removed using the DROP statement.
Common NoSQL Statements:
Create Table
To create a table in NoSQL, you can use the following syntax:
SHOW Tables
Run the following command to see the tables you have created:
Describe Tables
Run the following command to know what columns are contained within a table.
ALTER Tables:
Once you have created a table and you need to make dataset changes then you alter the table using the following syntax:
DROP Tables:
You can also remove tables using the DROP statement. Use the following syntax: