0% found this document useful (0 votes)
6 views23 pages

chapter 4 Introduction to Database

This document provides an introduction to databases, explaining their structure, importance, and usage in various fields. It covers key concepts such as SQL, keys, relational databases, and query languages, highlighting the significance of SQL in database management. Additionally, it discusses basic SQL commands and the importance of query optimization and search specifications for efficient data retrieval.
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)
6 views23 pages

chapter 4 Introduction to Database

This document provides an introduction to databases, explaining their structure, importance, and usage in various fields. It covers key concepts such as SQL, keys, relational databases, and query languages, highlighting the significance of SQL in database management. Additionally, it discusses basic SQL commands and the importance of query optimization and search specifications for efficient data retrieval.
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/ 23

Introduction to Database

Chapter 4
What is Database?

What is a Database?
 A database is a structured collection of data that is organized and
stored in a way that allows for efficient retrieval, management, and
manipulation of that data.
 Databases are used to store, retrieve, and manage vast amounts of
information in various fields, including business, science, healthcare,
and more.
What is Database?

Example: Consider an online bookstore. In this context:

• The database would store information about books, including titles,


authors,numbers, prices, and quantities in stock.
• Customer data, such as names, addresses, and purchase histories,
would also be stored in the database.
• When a customer searches for a book, the database is queried to find
matching titles, and the results are displayed to the customer.
Importance of SQL

 SQL is vital for efficient database management because it allows


users to communicate with the database without needing to know the
underlying data structures and storage mechanisms. This makes it
easier to work with databases, even for users without a deep
understanding of database internals.

Example: A business analyst can use SQL to quickly retrieve sales


data for a specific time period without needing to understand how the
data is stored in the database. They can issue a SQL query like "SELECT
* FROM Sales WHERE Date BETWEEN '2023-01-01' AND '2023-12-31'" to
get the required information.
What are Keys ?
 Keys consist of the attributes that identify entity occurrences and define the
relationships between entities. There are 3 types of Keys:

• A candidate key is an attribute, or set of attributes, that can be used to uniquely identify an
occurrence of the entity.
• The primary key is chosen from the set of candidate keys and is used to identify an entity
occurrence.
 The primary key must guarantee the uniqueness of an entity occurrence.
1. The value of any component of the primary key cannot be null.

2. Primary keys of basic entities should not have embedded meaning.

3. Primary keys should not be changeable.


 Foreign keys reside in dependent entities to
establish relationships. The primary key
identifies an entity occurrence; foreign
keys identify relationships between entity
occurrences.
What is a Relational Database
(RDBMS)?
 A relational database is a type of database that stores and provides
access to data points that are related to one another.
 They are based on the relational model, straightforward way of
representing data in tables.
 In a relational database, each row in the table is a record with a
unique ID called the key.
 The columns of the table hold attributes of the data, and each record
usually has a value for each attribute, making it easy to establish the
relationships among data points.
A poor Relational Design can result in poor performance.
Introduction to Query
Languages
 Query languages are specialized programming languages designed
for retrieving, manipulating, and managing data in a database. They
serve as a bridge between the user and the database, allowing
seamless interaction and data retrieval.
Importance in Database
Administration:
 Efficient database administration relies heavily on the ability to
communicate with the underlying database system. Query languages
provide a standardized way for administrators and users to interact
with the database, performing tasks such as data retrieval, insertion,
updating, and deletion.
 Key Aspects:
 Data Retrieval: Extracting specific information from the database.
 Data Modification: Adding, updating, or deleting records as needed.
 Data Definition: Defining and altering the structure of the database.
Overview of SQL as a Widely
Used Query Language:
 SQL (Structured Query Language):
 SQL is the most prevalent query language for relational database
management systems (RDBMS).
 It offers a comprehensive set of commands for managing relational
databases, providing a standardized way to interact with various
database systems.
Overview of SQL as a Widely
Used Query Language:
 SQL Components:
 Data Query Language (DQL): Used for retrieving information from
the database. The primary command for this is SELECT.
 Data Definition Language (DDL): Involves defining and managing
the structure of the database.
 Data Manipulation Language (DML): Involves managing data
within the database (INSERT, UPDATE, DELETE).
 Data Control Language (DCL): Concerned with access control and
permissions (GRANT, REVOKE).
Overview of SQL as a Widely
Used Query Language:
 Versatility:
 SQL's versatility extends to its use in data analysis, reporting, and
integration with various programming languages.
SQL Basics
 Introduction to SQL Commands:
 SQL (Structured Query Language) provides a set of powerful
commands for interacting with databases. These commands can be
broadly categorized into four main types:
 SELECT:
 Used to retrieve data from one or more tables.
 Example: SELECT column1, column2 FROM table WHERE condition;
 INSERT:
 Adds new records to a table.
 Example: INSERT INTO table (column1, column2) VALUES (value1,
value2);
SQL Basics
 UPDATE:
 Modifies existing records in a table.
 Example: UPDATE table SET column1 = value1 WHERE condition;
 DELETE:
 Removes records from a table.
 Example: DELETE FROM table WHERE condition;
Explanation of SQL Syntax:
 SQL commands follow a specific syntax structure. The basic syntax
for the SELECT statement, for example, is as follows:

SQL
 SELECT column1, column2
FROM table
WHERE condition;
 Each SQL command has its own unique syntax, but they generally
include keywords like SELECT, FROM, WHERE, VALUES, SET, and
other.
Examples of Basic SQL Queries:
 SELECT Query:
SELECT first_name, last_name
FROM employees
WHERE department = 'IT';
INSERT Query:
INSERT INTO customers (customer_id, customer_name, city)
VALUES (1, 'ABC Company', 'New York');
UPDATE Query:
UPDATE products
SET price = price * 1.1
WHERE category = 'Electronics';
Examples of Basic SQL Queries:

 DELETE Query:
DELETE FROM orders
WHERE order_date < '2023-01-01';
Query Optimization

 Enhancing Performance
 Query optimization is a critical aspect of database administration
aimed at improving the speed and efficiency of queries. Optimized
queries contribute to better overall database performance, ensuring
that data retrieval and manipulation tasks are executed in the most
efficient manner.
Search Specifications

 Defining Search Specifications


 Search specifications involve the process of clearly outlining the
criteria and conditions for database searches. These specifications
are crucial for accurately retrieving relevant data and ensuring that
the search aligns with the intended goal
 Controlling Searches with Criteria and
Conditions
 Effective search specifications include well-defined criteria and
conditions that guide the search process. These criteria help narrow
down the search space and ensure that the results are both
meaningful and relevant.
Search Specifications

 Example Search Specification:


 Retrieve all products with a price less than $50 and belonging to the
'Electronics' category.
SELECT * FROM products
WHERE price < 50 AND category = 'Electronics';
Search Specifications

 Sorting and Filtering Options


 Search specifications also encompass sorting and filtering options,
allowing users to organize and refine search results based on specific
parameters.
 Sorting:
 Arrange results in a specified order, such as ascending or descending by a
particular column.
SELECT * FROM customers
ORDER BY last_name ASC;
 Filtering:
 Apply additional filters to the search results based on specific
conditions
SELECT * FROM orders
WHERE order_date >= '2023-01-01';
THE END!

You might also like