990 likes | 1.38k Views
Database Management Systems (DBMS). C ertificate C ourse in I nformation T echnology. Anil Luvishewa anil@cc.ruh.ac.lk. Learning Outcomes. Understand the need for database management as opposed to the traditional stand - alone applications approach.
E N D
Database Management Systems(DBMS) Certificate Course in Information Technology Anil Luvishewa anil@cc.ruh.ac.lk
Learning Outcomes • Understand the need for database management as opposed to the traditional stand - alone applications approach. • Learn the major factors involved in proper database design including the use of entity-relationship diagrams and normalization. • Learn to use SQL for data definition and data manipulation.
Topics • Introduction to DBMS • The Database Architecture • Database Design Process • Conceptual Data modeling – (Entity-Relationship approach) • The logical Database Model – (The Relational Model) • Logical Database Design – (Normalization) • Data Manipulation using SQL
Introduction to Database Concepts • Why use a Database? • Why Database Technology? ?
ATM users Bank Banking System Banking System ATM users Branch Branch Mobile
Data and Information • Data • Raw facts • Less meaningful • Not processed Eg: Date of birth • Information • Processed data • Meaningful • Organized • Eg: • Processed DOB: Age
File Processing System • Individual applications maintain own private data files. • Leads to data duplicate (redundancy). • Inconsistency • Management is very difficult • Data is in different formats. • Inflexible
Database Student database File 1 File 2 File 3 What is a database? A database is an organized collection of data that are related in a meaningful way and stored in a common pool which can be accessed by one or many persons for many purposes. A database is a group of related files • Eg: Course file • Student name file • Marks file
What is a Database? Data collection may be . . . Electronically Collected Manually Collected
Key Features of a database The data is • input (stored) only once • Organized • accessible effectively and efficiently
Database Building Blocks • File/Table A collection of related records. • Record A record is a group of related fields. • Field Field represents an attribute, or a characteristic or a piece of information
Table a Record a Field Database Building Blocks..
Database Management System (DBMS) • The DBMS is a software package which allows a user to define, create, and maintain the database and provides controlled access to this database. • The interface between users and data is provided by a database management system. Eg: Oracle, MS SQL-Server, MS Access MySQL, PostgreSQL
Admin DBMS Data-bases Results Modify/ Retrieval (Command) Users Overview of a DBMS
Characteristics of Modern DBMS • Query processing • Transaction management • Concurrency control • Database recovery • Database security and authorization • Distributed databases
Advantages of using DBMS • Data duplication and storage space wasting can be avoided • Inconsistency can be avoided • Data can be shared • Unauthorized access can be restricted • Recovery from failures
Disadvantages of using DBMS • cost of extra hardware • cost of entering data • cost of training people to use DBMS • cost of maintaining DBMS • complex
Components of a Database System • Data The data in the database integrated and shared. • Hardware Physically stores data, it can be secondary storage on which the database physically resides together with associated I/O devices. • Software Between the physical database & the users is a layer of software which is known as the DBMS. • Procedures Refer to the instructions & rules that governs the design & use of the database. • Users Application Programmers. End-users
Controlling & Maintaining a Database Database Administrator (DBA) Database
Duties of the Database Administrator • Installing and upgrades of database software • Performance tuning • Backup and recovery strategies • Start the database & shutdown the database • Monitoring the database • Give and drop database access to the users • Consultation with developers
Database Architecture Data-bases
The Need of a Database Architecture • Users need to access same data but in different customized views. • User views can be changed without affecting data or other user views. • Users are not deal directly with physical data storage • Database administrator should be able to change the database storage without affecting the user’s views.
Database Architecture An architecture for a database system is useful for explaining the structure of a specific database system The database architecture is a three level architecture which reflects the underlying database system
Schemas and Instances Database schema • The description of a database called database schema • The logical structure of the database • Schema is defined during the database designing and is not frequently changed Instance • Data (the actual content) in the database at a particular moment in time is called database state. • It is also called the instances or current set of occurrences
External View 1 External View n Conceptual Schema Internal Schema DB DB DB Three Schema Architecture End users External Level External / Conceptual mapping Conceptual Level Conceptual / Internal mapping Internal Level
Three Schema Architecture.. Internal (Physical) Schema • Defines the physical view of data (as seen by a DBMS) • Describe the physical storage of the database • Describe how the data is stored in the database • Concern with storage space allocation, record description, data compression and encryption techniques.
Internal (Physical) Level • Struct Employee { Char Emp_no[5], Char Name[25], Date Date_joined, Boolean Pay_Tax, Int OT_Hours, Char Des_Code[3] } ;
Three Schema Architecture.. Conceptual Schema • Defines the logical view of data (as seen by programs) • Describe the structure of the whole database for a community of users. • Hides the details of physical storage structure. • Describe entities, data types, relationships, user operations and constraints.
Conceptual Level Employee Table Base Table
Three Schema Architecture.. External Schema • Defines the external view of data (as seen by a user) • The users view of the database • Describe the part of the database that a particular user group is interested. • Hides the other details of the database.
External Level Base Table (Conceptual View) The data what user wants (Only selected parts of selected records from base table) View Table (External View)
Mapping External/Conceptual mapping • Define the correspondence between a particular external view and conceptual view. • This specified how a particular external schema is derived from conceptual schema Conceptual/Internal mapping • Define the correspondence between the conceptual view and stored database. • This specifies how the conceptual schema is represented at the internal level. • If the structure of the stored database is changed, the conceptual internal mapping must also be changed accordingly.
Sno FName LName Staff_No LName Bno Staff_No FName LName DOB Batch_no Mapping.. External view 1 External view 2 External Level Conceptual Level Struct STAFF { int Staff_No; int Branch_No; char FName[15]; char LName[15]; date date_of_birth}; Internal (Physical) Level
Data Independence The major objective for the three-level architecture is to provide data independence Logical Data Independence Capacity to change the conceptual schema without having to change external schemas or application program. Physical Data Independence The ability to modify the physical schema without changing the conceptual (or external ) schema
Database Design The database design process can be broken down into four phases. • Requirements collection and analysis phase • Conceptual Design • Logical Design • Physical Design
Requirements collection and analysis phase Prospective database users are interviewed to understand and document their data requirements
Conceptual Design • This is a high level description of the structure of a database Eg: E-R Diagram • Concise description of the data requirements of the users and includes detailed description of the data, relationship and constraints.
Logical Design This is the process of mapping the database structure developed in the previous phase to a particular database model. Eg: Map E-R model to relational
Physical Design This is the process of defining structure that enables the database to be queried in an efficient manner Eg: index and hash file design
Phases of Database Design Problem Requirements collection & analysis Database Requirements Conceptual Design Conceptual Data Model Logical Design Logical Data Model Physical Design Physical Data Model Database Implementation
Entity – Relationship Modeling ER model is high level conceptual data model
The Concepts of the ER Model • Entity • An entity is a thing in the real world with an independent existence . • As entity may be an object with a physical existence . e.g. : a person , a student , a house, etc. • An entity is any object that is relevant to the organization. • Tangible object • Intangible objects • Events
Conceptual Design Entities Department Employee Project Dependent
The Concepts of the ER Model • Attribute • Each entity has particular properties or features (characteristics ) called attributes . • e.g. student entity(student no, name, address, dob)
Type of attributes • Simple (atomic) attribute Attributes that are not divisible are called simple or atomic attribute. Eg: Emp_No • Composite attribute Can be divided in a smaller part which represent more basic attributes with independent meaning of their own. Eg: Name (First Name, Mid Name, Last Name)
Type of attributes • Multi-valued attribute In some case an attribute can have a set of values for the same entity such attributes are called multi-valued attributes. Eg. Degree of a person , Qualification • Derived attribute • An attribute whose value can be calculated from related attribute values Eg: Age (Using Date of Birth) . Years Employed (Using Employed Date) .
Relationship • Relationship A meaningful association between entities. Eg: Student follows courses Employee works for department
Manages follows Student Courses Relationship • Degree of a Relationship The degree of the relationship type is no. of participating entity types . • Unary Relationship • Relationship between the instances of a single entity type. E.g.: person is married to a person (1:1) Employee manages Employees (1:M) • Binary Relationship • Relationship between the instances of two entity types. Degree = 2; Employee
supplies Supplier Project Part Relationship • Degree of a Relationship • Ternary Relationship A simultaneous relationship among the instances of three entity type. Degree = 3 ,Ternary Relationship