Introduction to SQL
● What is SQL?
● SQL stands for Structured Query Language. It is used for accessing and
manipulating the data.
● SQL uses CRUD operations to communicate with the databases. CRUD
stands for Create, Read, Update and Delete procedures.
● Here is a breakdown of CRUD operations -
▪ CREATE procedures: Performs the INSERT statement to create a
new record.
▪ READ procedures: Reads the records of the table
▪ UPDATE procedures: Executes an UPDATE statement on the table
based on the specified primary key for a record within the WHERE
clause of the statement.
▪ DELETE procedures: Deletes a specified row in the WHERE clause.
● What is RDBMS?
RDBMS stands for Relational Database Management System. It is the basis
for SQL, and for all modern database systems Ex- MS SQL, MySQL, etc.
Tables are the database objects that are used in RDBMS. Table is a collection
of related data entries and it consists of numerous columns and rows.
Table is the simplest form of data storage in a Relational Database. Below is an
example of table named Ninjas which contains attributes ID, Ninja’s Name and
City-
Page 1 of 4
ID Ninja’s City
Name
101 Lokesh Ninja Kolkata
102 Kuldeep Ninja Bhopal
103 Ojasv Ninja Shimla
In this course we will be using an open-source RDBMS i.e MySQL. This
database uses Structured Query Language for all CRUD operations and other
procedures.
MySQL uses the Client-Server model. In this model a "client" is a front-end
application that uses the services provided by a MySQL server. And this whole
use of the services takes place through SQL Queries.
Difference between MySQL and SQL :
SQL MySQL
SQL is a Structured Query Language. MySQL is an RDBMS to store,
It is useful to manage relational retrieve, modify and administrate a
databases. database using SQL.
SQL is a query language. MYSQL is used as an RDBMS
database.
To query and operate database Allows data handling, storing,
systems. modifying, deleting in a tabular
format.
Page 2 of 4
● COMMENTS IN MySQL –
There are 3 ways to add comments in MySQL.
● From # character, till the end of the line.
Syntax -
# this is a single-line comment.
● From - - (double-dash without space) till the end of line.
Syntax -
—This is a comment.
● Can add up multiple lines of comments using this starting and ending
syntax.
Syntax -
/* This is multiple line of comment. */
● Example: Banking System -
Understanding basic MySQL database using Banking System with help of ER
Model.
Note:- ER Model :
1. Entity - Real world object (Can be understand as a tables)
2. Attributes - These are the properties of the entity.
In our Banking system we will be considering below mentioned entities:
1. Customer
2. Account
3. Branches
4. Loan
5. Loan type(Loan_type)
6. Transactions
7. Cards
Page 3 of 4
Customer entity and with attributes(column):-
customer_id branch_id first_name last_name Gender D.O.B
In this above customer entity we have used branch_id as the attribute that
we can use to set up a relationship with Branch entity. Similarly, in the
given ER Model below we can understand the different relationships that
exist between different entities.
Page 4 of 4