2. IN S T R U C TO R
2
Email: Tanvir.fatima@au.edu.pk
GCR:
3. Database Systems
What we are going to learn in this subject?
The basic concepts of databases, why we need them,
how it can be subdivided, why it is important, what we
can achieve by this course?
8. Why do we need databases?
• Why can’t we just use the file system?
• Store data in files
9. Using the File System
• Sometimes using the file system for your
applications is just fine
• Word processing
• Pictures
• Games
• As the complexity of the application and the amount
of information it works with increase, some
disadvantages of exclusively relying on the file
system start to surface..
• Example –consider a banking system
10. FILE PROCESSING SYSTEMS
10
Collection of application programs that performs
services for the end-users (e.g. Reports)
Each program defines and maintains its own
data
12. LIMITATIONS OF FILE-BASED APPROACH
⚫ Separation and isolation of data
⚫ Each program maintains its own set of data. Users
• of one program may be unaware of potentially useful data held by other
programs.
⚫ Duplication of data
⚫ Same data is held by different programs. Wasted
• space and potentially different values and/or different formats for the same
item.
⚫ Atomicity of updates
⚫ Failure may lead database to an inconsistent state
• with partial updates carried out
⚫ E.g. Transfer of funds from one account to another should either be complete or
incomplete, no in- between state
20
13. LIMITATIONS OF FILE-BASED APPROACH
Data dependence
⚫ File structure is defined in the program code.
Incompatible file formats
⚫ Programs are written in different languages, and
so cannot easily access each others files.
Integrity Problems
⚫ Hard to add new constraint or update existing one
21
14. LIMITATIONS OF FILE-BASED APPROACH
Fixed Queries/Proliferation of application
programs
⚫ Programs are written to satisfy particular
functions. Any new requirement needs a new
program.
Data Redundancy and Inconsistency
⚫ Multiple file formats, and duplication of
information in different files
Difficulty in Accessing Data
⚫ Need to write a new program for accessing new
data 22
16. File System Disadvantages
• Data redundancy - wasted space
• Update issues – every copy of
the data needs to be modified
• Data inconsistency –sometimes
every copy is not modified
• Data access issues (getting to just
the right data)
• “There’s no program for that.”
• Data isolation - pulling all the
data from disparate sources
together)
• Integrity constraints buried in
application logic – hard to add to
or change
• Atomicity problems – what
happens when the system
crashes during an important
operation?
• Concurrency issues –when
multiple users work with the
same data at the same time
• Security issues – how to give
someone access to some, but not
all, of the data
17. Why do we need databases?
1. Data storage and retrieval:.
2. Data consistency and integrity:
3. Performance optimization:
4. Data scalability and concurrency
18. Difference b/w database system and file system
File System Database Management System
File system is a software that manages and organizes
the files in a storage medium within a computer.
DBMS is a software for managing the database.
Redundant data can be present in a file system. In DBMS there is no redundant data.
It doesn’t provide backup and recovery of data if it is
lost.
It provides backup and recovery of data even if it is
lost.
There is no efficient query processing in file system. Efficient query processing is there in DBMS.
There is less data consistency in file system.
There is more data consistency because of the
process of normalization.
It is less complex as compared to DBMS.
It has more complexity in handling as compared to
file system.
File systems provide less security in comparison to
DBMS.
DBMS has more security mechanisms as compared
to file system.
It is less expensive than DBMS. It has a comparatively higher cost than a file system.
20. What is “database” & “database systems”
“A DATABASE is an organized collection of structured information, or
data, typically stored electronically in a computer system.”
“A database is usually controlled by a DATABASE MANAGEMENT
SYSTEM (DBMS). Together, the data and the DBMS, along with the
applications that are associated with them, are referred to as a database
system, often shortened to just database.”
21. What is “database” & “database systems”
• Database involves many thing but some of them following:
• Store structure of Data
• Types of data
• Modeling of Data
• Management of Data
• etc
23. Difference b/w database and data structure
Database Data Structure
It is an organized collection of data.
It is a special format for storing data to serve a
particular purpose.
It is used to access the data and manage it easily.
It is used for efficiency and to reduce the complexities
of the program.
Structured query language (SQL) is used to
perform operations on the data in a database.
Database Management System (DBMS) is used to
manage the database.
Programming languages like C, C++, Java, Python
are used to perform operations using data Structures.
It is a Non-volatile memory. It is a volatile memory.
Types: Relational database, NOSQL database,
Centralized database, Hierarchical database are
some types of databases.
Types: Linear data structure and non-linear data
structure are the types of data structures.
Example: MySQL, SQL Server, Oracle, MongoDB,
SQLite and etc.
Example: Array, Linked List, Stack, Queue, Tree,
Graph.
25. Data Vs Information & its types
• Data: A collection of raw facts and figures is known as data.
• Types of Data
• Numeric Data
• Alphabetic Data
• Alphanumeric Data
• Image Data
• Audio Data
• Video Data
Information: The processed data is known as information. A useful or meaningful
data is also known as information.
26. DATA VS. INFORMATION
26
Data: Raw facts/Un-processed information
⚫ But they are building blocks for information
Information: Data Processed to reveal its
meaning
⚫ Information is meaningful
⚫ In today’s world, accurate, relevant and timely
information is the key to good decision making
⚫ Good decision making is key to survival in today’s
competitive and global environment
28. Concepts of Tables in Database
Table is the fundamental object of the database structure. The basic purpose of a table is to
store data. A table consists of rows and columns.
Row/Record/tuple: Rows are the horizontal part of the table. A single row is known as record or
tuple. Table in this slide has 3 records.
Column/field/attribute: Columns are the vertical part of the table. A single column is known as field
or attribute. Above table has 4 fields or attributes.
Relation: In relation model, data is stored in the form of relations. Relation is another name used for
table.
29. Concepts of Users in Database
End users (EU)
Use the database system to
achieve some goal
Application developers (AD)
Write software to allow end
users to interface with the
database system
Database Administrator (DBA)
Designs & manages the
database system/Provide
technical support
Database systems programmer
Writes the database software
itself
30. Database Management System
DBMS is a system software for creating and managing databases.
A software that interacts with end users, applications, and the database
itself to store and analyze the data
DBMS provides:
efficient, reliable, convenient and safe (don’t loss or override or corrupt)
multi-user (concurrency control) storage of and access to massive
amount of persistent data.
31. Database Management System
• A set of programs which manages and control database is known as Database Management
System.
• List of functions of DBMS?
32. Database Management System
• A set of programs which manages and control database is known as Database Management
System.
• List of functions of DBMS:
• Create database
• Create tables
• Create structures
• Read database data
• Update database data
• Maintain database structures
• Enforce rules
• Perform Security
• Perform Backup and Recovery
33. Database Management System in a gaming Point
of view
• A database management system (DBMS) can have several functions in a gaming point of view. Here are some
common functions of a DBMS in the context of gaming.
34. Database Management System in a gaming Point
of view
A database management system (DBMS) can have several functions in a gaming point of view. Here are some
common functions of a DBMS in the context of gaming.
• Player and Account Management
• Game Progress and Save Data
• Leaderboards and Rankings
• In-Game Economy and Virtual Goods
• Matchmaking and Multiplayer
• Game Analytics and Telemetry
• Content Management
• Anti-Cheating and Security
35. Examples of Database Management System
• Train timetables
• Airline bookings
• Credit card details
• Student records
• Customer histories
• Stock market prices
• Discussion boards
• and so on…
• Web indexes
• Library catalogues
• Medical records
• Bank accounts
• Stock control
• Personnel systems
• Product catalogues
• Telephone directories
36. What Database Management System Do
• Provides users with
• Data definition language (DDL)
• Data manipulation language (DML)
• Data control language (DCL)
• Transaction Control Language (TCL)
• Often these are all the same language
38. Data Definition Language
• These SQL commands are mainly categorized into four categories as discussed below:
• DDL(Data Definition Language) : DDL or Data Definition Language actually consists of the SQL
commands that can be used to define the database schema. It simply deals with descriptions of
the database schema and is used to create and modify the structure of database objects in
database. Examples of DDL commands:
• CREATE – is used to create the database or its objects
• DROP – is used to delete objects from the database.
• ALTER-is used to alter the structure of the database.
• TRUNCATE–is used to remove all records from a table, including all spaces allocated for the records are removed.
• COMMENT –is used to add comments to the data dictionary.
• RENAME –is used to rename an object existing in the database.
39. Data Manipulation Language
• DML(Data Manipulation Language) : The SQL commands that deals with the manipulation of data
present in database belong to DML or Data Manipulation Language and this includes most of the
SQL statements. Examples of DML:
• SELECT – is used to retrieve data from the a database.
• INSERT – is used to insert data into a table.
• UPDATE – is used to update existing data within a table.
• DELETE – is used to delete records from a database table.
40. DCL and TCL
• DCL(Data Control Language) : DCL includes commands such as GRANT and
REVOKE which mainly deals with the rights, permissions and other controls of the
database system. Examples of DCL commands:
• GRANT-gives user’s access privileges to database.
• REVOKE-withdraw user’s access privileges given by using the GRANT command.
• TCL(Transaction Control Language) : TCL commands deals with the transaction
within the database. Examples of TCL commands:
• COMMIT– commits a Transaction.
• ROLLBACK– rollbacks a transaction in case of any error occurs.
41. What DBMS Does
• DBMS provides
• Persistence
• Concurrency (Multi tasking)
• Integrity
• Security
• Data independence
• Data Dictionary
• Describes the database itself
42. Data Dictionary - Metadata
• The dictionary or catalogue stores information about the database itself
• This is data about data or ‘metadata’
• Almost every aspect of the DBMS uses the dictionary
• The dictionary holds
• Descriptions of database objects (tables, users, rules, views, indexes,…)
• Information about who is using which data (locks)
• Schemas and mappings
47. Requirement Collection and Analysis
Client
1
Requirement Collection and
Analysis
Databasedesignersinterviewclients to
understandanddocument their
requirements
50. Logical Database Schema
Client
RequirementCollection and
Analysis
Conceptual
DatabaseDesign
Logical
DatabaseDesign
1
3
4
Describeswhatdata will bestored (e.g.whattablesareused, what
data typesareused, whatconstraints are applied)
Constraint
Enforces limit to the data that can be
inserted/updated/deleted from a table (e.g. attribute X
cannot have duplicate values; attribute Y cannot have
null values)
Logical Schema= {entities, attributes, constraints, data
types, relationships}
52. Physical Database Schema
Client
RequirementCollection and
Analysis
Conceptual
DatabaseDesign
Logical
DatabaseDesign
Physical
DatabaseDesign
Functional
Requirements
1
3
4
5
2
SQL code used to build database describes how data
will be stored (i.e. define index structures and storage
layout)
54. Database design for gaming
1. Requirement Collection and Analysis:
For example, requirements may include capturing player information (username, level, achievements), game progress,
inventory management, and leaderboard data.
2. Functional Requirements:
Specific to the gaming application. For instance, the database should support player registration, login, character creation, game
session management, saving and loading game progress, and handling multiplayer interactions.
3. Conceptual Database Design:
High-level structure and relationships of the database. Examples of conceptual design elements could be entities like Players,
Characters, Levels, Achievements, Items, and Relationships such as Player-Character, Character-Item, and Player-Game.
4. Logical Database Design:
Conceptual design into a database model. In gaming, the logical design may involve creating tables like Player (with attributes
such as ID, username, password), Character (with attributes like character ID, name, level), and Game (with attributes like game
ID, title, description).
5. Physical Database Design:
For gaming, the physical design may involve selecting a DBMS (e.g., MySQL, PostgreSQL, MongoDB) and implementing the
tables, columns, indexes, and constraints based on the chosen DBMS.
55. Levels of Abstraction
To ease the user interaction with database, the developers hide internal
irrelevant details from users. This process of hiding irrelevant details from user
is called data abstraction.
• There three types of level
• External level/View level
• Logical level/Conceptual level
• Physical level/Internal level
56. View Level/ External Level
Highest level of data abstraction. This describes the user interaction with
database system.
At external/view level, user just interact with system with the help of GUI
and enter the details at the screen, they are not aware of how the data is
stored and what data is stored; such details are hidden from them.
57. Logical / Conceptual Level
Logical level: This is the middle level of 3-level data abstraction architecture.
It describes what data is stored in database.
It describes what will be the entities, what will be their attributes and
relationships between them.
58. Physical / Internal Level
This is the lowest level of data abstraction. It describes how data is actually
stored in database and what type of data will be stored.
Let’s say we are storing customer information in a customer table.
At physical level these records can be described as blocks of storage (bytes,
gigabytes, terabytes etc.) in memory.