Chapter 1 SQL 2024
Chapter 1 SQL 2024
Introduction
Why Study
Database as a Topic?
A company's database is its biggest
asset
• Purpose:
• Easy access to data
• Modification of stored information Database
• Protection of sensitive data
• Analysis of large datasets
• Features:
• Login through a URL
• Enter staff details
• Record timesheet details Data
• Track student attendance
• Store student marks Data
• Database role:
• Installed on your personal computer
• Connects to the timesheet application
• Stores all entered data
• Retrieves data when requested
• Allows modification of stored information
•Examples of DBMS:
•MySQL
•PostgreSQL
•MongoDB
•Neo4j
Database vs. DBMS
•Cassandra
• Database:
• Container that stores data app
• The actual collection of information
A collection of software programs that control the storage, organization, and retrieval
of data in a database
Gives us the ability to access and manipulate data without knowledge of the structure
of the database
Evolution of Databases
• 1960s: Flat file databases
• Data stored in simple files (CSV, fixed-length files)
• Relational databases
• Replaced earlier models due to better handling of complex
relationships
• Non-relational databases
• Emerged to handle new types of data and scale
requirements
Types of Databases Today
• Two main types:
• Relational Databases (74% usage)
• Non-Relational Databases
• Relational databases still dominate, but non-relational databases are
rising
• Reasons for non-relational database popularity:
• Immense rise in data usage over the past decade
• Growth of social media platforms
• Large companies often use a combination of both types
• Helps manage data related to millions of users daily
• Most popular examples:
• Relational: Oracle
• Non-relational: MongoDB
Relational Database
• Data stored in tables with columns and rows
• Tables are related to one another
• Structure:
• Columns have names and data types
• Rows are treated as records
• Data type acts as a rule for what can be inserted in a column
• Uses SQL (Structured Query Language) for querying
• SQL follows a standard format across different relational databases
• Examples:
• Oracle
• MySQL
• Microsoft SQL Server
• PostgreSQL: Widely used in financial institutions (banks, insurance
companies)
Relational Database
• Example: Office database
• Tables are related through common columns:
• Employee and Manager tables linked by Manager
ID
• Manager and Department tables linked by
Department ID
• Foreign key constraints form relationships between
tables
• Allows fetching data across tables based on
relationships
• Even indirectly related tables (e.g., Employee and
Department) can be queried together
What is a Relational Database?
Requirements
Analysis Results in a set of requirements that the
database must support
Step 3:
Database
Design Three common phases in database
modeling:
Entity
Relational Data
Relationship Normalization
Model
Diagram (ERD)
Entity
Relationship
Diagram (ERD)
Graphical representation of
the proposed database
Stays the same regardless of
what type of DBMS the system
is eventually built with
Answers the questions:
What entities (person, place, or thing) are being
represented?
Entity What attributes (data) are stored about each
Relationship entity?
What are the relationships between the entities?
Diagram Basically, what data do we want to capture and what
(ERD) are the business rules surrounding that data
Example
ERD
A technique used during database design to identify
redundancy within the database
Testing
Step 6: Allocate storage requirements
Database Place the database into production
Deployment
Database Maintenance
Step 7: Maintain the database on an on-going basis
according to user requirements
Database
Maintenance
SQL pronounced "S-Q-L" stands for Structured Query
Introduction Language