0% found this document useful (0 votes)
9 views3 pages

Introduction To SQL

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Introduction To SQL

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Introduction to SQL

What is SQL?

SQL, which stands for Structured Query Language, is like a magic language for working with
data. It's a special language used for managing and manipulating data in databases. Just like
you use Python for interacting with computers, you use SQL for interacting with databases.

Understanding SQL:

● Imagine you have a huge bookshelf with thousands of books. Now, how would you find a
book on, say, Indian history? You need a system or a set of instructions to find it quickly.
SQL is that set of instructions, but for finding and managing data in a database.

● SQL helps you ask the database specific questions like, "Show me all the transactions
from last month" or "Update the address for this customer."

● Imagine you have a box full of different toys and you want to find all the red cars. SQL
helps you tell the box (database) to show you only the red cars.

Common Database Management Systems Using SQL

Introduction to DBMS:

A Database Management System (DBMS) is like a digital librarian that manages and organizes
all the data in a database. It helps in storing, retrieving, and managing data efficiently.

Popular DBMS That Use SQL:

● MySQL: It's like the popular kid in school – widely used, reliable, and fits well in many
scenarios, from small projects to big websites.
● PostgreSQL: This one is like the all-rounder student – it's powerful and supports a lot of
advanced features.
● SQLite: Think of it as a pocket-sized diary. It's lightweight and used in mobile
applications or small desktop applications.

Different Types of Queries:

SQL queries are instructions you give to the database, just like how you ask different questions
in class.
● DDL (Data Definition Language):

○ This is about defining or changing the structure of the data, like creating a new
table or adding a column to an existing table.
○ It’s like setting up or changing your toy shelf. Like adding a new shelf or changing
the label of a shelf.

● DML (Data Manipulation Language):

○ This involves working with the actual data. Like adding new data (INSERT),
updating existing data (UPDATE), or removing data (DELETE).
○ It’s like adding new toys, fixing broken ones, or throwing away old toys. It’s for
adding, changing, or removing data.

● DCL (Data Control Language):

○ These commands control access to the data. It’s like setting rules on who can
view or use your personal diary.
○ It’s like setting rules for who can play with your toys. It’s for managing who can
see or use the data.

● TCL (Transaction Control Language):

○ These commands deal with transactions within databases, like confirming a


group of operations (COMMIT) or undoing them (ROLLBACK).
○ It's like keeping a diary of what you did with your toys and being able to undo
something if you made a mistake.

What is SQL Server?

Think of SQL Server as a big, secure filing cabinet where businesses keep their important data.
It's a product by Microsoft that uses SQL to manage all this data effectively.

How SQL Works?

● Parser: It checks the SQL instructions, like scanning a shopping list to make sure it
makes sense.
● Relational Engine: It plans the best way to get your data, like planning the quickest route
to buy your groceries.
● Storage Engine: This does the actual work of fetching and storing data, like going to the
store and picking up items from your list.
SQL in Data Science

SQL (Structured Query Language) is like a librarian who's really good at organizing and finding
books in a library. In the world of data, SQL excels in dealing with data that's stored in
databases.

Example 1: Online Shopping Insights

● Situation: Imagine a big online store like Amazon or Flipkart.


● Use of SQL: Data scientists use SQL to understand what customers like to buy. They
might ask SQL to show data like, "Which mobile phones were the most popular last
month?" or "How many people bought books and also bought bookmarks?"
● Outcome: This helps the store decide which products to promote or stock up on.

Strengths of SQL:

● Efficient Data Retrieval: It's great for quickly finding and pulling out specific pieces of
data from large databases. Imagine asking a librarian for books on a specific topic, and
they bring them to you in no time.
● Handling Complex Queries: SQL is excellent for complex searches, like finding all
students in a school who play both football and chess.
● Data Manipulation: It can easily insert, update, and delete records in databases. Think of
it like updating a school register with new student details.
● Structured Data: SQL works best with structured data, where everything is organized in
neat rows and columns, like a well-arranged bookshelf.

Why Choose SQL Over Python for Specific Tasks?

● Optimized for Databases: SQL is specifically designed to interact with databases


efficiently. It's like having a tool made just for organizing and finding books.
● Speed with Large Databases: SQL can handle large amounts of data really fast,
especially when it comes to retrieving and organizing it.
● Simplicity: For tasks related to database management, SQL tends to be simpler and
more straightforward than Python.

SQL handles all the heavy-lifting of data management in databases, while Python steps in for
more complex analysis, data processing, and applying machine learning models.

You might also like