0% found this document useful (0 votes)
42 views27 pages

Lecture 2.1 A

Uploaded by

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

Lecture 2.1 A

Uploaded by

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

INSTITUTE: CHANDIGARH UNIVERSITY

DEPARTMENT: USB
MCA
Business Analytics
23CAH-701

DISCOVER . LEARN . EMPOWER


Introduction to
DATABASE

2
A database is a structured collection of data organized and
stored in a way that allows for efficient retrieval, manipulation,
and management of information. It is designed to provide a
systematic approach to storing, managing, and retrieving data.
Databases are used to store and manage large amounts of data
for various applications, ranging from small personal projects to
enterprise-level systems. They are widely used in areas such as
business, finance, healthcare, education, e-commerce, and many
others.
The main purpose of a database is to provide a central repository
where data can be stored securely and accessed by multiple
users or applications concurrently. It offers a structured format
for organizing data, enabling efficient storage, retrieval, and
modification operations. Databases also support data integrity
and enforce rules and constraints to maintain the accuracy and
consistency of the stored data.
3
Database Components
1.Data: It represents the information stored in the
database, organized in tables or other data structures
based on the chosen database model.
2.Database Management System (DBMS): It is a software
system responsible for managing the database. The
DBMS provides tools and functions for creating,
modifying, and querying the database. It also handles
tasks such as data security, concurrency control, and
backup and recovery.
3.Database Schema: It defines the structure of the
database, including tables, fields, relationships, and
constraints. The schema acts as a blueprint for
organizing and representing data. 4
4. Queries: Queries are used to retrieve specific information from
the database. They allow users or applications to search, filter, and
sort data based on various criteria.

5. Database Administration: It involves tasks related to the


maintenance and management of the database system, such as
user management, performance optimization, security, and backup
and recovery.

There are different types of database models, each with its own
strengths and use cases. Some popular database models include
the relational model, where data is organized in tables with rows
and columns, and the NoSQL (Not Only SQL) model, which provides
flexible data structures suitable for handling unstructured or semi-
structured data.
5
INTRODUCTION TO DBMS

• A Database Management System (DBMS) is defined as the


software system that allows users to define, create, maintain
and control access to the database.
• DBMS makes it possible for end users to create, read, update
and delete data in database.
• A DBMS serves as an interface between an end-user.
• DBMS Examples:- MySQL, Microsoft Access, SQL Server, FileMaker,
Oracle, RDBMS.
WHERE IS DATABASE MANAGEMENT SYSTEM (DBMS) BEING USED?

• Airlines: reservations, schedules, etc


• Telecom: calls made, customer details, network
usage, etc
• Universities: registration, results, grades, etc
• Sales: products, purchases, customers, etc
• Banking: all transactions etc
ADVANTAGES OF DBMS
• Better Data Transferring
• Better Data Security
• Better data integration
• Better decision making
• Increased end-user productivity
• Simple
RELATIONAL DATABASE(RDMS)
AN INTRODUCTION TO RELATIONAL DATABASE

• A relational database organizes data into tables which can be linked—


or related—based on data common to each.
• This capability enables you to retrieve an entirely new table from
data in one or more tables with a single query.
• Data is represented in the terms of rows/records and columns.
• In a relational database, each row in the table is a record with a
unique ID called the key.
WHAT IS A TABLE?
• The RDBMS database uses tables to store data. A table is a
collection of related data entries and contains rows and columns
to store data.
13
14
WHAT IS SQL?
• SQL is a programming language for Relational Databases. It is
designed over relational algebra and Tuple relational calculus. SQL
comes as a package with all major distributions of RDBMS.

• SQL comprises both data definition and data manipulation


languages. Using the data definition properties of SQL, one can
design and modify database schema, whereas data manipulation
properties allows SQL to store and retrieve data from Database.
ADVANTAGES OF SQL
1.No programming needed
2. High-Speed Query Processing
3. Standardized Language
4. Portability
5. Interactive language
6. More than one Data View
SQL Select Statement:
The SQL SELECT statement is used to retrieve data from
a database. It is one of the most fundamental and
commonly used SQL statements. The SELECT statement
allows you to specify the columns you want to retrieve
and the tables from which you want to retrieve the data.

Here is the basic syntax of the SELECT statement:


SELECT column1, column2, ...
FROM table_name;
18
Where:

• SELECT: This keyword is used to indicate that you want to


retrieve data from the database.
• column1, column2, ...: These are the names of the
columns you want to retrieve from the table. You can
specify multiple column names separated by commas, or
you can use the wildcard character (*) to select all
columns.
• FROM: This keyword is used to specify the table or tables
from which you want to retrieve data.
• table_name: This is the name of the table from which
you want to retrieve data.
19
Example of the SELECT statement:

SELECT first_name, last_name


FROM employees
WHERE department = 'IT'
ORDER BY last_name;

This statement retrieves the first name and last name of


employees from the "employees" table, where the
department is 'IT'. The result will be sorted in ascending
order based on the last name.

20
SQL Distinct keyword
• SQL DISTINCT clause is used to remove the duplicates columns from
the result set.
• SELECT DISTINCT returns only distinct (different) values.
• DISTINCT eliminates duplicate records from the table.
• DISTINCT can be used with aggregates: COUNT, AVG, MAX, etc.
• Syntax:
SELECT DISTINCT expressions FROM tables [WHERE conditions];

21
SELECT DISTINCT SALARY FROM EMPLOYEES ORDER BY SALARY;

22
SQL IN Operator
• The SQL IN is a logical operator that allows us to specify multiple
values or sub query in the WHERE clause.
• It returns all rows in which the specified column matches one of the
values in the list. The list of values or sub query must be specified in
the parenthesis e.g. IN (select query) or IN (Value1, Value2, Value3,
…).
• Syntax:
SELECT Column_Name_1, Column_Name_2, ......, Column_Name_N F
ROM Table_Name WHERE Column_Name IN (Value_1, Value_2, .......,
Value_N);

23
EmpId FirstName LastName Email Salary DeptId
1 'John' 'King' 'john.king@ab 33000 1
c.com'

2 'James' 'Bond' 1
3 'Neena' 'Kochhar' '[email protected] 17000 2
om'
4 'Lex' 'De Haan' '[email protected] 15000 1
'
5 'Amit' 'Patel' 18000 3
6 'Abdul' 'Kalam' '[email protected] 25000 4
om'

SELECT EmpId, FirstName, LastName, Salary FROM Employee WHERE EmpId IN (1, 3, 5, 6)

EmpId FirstName LastName Salary


1 'John' 'King' 33000
3 'Neena' 'Kochhar' 17000
5 'Amit' 'Patel' 18000
6 'Abdul' 'Kalam' 25000

24
SQL Wildcard Characters
• A wildcard character is used to substitute one or more characters in a
string.
• Wildcard characters are used with the LIKE operator. The LIKE
operator is used in a WHERE clause to search for a specified pattern in
a column.
Symbol Description
% Represents zero or more
characters
_ Represents a single character

25
The % wildcard represents any number of characters, even zero
characters.
• Return all customers that starts with the letter 'a’:
Example:- SELECT * FROM Customers WHERE CustomerName LIKE 'a%’;
• Return all customers that ends with the pattern 'es’:
Example:- SELECT * FROM Customers WHERE CustomerName LIKE '%es’;
The _ wildcard represents a single character.
• Return all customers with a City starting with any character, followed
by "ondon":
Example:- SELECT * FROM Customers WHERE City LIKE '_ondon';

26
THANK YOU

For queries
Email:
[email protected]

You might also like