week 9 sql (2)
week 9 sql (2)
Introduction to Database
Week 9
Database
Management
System
▸ It enables a user to create, read, update and delete relational databases and
tables.
13
What Can SQL do?
▸ SQL can execute queries against a database.
▸ SQL can retrieve data from a database.
▸ SQL can insert records in a database.
▸ SQL can update records in a database.
▸ SQL can delete records from a database.
▸ SQL can create new databases.
▸ SQL can create new tables in a database.
▸ SQL can create views in a database.
▸ SQL can set permissions on tables etc.
14
SQL Commands
▸ SELECT - extracts data from a database
15
SQL Commands
▸ ALTER DATABASE - modifies a database
▸ etc.
16
SQL Queries
▸ Suppose we have data of people who shopped from an online store stored in a
Table called Customers.
17
SQL Queries- Select
▸ Write a query to show all entries of the table
SELECT * FROM Customers;
Output:
CustomerName City
Ali Lahore
Ahmed Karachi
Bisma Multan
Faraz Islamabad
19
SQL Queries - Select
▸ Write a query to display all customers from Multan city
20
SQL Queries - Insert
21
SQL Queries - Insert
22
SQL Queries - Delete
DELETE FROM table_name WHERE condition;
Example:
▸ DELETE FROM Customers WHERE CustomerName= ‘Ahsan';
▸ DELETE FROM Customers; (deletes all rows)
▸ DROP TABLE Customers; (delete the table completely)
23
SQL Queries - Update
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Example:
▸ UPDATE Customers
SET CustomerName = Ahmed Ali', City= ’Islamabad'
WHERE CustomerID = 2;
24
NoSQL Databases
▸ NoSQL, or "not only SQL" or "non-SQL", is a database
design approach that stores and retrieves data in a non-
tabular format.
▸ They are often used for large data volumes, real-time web
applications, and big data.
▸ Example: MongoDB
28
NoSQL Features
▸ No tables: NoSQL databases don't use tables like traditional
databases do. Instead, they use other structures like documents, key-
value pairs, or graphs.
▸ Flexibility: NoSQL databases can handle different types of data, like
text, images, or videos, and can store them in a flexible way.
▸ Scalability: NoSQL databases are designed to handle large amounts
of data and scale easily, making them perfect for big data and real-
time applications.
29
NoSQL Real World Example
▸ Social media: NoSQL databases are used to store user
data, posts, and comments etc.
30
Big Data
▸ Big Data refers to a huge amount of information that is too large and
complex to be processed by traditional data processing tools.
▸ Big Data is generated from a diverse range of sources like social
media platforms (Facebook etc.), Online transactions (including e-
commerce and digital marketplaces etc.
▸ This data is then stored, processed, and analyzed to gain insights,
make predictions, and inform decisions, driving business, innovation,
and progress.
▸ The five characteristics of big data are often described as the 5 V’s.
31