SlideShare a Scribd company logo
1 of 65
Unit-1
Module-1
 Introduction to DBMS
 Data Models in DBMS
 Data Base System Architecture
 Data Abstraction
Dr. Omkar Pattnaik
Associate Professor
Sandip University Nashik
Introduction
 A database is a collection of related information stored in a organized manner
so that it is available to many users for different purposes.
 The content of a database is obtained by combining data from all the
different sources in an organization. So that data are available to all users
and redundant data can be eliminated.
 A Database System is an integrated collection of related files, along with
details of the interpretation of the data contained therein.
General objectives in establishing a Database
 Eliminate redundant data as much as possible.
 Integrate existing data files.
 Share data among all users.
 Incorporate changes easily and quickly.
 Simplify the use of data files.
 Maintenance of Data Security
 Lower the cost of storing and retrieving data.
 Improve accuracy and consistency.
 Provide data security from unauthorized use.
 Exercise central control over standards
Advantages of Database
 File Consolidation
 Program and file independence
 Access Versatility
 Data Security
 Program Development
 Program Maintenance
 Special Information
What is DBMS?
 The management of data in a database system is done by means of a general
purpose software package called DBMS.
 The primary goal of the DBMS is to provide an environment that is both
convenient and efficient to use in retrieving and storing database
information.
 A Database Management System is a software system that allows access to
data contained in a database. The objective of the DBMS is to provide a
convenient and effective method of defining, storing, and retrieving the
information contained in the database.
 The DBMS interfaces with application programs, so that data contained in the
database can be used by multiple applications and users.

DBMS……
 Creating of a file, addition, Deletion, modification of data and of entire files.
 Retrieving data collectively/selectively.
 The data can be sorted/indexed.
 Various reports can be produced.
 It can perform desired calculations.
 To maintain data integrity and database use.
 A DBMS, therefore, is a combination of Hardware and software that can be
used to set up and monitor a database, and can manage the updating and
retrieval of database that has been stored in it.
Commercially available DBMS Software
 ORACLE
 SYBASE
 INGRESS
 Microsoft ACCESS
 FoxBASE
 FoxPro
 Dbase
Data Models
 Data Model is a collection of concept that can be used to describe structure
of the database.
 Structure of the database means data type relationship constraints that
should hold the data.
 Data model the set of basic operation for specifying retrieve and update the
database.
 Data model is a collection of conceptual tools,
 1. Data
 2. Data Relationship
 3. Data Semantics.
 4. Data Constraints.
Categories of Data Models

Relational Model
 This model represent data and relationship among data by a collection of
tables known as relationship.
 A number of columns unique names.
 Relationship model relate records by the value that contain.
 Advantage:
• Easy to use
• Flexibility
• Precision
• Security
• Data Independence
Disadvantage
 Low Performance.
 Physical storage consumption.
 Easy of design can lead to bad design.
 Hardware over heads
Cont….
 The most common model is the Relational Model.
 The data in this model is kept in the form of a two-dimensional table.
 All data is saved in the form of rows and columns.
 Tables are the foundation of a relational paradigm.
 In the relational paradigm, the tables are also referred to as relations. Example: We
have an Employee table in this example.
Network data Model
 This model represent data by collection of records and relationship among
data.
 This is represent by link which can be viewed as pointer.
 There are three components of network models,
 Record Type
 Data Elements
 Link
Cont….
 This paradigm is an expansion of the hierarchical model. It was the most prevalent
model prior to the relational model.
 The main difference between this model and the hierarchical approach is that a
record can have several parents.
 It replaces the hierarchical tree with a graph.
 In the sample below, we can see that node student has two parents, CSE
Department and Library.
 This was not allowed in the hierarchical model.
Cont….
 Advantages
 Easy to access data.
 Capability to handle more relationship type.
 Data Integrity.
 Data Independence.
Disadvantages:
 System Complexity.
 Operational Anomalies.
 Structural Independence.
Hierarchical Data Model
 A DBMS to the hierarchical data model uses tree structure to relationship among records.
 A hierarchical database consist of a collection of records which are connected with each other
through link.
 Advantages
 It is a simple, straight forward and natural method of implementing.
 It is a useful when there is some hierarchical character in the database.
 Disadvantages:
 The hierarchical model cannot represent all the relationship that occurs in the real world.
 It cannot represent many to many relationship.
 The hierarchical model use only there is a hierarchical character in the consider database.
Database System Architecture

Cont….

Unit-1: Module-2
 Entity Relationship Diagram – ER Diagram in DBMS
 An Entity–relationship model (ER model) describes the structure of a database with
the help of a diagram, which is known as Entity Relationship Diagram (ER
Diagram).
 An ER model is a design or blueprint of a database that can later be implemented as a
database.
 The main components of E-R model are: Entity set and Relationship set.
 An ER diagram shows the relationship among entity sets.
 An entity set is a group of similar entities and these entities can have attributes.
 In terms of DBMS, an entity is a table or attribute of a table in database.
 ER diagram shows the complete logical structure of a database.
Example of E-R diagram
 Here are the geometric shapes and their meaning in an E-R Diagram.
 Rectangle: Represents Entity sets.
Ellipses: Attributes
Diamonds: Relationship Set
Lines: They link attributes to Entity Sets and Entity sets to Relationship Set
Double Ellipses: Multivalued Attributes
Dashed Ellipses: Derived Attributes
Double Rectangles: Weak Entity Sets
Double Lines: Total participation of an entity in a relationship set

Components of a ER Diagram
 ER diagram has three main components:
1. Entity
2. Attribute
3. Relationship
 Entity : An entity is an object or component of data.
 An entity is represented as rectangle in an ER diagram.
 In the following ER diagram we have two entities
 Student and College and these two entities have many to one relationship
Cont….
 Weak Entity:
An entity that cannot be uniquely identified by its own attributes and relies on the
relationship with other entity is called weak entity.
 The weak entity is represented by a double rectangle.
A bank account cannot be uniquely identified without knowing the bank to which the account belongs,
so bank account is a weak entity.
Cont…
 Attribute : An attribute describes the property of an entity. An attribute is represented as
oval in an ER diagram.
There are four types of attributes:
 Key attribute
 Composite attribute
 Multivalued attribute
 Derived attribute
 Key attribute: A key attribute can uniquely identify an entity from an entity set
• Student roll number can uniquely identify a student from a set of students.
• Key attribute is represented by oval same as other attributes.
• However the text of key attribute is underlined.
Cont….
 Composite attribute: An attribute that is a combination of other attributes is known as
composite attribute.
 In student entity, the student address is a composite attribute as an address is composed
of other attributes such as pin code, state, country.
 Multivalued attribute: An attribute that can hold multiple values is known as
multivalued attribute.
 It is represented with double ovals in an ER Diagram.
 Example: A person can have more than one phone numbers.
Cont…
 A derived attribute is one whose value is dynamic and derived from another attribute.
 It is represented by dashed oval in an ER Diagram. (Previous diagram)
 Example – Person age is a derived attribute as it changes over time and can be derived
from another attribute (Date of birth).
Relationship
 A relationship is represented by diamond shape in ER diagram.
 It shows the relationship among entities.
 There are four types of relationships:
1. One to One
2. One to Many
3. Many to One
4. Many to Many
 One to One: When a single instance of an entity is associated with a single instance of
another entity then it is called one to one relationship.
 Example, a person has only one passport and a passport is given to one person.
Cont…
 One to Many: When a single instance of an entity is associated with more than one
instances of another entity then it is called one to many relationship.
 Example – a customer can place many orders but a order cannot be placed by many
customers.
 Many to One: When more than one instances of an entity is associated with a single
instance of another entity then it is called many to one relationship.
 Example – many students can study in a single college but a student cannot study in
many colleges at the same time.
Cont…
 Many to Many: When more than one instances of an entity is associated with more
than one instances of another entity then it is called many to many relationship.
 Example, a student can be assigned to many projects and a project can be assigned to
many students.
Total Participation of an Entity set
 Total participation of an entity set represents that each entity in entity set must have at
least one relationship in a relationship set.
 It is also called mandatory participation.
 Example: In the following diagram each college must have at-least one associated
Student.
 Total participation is represented using a double line between the entity set and
relationship set.
DBMS Schema

DBMS Schema
Definition of schema: Design of a database is called the schema.
For example: An employee table in database exists with the following attributes:
EMP_NAME EMP_ID EMP_ADDRESS EMP_CONTACT
-------- ------ ----------- -----------
This is the schema of the employee table.
Schema defines the attributes of tables in the database.
Schema is of three types: Physical schema, logical schema and view schema.
DBMS Instance
 Definition of instance: The data stored in database at a particular moment of time is called
instance of database.
 Database schema defines the attributes in tables that belong to a particular database.
 The value of these attributes at a moment of time is called the instance of that database.
 EMP_NAME EMP_ID EMP_ADDRESS EMP_CONTACT
 ------- ------ ----------- -----------
 Chaitanya 101 Noida 95********
 Ajeet 102 Delhi 99********
Elements of Object oriented data model
 Objects
 The real world entities and situations are represented as objects in the Object oriented database
model.
 Attributes and Method
 Every object has certain characteristics. These are represented using Attributes. The behaviour of the
objects is represented using Methods.
 Class
 Similar attributes and methods are grouped together using a class. An object can be called as an
instance of the class.
 Inheritance
 A new class can be derived from the original class. The derived class contains attributes and methods
of the original class as well as its own.
Integrity Constraints
 Integrity constraints are a set of rules. It is used to maintain the quality of information.
 Integrity constraints ensure that the data insertion, updating, and other processes have to
be performed in such a way that data integrity is not affected.
 Thus, integrity constraint is used to guard against accidental damage to the database.
 Types of constraints
 NOT NULL
 UNIQUE
 DEFAULT
 CHECK
 Key Constraints – PRIMARY KEY, FOREIGN KEY
 Domain constraints
Unit-2: Module-1
 Introduction to SQL: Structured Query Language, popularly known as SQL is a domain specific
language used to manage data in relational database management systems (RDBMS).
 It allows the user to perform operations such as create, delete etc. on tables in database
 It also allows operations such as read, insert, update, delete etc. on the data stored in the tables.
 All popular database management softwares such as MySQL, PostgreSQL, Oracle, Microsoft Access,
IDBM Db2, SQLite etc. use SQL to manage the database.
 SQL is a simple English like language which is used to query the database to perform various
operations on the database.
Characteristics of SQL
 Only use lowercase letters, numbers and underscores for database, schema, column
and table name.
 Use simple & meaningful, table and column name.
 This is because sometimes, we refer the attribute of a table from another table as
foreign key.
 SQL is not a case sensitive language, however the keywords used in the SQL query are
generally written in uppercase.
 Using SQL queries you can perform various operations on the database.
SQL Processing
 When a SQL statement executes, system first performs various checks such as syntax check,
semantic check, shared pool check on the SQL query during parsing phase.
 In the second phase, which is also known as hard parsing phase, system performs query
optimization and generate various execution plans.
 In the next phase, row source generator software receives the optimal execution plan and
generate a iterative plan that is used by the database.
 Last step is execution of the query based on the iterative plan generated in the previous step.
Introduction to SQL Data Types and Literals
 Each column in a database table is required to have a name and a data type.
 An SQL developer must decide what type of data that will be stored inside each column when
creating a table.
 The data type is a guideline for SQL to understand what type of data is expected inside of each
column, and it also identifies how SQL will interact with the stored data.
 While creating a database table in a database, we need to specify following two attributes to
define a table column:
 Name of the column
 Data type of the column
Cont…
 SQL Data types are defined during the creation of a table in a database.
 While creating a table, it is required to specify its respective data type and size along with the
name of the column.
 Syntax to specify a data type in MySQL −
 CREATE TABLE table_name(column1 datatype, column2 datatype....)
 Example query below to understand better.
 CREATE TABLE Customers (Name VARCHAR (25), Age INT);
 In the above SQL query, we are creating a table Customers.
 And since the Name column only stores string values, we are specifying its data type as
"VARCHAR".
 The VARCHAR data type represents string values in SQL.
 Similarly, we define the Age column with the integer data type, "INT".
Types of SQL Data Types
 String
 Numeric
 Date and Time
 MySQL Data Types
 There are three main data types available in MySQL Database: string, numeric, and date and time.
 MySQL - String Data Types
 Data type with Description
 CHAR(size) A fixed length string which can have letters, numbers, and special characters. The size parameter
specifies the column length in characters which can vary from from 0 to 255. Default size is 1
 VARCHAR(size)A variable length string which can contain letters, numbers, and special characters. The size
parameter specifies the maximum string length in characters which can vary from 0 to 65535.
 BINARY(size) This is equal to CHAR(), but stores binary byte strings. The size parameter specifies the column
length in bytes. Default size is 1
 VARBINARY(size) This is equal to VARCHAR(), but stores binary byte strings. The size parameter specifies the
maximum column length in bytes.
 TINYTEXT This holds a string with a maximum length of 255 characters
 TEXT(size)This holds a string with a maximum length of 65,535 bytes
 LONGTEXT This holds a string with a maximum length of 4,294,967,295 characters
MySQL - Date and Time Data Types
 Data type with Description
 DATE A date in YYYY-MM-DD format, between 1000-01-01 and 9999-12-31. For example,
December 30th, 1973 would be stored as 1973-12-30.
 DATETIME A date and time combination in YYYY-MM-DD HH:MM:SS format, between 1000-01-
01 00:00:00 and 9999-12-31 23:59:59. For example, 3:30 in the afternoon on December 30th,
1973 would be stored as 1973-12-30 15:30:00.
 TIMESTAMP A timestamp between midnight, January 1st, 1970 and sometime in 2037. This
looks like the previous DATETIME format, only without the hyphens between numbers; 3:30 in
the afternoon on December 30th, 1973 would be stored as 19731230153000 (
YYYYMMDDHHMMSS ).
 TIME Stores the time in a HH:MM:SS format.
 YEAR(M) Stores a year in a 2-digit or a 4-digit format. If the length is specified as 2 (for
example YEAR(2)), YEAR can be between 1970 to 2069 (70 to 69). If the length is specified as
4, then YEAR can be 1901 to 2155. The default length is 4.
SQL commands
 SQL commands are instructions to the database to perform a specific operation.
 For example, you can use SELECT command to read the data from database, you can use UPDATE command to update data in
database.
 There are several commands that are available in SQL for various type of tasks and these commands are divided in following
categories:
1. DDL (Data Definition Language) – Commands such as CREATE, DROP, ALTER.
2. DML (Data Manipulation Language) – Commands such as INSERT, UPDATE, DELETE.
3. DCL (Data Control Language) – Commands such as GRANT, REVOKE.
4. TCL (Transaction Control Language) – Commands such as COMMIT, ROLLBACK.
5. DQL (Data Query Language) – Commands such as SELECT.
DDL (Data Definition Language)
 1. DDL (Data Definition Language)
 DDL commands are used to create, drop and alter the databases, aliases, indexes, tables etc.
 Once a DDL statement is executed, it takes effect immediately in the database. Which means any changes done to the database
using DDL command is permanent.
 Popular DDL commands are: CREATE, DROP, ALTER and TRUNCATE.
 a) CREATE: This command is used to create database and tables inside a database.
 Syntax for creating database:
 CREATE DATABASE database_name;
 Syntax for creating table:
 CREATE TABLE table_name (
 column1 datatype,
 column2 datatype,
 column3 datatype,
 ....
 );
 Desc table name;
Examples
 CREATE TABLE CUSTOMERS(
 ID INT NOT NULL,
 NAME VARCHAR (20) NOT NULL,
 AGE INT NOT NULL,
 ADDRESS CHAR (25),
 SALARY DECIMAL (18, 2),
 PRIMARY KEY (ID)
 );
Field Type Null Key Default Extra
ID int(11) NO PRI NULL
NAME
varchar(
20)
NO NULL
AGE int(11) NO NULL
ADDRESS char(25) YES NULL
SALARY
decimal(
18,2)
YES NULL
Cont…
 DROP: This command is used to drop database and tables.
 Syntax for dropping database:
 DROP DATABASE database_name;
 Syntax for dropping table:
 DROP TABLE table_name;
 ALTER: This command is used to add, delete, or modify columns in an existing table.
 Syntax: To add a new column in the existing table
 ALTER TABLE table_name
 ADD column_name datatype;
 Example: The following ALTER TABLE statement will add a new column Address to the existing
table Employees.
 ALTER TABLE EMPLOYEES
 ADD Address VARCHAR2(200);
Cont….
 TRUNCATE: This statement deletes all the rows from the table.
 This is different from the DROP command, the DROP command deletes the
entire table along with the table schema,
 However TRUNCATE just delete all the rows and leaves an empty table.
 Syntax:
 TRUNCATE TABLE table_name;
 Example: Deletes all the rows from the table Employees.
 TRUNCATE TABLE EMPLOYEES;
DML (Data Manipulation Language)
 SQL commands that deals with the manipulation of data comes under DML category.
 The popular commands that come under DML are:
 INSERT − Insert data into a table.
 UPDATE − Update existing data in the specified table.
 DELETE − Delete records from the specified table in database.
 a) INSERT: This command is used to insert records in a table
 Syntax: When you are not inserting the data for all the columns and leaving some columns empty. In that
case specify the column name and corresponding value.
 INSERT INTO table_name (column1, column2, column3, ...)
 VALUES (value1, value2, value3, ...);
 Syntax: When inserting the data for all the columns. No need to specify column name.
 INSERT INTO table_name
 VALUES (value1, value2, value3, ...);
Cont….
 INSERT INTO EMPLOYEE (name, age) VALUES ("Chaitanya", "35");
 UPDATE: This is used to modify the existing records in a table.
 Syntax:
 UPDATE table_name
 SET column1 = value1, column2 = value2, ...
 WHERE condition;
 Example: Updating the name and city of the employee with employee id “101”. This will search all the
records in the table where Employee_id is equal to 101 then it will update the name field to “Mukesh”
and city field to “Nashik” for all the filtered records.
 UPDATE EMPLOYEE
 SET name = ‘Mukesh', city = ‘Nashik'
 WHERE Employee_id = 101;
Cont…
 DELETE: It is used to delete the existing records from the table.
 Syntax:
 DELETE FROM table_name WHERE condition;
 Example: The following SQL query will delete all the rows from the table Employees where
name is equal to “Mukesh".
 DELETE FROM EMPLOYEES
 WHERE name=“Mukesh";
DCL (Data Control Language)
 DCL commands are used to set permissions on the table.
 This is the command that is responsible for the security of database. By setting up the permission,
user can prevent un-authorised access to the database.
 DCL commands are:
 GRANT
 REVOKE
 a) Grant: It is used to give user access privileges to a database.
 Example: The following command will grant users USER1 & USER2, the select, update and delete
access to the table TABLE1 .
 GRANT SELECT, UPDATE, DELETE ON TABLE1 TO USER1, USER2;
 b) Revoke: It revokes the given access to the user.
 Example: Let’s revoke the access from USER1 & USER2 given above using GRANT command.
 REVOKE SELECT, UPDATE, DELETE ON TABLE1 FROM USER1, USER2;
TCL (Transaction Control Language)
 The purpose of TCL commands is to maintain the consistency of the database. These commands
are generally used along with the DML commands such as INSERT, UPDATE and DELETE.
 The changes made by DML commands are either committed or rolled back by TCL commands.
There is another TCL command that can place a save point in the transactions which makes it
possible to rollback all the transaction till the last save point.
 TCL commands are:
 COMMIT
 ROLLBACK
 SAVEPOINT
 a) Commit: Commit command make the changes made to the database permanent.
 Syntax:
 COMMIT;
 Example: The following update command changes the name in the STUDENT table from “Harilal"
to “Hiralal". By using COMMIT just after the update statement save these changes permanently in
the table.
Cont….
 UPDATE STUDENT
 SET NAME = ‘Hiralal’
 WHERE NAME = ‘Harilal’;
 COMMIT;
 b) Rollback: Rollback command is used to undo the changes that have been made to the database temporarily. The
important point to note here is that the changes saved using COMMIT command cannot be undone using ROLLBACK
command.
 Syntax:
 ROLLBACK;
 Example: The following commands would have deleted all the students from the STUDENT table who have age
greater than 15. Since we have used the ROLLBACK command after the DELETE statement, these changes were
undone and no record deleted from the table.
 The important point to note here is that DELETE and ROLLBACK are two different commands, they are not written
together. To understand this, let’s say the user mistakenly written the following DELETE command but as soon as
he realises his mistake, he use ROLLBACK command to undo the changes that were made unintentionally.
 DELETE FROM STUDENT
 WHERE AGE > 30;
 ROLLBACK;
Cont…
 SAVEPOINT: This command helps in roll backing the transactions till a certain point.
 For example, a transaction consists of several DML commands and we want to undo the changes till
a certain point and not completely, this can be achieved by using SAVEPOINT.
 Syntax:
 SAVEPOINT SAVEPOINT_NAME;
SQL Operators
 SQL Arithmetic Operators: +,-,*,/,%
 SQL Bitwise Operators: &, |, ^
 SQL Comparison Operators: =,>,<,…
 SQL Compound Operators: +=,-=,*=,/=,…
 SQL Logical Operators: AND,OR, Like,….
 Examples: SELECT 30 + 20; output: 50
 SELECT * FROM Products WHERE Price >= 30;
 SELECT * FROM Customers
 WHERE City = “Nashik" AND Country = “India";
SET Operations in SQL
 SQL supports few Set operations which can be performed on the table data.
 These are used to get meaningful results from data stored in the table, under
different special conditions.
 4 different types of SET operations, along with examples:
1. UNION
2. UNION ALL
3. INTERSECT
4. MINUS
SELECT * FROM First 1 x
UNION 2 y
SELECT * FROM Second;
Cont…
 UNION ALL
 This operation is similar to Union. But it also shows the duplicate rows.
 SELECT * FROM First
 UNION ALL
 SELECT * FROM Second; ID NAME
 1 Rabi
 2 Akash
 2 Akash
 3 Sarat
INTERSECT
 Intersect operation is used to combine two SELECT statements, but it only
retuns the records which are common from both SELECT statements. In case
of Intersect the number of columns and datatype must be same.
 NOTE: MySQL does not support INTERSECT operator.
 SELECT * FROM First
 INTERSECT
 SELECT * FROM Second; Akash
MINUS
 The Minus operation combines results of two SELECT statements and return
only those in the final result, which belongs to the first set of the result.
 SELECT * FROM First
 MINUS
 SELECT * FROM Second; Rabi
Introduction to MongoDB
 MongoDB is an open source, document oriented database that stores data in form of documents (key
and value pairs).
 That document based databases are one of types of NoSQL databases.
 MongoDB was created by Eliot and Dwight (founders of DoubleClick) in 2007, when they faced
scalability issues while working with relational database.
 The organization that developed MongoDB was originally known as 10gen.
Features of MongoDB

Cont…
 MongoDB provides high performance.
 Most of the operations in the MongoDB are faster compared to relational databases.
MongoDB provides auto replication feature that allows you to quickly recover data in case of a
failure.
 Horizontal scaling is possible in MongoDB because of sharing.
 Sharding is partitioning of data and placing it on multiple machines in such a way that the order of
the data is preserved.
 Horizontal scaling vs vertical scaling:
 Vertical scaling means adding more resources to the existing machine while horizontal scaling means
adding more machines to handle the data.
 Vertical scaling is not that easy to implement, on the other hand horizontal scaling is easy to
implement.
 Horizontal scaling database examples: MongoDB, Cassandra etc.
Cont….
 Load balancing:
 Horizontal scaling allows MongoDB to balanace the load.
 High Availabilty:
 Auto Replication improves the availability of MongoDB database.
 Indexing:
 Index is a single field within the document.
 Indexes are used to quickly locate data without having to search every
document in a MongoDB database.
 This improves the performance of operations performed on the MongoDB
database.
Codd's 12 Rules
 Dr Edgar F. Codd, after his extensive research on the Relational Model of database
systems, came up with twelve rules of his own, which according to him, a database
must obey in order to be regarded as a true relational database.
 Rule 1: Information Rule
 The data stored in a database, may it be user data or metadata, must be a value of
some table cell. Everything in a database must be stored in a table format.
 Rule 2: Guaranteed Access Rule
 Every single data element (value) is guaranteed to be accessible logically with a
combination of table-name, primary-key (row value), and attribute-name (column
value). No other means, such as pointers, can be used to access data.
 Rule 3: Systematic Treatment of NULL Values
 The NULL values in a database must be given a systematic and uniform treatment. This
is a very important rule because a NULL can be interpreted as one the following − data
is missing, data is not known, or data is not applicable.
Cont…
 Rule 4: Active Online Catalog
 The structure description of the entire database must be stored in an online catalog, known as
data dictionary, which can be accessed by authorized users. Users can use the same query
language to access the catalog which they use to access the database itself.
 Rule 5: Comprehensive Data Sub-Language Rule
 A database can only be accessed using a language having linear syntax that supports data
definition, data manipulation, and transaction management operations. This language can be
used directly or by means of some application. If the database allows access to data without
any help of this language, then it is considered as a violation.
 Rule 6: View Updating Rule
 All the views of a database, which can theoretically be updated, must also be updatable by
the system.
Cont…
 Rule 7: High-Level Insert, Update, and Delete Rule
 A database must support high-level insertion, updataion, and deletion. This must not be
limited to a single row, that is, it must also support union, intersection and minus
operations to yield sets of data records.
 Rule 8: Physical Data Independence
 The data stored in a database must be independent of the applications that access the
database. Any change in the physical structure of a database must not have any impact on
how the data is being accessed by external applications.
 Rule 9: Logical Data Independence
 The logical data in a database must be independent of its user’s view (application). Any
change in logical data must not affect the applications using it. For example, if two tables
are merged or one is split into two different tables, there should be no impact or change
on the user application. This is one of the most difficult rule to apply.
Cont…
 Rule 10: Integrity Independence
 A database must be independent of the application that uses it. All its integrity constraints
can be independently modified without the need of any change in the application. This rule
makes a database independent of the front-end application and its interface.
 Rule 11: Distribution Independence
 The end-user must not be able to see that the data is distributed over various locations.
Users should always get the impression that the data is located at one site only. This rule has
been regarded as the foundation of distributed database systems.
 Rule 12: Non-Subversion Rule
 If a system has an interface that provides access to low-level records, then the interface
must not be able to subvert the system and bypass security and integrity constraints.
Unit-1-DBMS-SUN-4 everything you need to know.pptx

More Related Content

Similar to Unit-1-DBMS-SUN-4 everything you need to know.pptx

Week 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data ModelingWeek 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data Modelingoudesign
 
Database Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfDatabase Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfrsujeet169
 
introduction of database in DBMS
introduction of database in DBMSintroduction of database in DBMS
introduction of database in DBMSAbhishekRajpoot8
 
Bca examination 2015 dbms
Bca examination 2015 dbmsBca examination 2015 dbms
Bca examination 2015 dbmsAnjaan Gajendra
 
Student POST  Database processing models showcase the logical s.docx
Student POST  Database processing models showcase the logical s.docxStudent POST  Database processing models showcase the logical s.docx
Student POST  Database processing models showcase the logical s.docxorlandov3
 
DBMS Lecture1.ppt
DBMS Lecture1.pptDBMS Lecture1.ppt
DBMS Lecture1.pptIpsitaSaha9
 
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...Anwar Patel
 
Geographic Information systems
Geographic Information systemsGeographic Information systems
Geographic Information systemsRajalakshmiS34
 
Geographic Information System unit 2
Geographic Information System unit 2Geographic Information System unit 2
Geographic Information System unit 2sridevi5983
 
Schema Integration, View Integration and Database Integration, ER Model & Dia...
Schema Integration, View Integration and Database Integration, ER Model & Dia...Schema Integration, View Integration and Database Integration, ER Model & Dia...
Schema Integration, View Integration and Database Integration, ER Model & Dia...Mobarok Hossen
 

Similar to Unit-1-DBMS-SUN-4 everything you need to know.pptx (20)

Data models
Data modelsData models
Data models
 
Data models
Data modelsData models
Data models
 
database
databasedatabase
database
 
Week 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data ModelingWeek 3 Classification of Database Management Systems & Data Modeling
Week 3 Classification of Database Management Systems & Data Modeling
 
Database Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfDatabase Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdf
 
introduction of database in DBMS
introduction of database in DBMSintroduction of database in DBMS
introduction of database in DBMS
 
DBMS Part 1.pptx
DBMS Part 1.pptxDBMS Part 1.pptx
DBMS Part 1.pptx
 
Bca examination 2015 dbms
Bca examination 2015 dbmsBca examination 2015 dbms
Bca examination 2015 dbms
 
Student POST  Database processing models showcase the logical s.docx
Student POST  Database processing models showcase the logical s.docxStudent POST  Database processing models showcase the logical s.docx
Student POST  Database processing models showcase the logical s.docx
 
DBMS OF DATA MODEL Deepika 2
DBMS OF DATA MODEL  Deepika 2DBMS OF DATA MODEL  Deepika 2
DBMS OF DATA MODEL Deepika 2
 
DBMS Lecture1.ppt
DBMS Lecture1.pptDBMS Lecture1.ppt
DBMS Lecture1.ppt
 
DBMS
DBMSDBMS
DBMS
 
DBMS Part-2.pptx
DBMS Part-2.pptxDBMS Part-2.pptx
DBMS Part-2.pptx
 
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
Lecture Basic HTML tags. Beginning Web Site Design Stanford University Contin...
 
Db lec 01
Db lec 01Db lec 01
Db lec 01
 
Spatial Data Models
Spatial Data Models Spatial Data Models
Spatial Data Models
 
Geographic Information systems
Geographic Information systemsGeographic Information systems
Geographic Information systems
 
Geographic Information System unit 2
Geographic Information System unit 2Geographic Information System unit 2
Geographic Information System unit 2
 
Schema Integration, View Integration and Database Integration, ER Model & Dia...
Schema Integration, View Integration and Database Integration, ER Model & Dia...Schema Integration, View Integration and Database Integration, ER Model & Dia...
Schema Integration, View Integration and Database Integration, ER Model & Dia...
 
dbms mannual.pdf
dbms mannual.pdfdbms mannual.pdf
dbms mannual.pdf
 

Recently uploaded

9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdfHuman37
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 

Recently uploaded (20)

9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf20240419 - Measurecamp Amsterdam - SAM.pdf
20240419 - Measurecamp Amsterdam - SAM.pdf
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
E-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptxE-Commerce Order PredictionShraddha Kamble.pptx
E-Commerce Order PredictionShraddha Kamble.pptx
 

Unit-1-DBMS-SUN-4 everything you need to know.pptx

  • 1. Unit-1 Module-1  Introduction to DBMS  Data Models in DBMS  Data Base System Architecture  Data Abstraction Dr. Omkar Pattnaik Associate Professor Sandip University Nashik
  • 2. Introduction  A database is a collection of related information stored in a organized manner so that it is available to many users for different purposes.  The content of a database is obtained by combining data from all the different sources in an organization. So that data are available to all users and redundant data can be eliminated.  A Database System is an integrated collection of related files, along with details of the interpretation of the data contained therein.
  • 3. General objectives in establishing a Database  Eliminate redundant data as much as possible.  Integrate existing data files.  Share data among all users.  Incorporate changes easily and quickly.  Simplify the use of data files.  Maintenance of Data Security  Lower the cost of storing and retrieving data.  Improve accuracy and consistency.  Provide data security from unauthorized use.  Exercise central control over standards
  • 4. Advantages of Database  File Consolidation  Program and file independence  Access Versatility  Data Security  Program Development  Program Maintenance  Special Information
  • 5. What is DBMS?  The management of data in a database system is done by means of a general purpose software package called DBMS.  The primary goal of the DBMS is to provide an environment that is both convenient and efficient to use in retrieving and storing database information.  A Database Management System is a software system that allows access to data contained in a database. The objective of the DBMS is to provide a convenient and effective method of defining, storing, and retrieving the information contained in the database.  The DBMS interfaces with application programs, so that data contained in the database can be used by multiple applications and users. 
  • 6. DBMS……  Creating of a file, addition, Deletion, modification of data and of entire files.  Retrieving data collectively/selectively.  The data can be sorted/indexed.  Various reports can be produced.  It can perform desired calculations.  To maintain data integrity and database use.  A DBMS, therefore, is a combination of Hardware and software that can be used to set up and monitor a database, and can manage the updating and retrieval of database that has been stored in it.
  • 7. Commercially available DBMS Software  ORACLE  SYBASE  INGRESS  Microsoft ACCESS  FoxBASE  FoxPro  Dbase
  • 8. Data Models  Data Model is a collection of concept that can be used to describe structure of the database.  Structure of the database means data type relationship constraints that should hold the data.  Data model the set of basic operation for specifying retrieve and update the database.  Data model is a collection of conceptual tools,  1. Data  2. Data Relationship  3. Data Semantics.  4. Data Constraints.
  • 9. Categories of Data Models 
  • 10. Relational Model  This model represent data and relationship among data by a collection of tables known as relationship.  A number of columns unique names.  Relationship model relate records by the value that contain.  Advantage: • Easy to use • Flexibility • Precision • Security • Data Independence Disadvantage  Low Performance.  Physical storage consumption.  Easy of design can lead to bad design.  Hardware over heads
  • 11. Cont….  The most common model is the Relational Model.  The data in this model is kept in the form of a two-dimensional table.  All data is saved in the form of rows and columns.  Tables are the foundation of a relational paradigm.  In the relational paradigm, the tables are also referred to as relations. Example: We have an Employee table in this example.
  • 12. Network data Model  This model represent data by collection of records and relationship among data.  This is represent by link which can be viewed as pointer.  There are three components of network models,  Record Type  Data Elements  Link
  • 13. Cont….  This paradigm is an expansion of the hierarchical model. It was the most prevalent model prior to the relational model.  The main difference between this model and the hierarchical approach is that a record can have several parents.  It replaces the hierarchical tree with a graph.  In the sample below, we can see that node student has two parents, CSE Department and Library.  This was not allowed in the hierarchical model.
  • 14. Cont….  Advantages  Easy to access data.  Capability to handle more relationship type.  Data Integrity.  Data Independence. Disadvantages:  System Complexity.  Operational Anomalies.  Structural Independence.
  • 15. Hierarchical Data Model  A DBMS to the hierarchical data model uses tree structure to relationship among records.  A hierarchical database consist of a collection of records which are connected with each other through link.  Advantages  It is a simple, straight forward and natural method of implementing.  It is a useful when there is some hierarchical character in the database.  Disadvantages:  The hierarchical model cannot represent all the relationship that occurs in the real world.  It cannot represent many to many relationship.  The hierarchical model use only there is a hierarchical character in the consider database.
  • 18. Unit-1: Module-2  Entity Relationship Diagram – ER Diagram in DBMS  An Entity–relationship model (ER model) describes the structure of a database with the help of a diagram, which is known as Entity Relationship Diagram (ER Diagram).  An ER model is a design or blueprint of a database that can later be implemented as a database.  The main components of E-R model are: Entity set and Relationship set.  An ER diagram shows the relationship among entity sets.  An entity set is a group of similar entities and these entities can have attributes.  In terms of DBMS, an entity is a table or attribute of a table in database.  ER diagram shows the complete logical structure of a database.
  • 19. Example of E-R diagram  Here are the geometric shapes and their meaning in an E-R Diagram.  Rectangle: Represents Entity sets. Ellipses: Attributes Diamonds: Relationship Set Lines: They link attributes to Entity Sets and Entity sets to Relationship Set Double Ellipses: Multivalued Attributes Dashed Ellipses: Derived Attributes Double Rectangles: Weak Entity Sets Double Lines: Total participation of an entity in a relationship set 
  • 20. Components of a ER Diagram  ER diagram has three main components: 1. Entity 2. Attribute 3. Relationship  Entity : An entity is an object or component of data.  An entity is represented as rectangle in an ER diagram.  In the following ER diagram we have two entities  Student and College and these two entities have many to one relationship
  • 21. Cont….  Weak Entity: An entity that cannot be uniquely identified by its own attributes and relies on the relationship with other entity is called weak entity.  The weak entity is represented by a double rectangle. A bank account cannot be uniquely identified without knowing the bank to which the account belongs, so bank account is a weak entity.
  • 22. Cont…  Attribute : An attribute describes the property of an entity. An attribute is represented as oval in an ER diagram. There are four types of attributes:  Key attribute  Composite attribute  Multivalued attribute  Derived attribute  Key attribute: A key attribute can uniquely identify an entity from an entity set • Student roll number can uniquely identify a student from a set of students. • Key attribute is represented by oval same as other attributes. • However the text of key attribute is underlined.
  • 23. Cont….  Composite attribute: An attribute that is a combination of other attributes is known as composite attribute.  In student entity, the student address is a composite attribute as an address is composed of other attributes such as pin code, state, country.  Multivalued attribute: An attribute that can hold multiple values is known as multivalued attribute.  It is represented with double ovals in an ER Diagram.  Example: A person can have more than one phone numbers.
  • 24. Cont…  A derived attribute is one whose value is dynamic and derived from another attribute.  It is represented by dashed oval in an ER Diagram. (Previous diagram)  Example – Person age is a derived attribute as it changes over time and can be derived from another attribute (Date of birth).
  • 25. Relationship  A relationship is represented by diamond shape in ER diagram.  It shows the relationship among entities.  There are four types of relationships: 1. One to One 2. One to Many 3. Many to One 4. Many to Many  One to One: When a single instance of an entity is associated with a single instance of another entity then it is called one to one relationship.  Example, a person has only one passport and a passport is given to one person.
  • 26. Cont…  One to Many: When a single instance of an entity is associated with more than one instances of another entity then it is called one to many relationship.  Example – a customer can place many orders but a order cannot be placed by many customers.  Many to One: When more than one instances of an entity is associated with a single instance of another entity then it is called many to one relationship.  Example – many students can study in a single college but a student cannot study in many colleges at the same time.
  • 27. Cont…  Many to Many: When more than one instances of an entity is associated with more than one instances of another entity then it is called many to many relationship.  Example, a student can be assigned to many projects and a project can be assigned to many students.
  • 28. Total Participation of an Entity set  Total participation of an entity set represents that each entity in entity set must have at least one relationship in a relationship set.  It is also called mandatory participation.  Example: In the following diagram each college must have at-least one associated Student.  Total participation is represented using a double line between the entity set and relationship set.
  • 29. DBMS Schema  DBMS Schema Definition of schema: Design of a database is called the schema. For example: An employee table in database exists with the following attributes: EMP_NAME EMP_ID EMP_ADDRESS EMP_CONTACT -------- ------ ----------- ----------- This is the schema of the employee table. Schema defines the attributes of tables in the database. Schema is of three types: Physical schema, logical schema and view schema.
  • 30. DBMS Instance  Definition of instance: The data stored in database at a particular moment of time is called instance of database.  Database schema defines the attributes in tables that belong to a particular database.  The value of these attributes at a moment of time is called the instance of that database.  EMP_NAME EMP_ID EMP_ADDRESS EMP_CONTACT  ------- ------ ----------- -----------  Chaitanya 101 Noida 95********  Ajeet 102 Delhi 99********
  • 31. Elements of Object oriented data model  Objects  The real world entities and situations are represented as objects in the Object oriented database model.  Attributes and Method  Every object has certain characteristics. These are represented using Attributes. The behaviour of the objects is represented using Methods.  Class  Similar attributes and methods are grouped together using a class. An object can be called as an instance of the class.  Inheritance  A new class can be derived from the original class. The derived class contains attributes and methods of the original class as well as its own.
  • 32. Integrity Constraints  Integrity constraints are a set of rules. It is used to maintain the quality of information.  Integrity constraints ensure that the data insertion, updating, and other processes have to be performed in such a way that data integrity is not affected.  Thus, integrity constraint is used to guard against accidental damage to the database.  Types of constraints  NOT NULL  UNIQUE  DEFAULT  CHECK  Key Constraints – PRIMARY KEY, FOREIGN KEY  Domain constraints
  • 33. Unit-2: Module-1  Introduction to SQL: Structured Query Language, popularly known as SQL is a domain specific language used to manage data in relational database management systems (RDBMS).  It allows the user to perform operations such as create, delete etc. on tables in database  It also allows operations such as read, insert, update, delete etc. on the data stored in the tables.  All popular database management softwares such as MySQL, PostgreSQL, Oracle, Microsoft Access, IDBM Db2, SQLite etc. use SQL to manage the database.  SQL is a simple English like language which is used to query the database to perform various operations on the database.
  • 34. Characteristics of SQL  Only use lowercase letters, numbers and underscores for database, schema, column and table name.  Use simple & meaningful, table and column name.  This is because sometimes, we refer the attribute of a table from another table as foreign key.  SQL is not a case sensitive language, however the keywords used in the SQL query are generally written in uppercase.  Using SQL queries you can perform various operations on the database.
  • 35. SQL Processing  When a SQL statement executes, system first performs various checks such as syntax check, semantic check, shared pool check on the SQL query during parsing phase.  In the second phase, which is also known as hard parsing phase, system performs query optimization and generate various execution plans.  In the next phase, row source generator software receives the optimal execution plan and generate a iterative plan that is used by the database.  Last step is execution of the query based on the iterative plan generated in the previous step.
  • 36. Introduction to SQL Data Types and Literals  Each column in a database table is required to have a name and a data type.  An SQL developer must decide what type of data that will be stored inside each column when creating a table.  The data type is a guideline for SQL to understand what type of data is expected inside of each column, and it also identifies how SQL will interact with the stored data.  While creating a database table in a database, we need to specify following two attributes to define a table column:  Name of the column  Data type of the column
  • 37. Cont…  SQL Data types are defined during the creation of a table in a database.  While creating a table, it is required to specify its respective data type and size along with the name of the column.  Syntax to specify a data type in MySQL −  CREATE TABLE table_name(column1 datatype, column2 datatype....)  Example query below to understand better.  CREATE TABLE Customers (Name VARCHAR (25), Age INT);  In the above SQL query, we are creating a table Customers.  And since the Name column only stores string values, we are specifying its data type as "VARCHAR".  The VARCHAR data type represents string values in SQL.  Similarly, we define the Age column with the integer data type, "INT".
  • 38. Types of SQL Data Types  String  Numeric  Date and Time  MySQL Data Types  There are three main data types available in MySQL Database: string, numeric, and date and time.  MySQL - String Data Types  Data type with Description  CHAR(size) A fixed length string which can have letters, numbers, and special characters. The size parameter specifies the column length in characters which can vary from from 0 to 255. Default size is 1  VARCHAR(size)A variable length string which can contain letters, numbers, and special characters. The size parameter specifies the maximum string length in characters which can vary from 0 to 65535.  BINARY(size) This is equal to CHAR(), but stores binary byte strings. The size parameter specifies the column length in bytes. Default size is 1  VARBINARY(size) This is equal to VARCHAR(), but stores binary byte strings. The size parameter specifies the maximum column length in bytes.  TINYTEXT This holds a string with a maximum length of 255 characters  TEXT(size)This holds a string with a maximum length of 65,535 bytes  LONGTEXT This holds a string with a maximum length of 4,294,967,295 characters
  • 39. MySQL - Date and Time Data Types  Data type with Description  DATE A date in YYYY-MM-DD format, between 1000-01-01 and 9999-12-31. For example, December 30th, 1973 would be stored as 1973-12-30.  DATETIME A date and time combination in YYYY-MM-DD HH:MM:SS format, between 1000-01- 01 00:00:00 and 9999-12-31 23:59:59. For example, 3:30 in the afternoon on December 30th, 1973 would be stored as 1973-12-30 15:30:00.  TIMESTAMP A timestamp between midnight, January 1st, 1970 and sometime in 2037. This looks like the previous DATETIME format, only without the hyphens between numbers; 3:30 in the afternoon on December 30th, 1973 would be stored as 19731230153000 ( YYYYMMDDHHMMSS ).  TIME Stores the time in a HH:MM:SS format.  YEAR(M) Stores a year in a 2-digit or a 4-digit format. If the length is specified as 2 (for example YEAR(2)), YEAR can be between 1970 to 2069 (70 to 69). If the length is specified as 4, then YEAR can be 1901 to 2155. The default length is 4.
  • 40. SQL commands  SQL commands are instructions to the database to perform a specific operation.  For example, you can use SELECT command to read the data from database, you can use UPDATE command to update data in database.  There are several commands that are available in SQL for various type of tasks and these commands are divided in following categories: 1. DDL (Data Definition Language) – Commands such as CREATE, DROP, ALTER. 2. DML (Data Manipulation Language) – Commands such as INSERT, UPDATE, DELETE. 3. DCL (Data Control Language) – Commands such as GRANT, REVOKE. 4. TCL (Transaction Control Language) – Commands such as COMMIT, ROLLBACK. 5. DQL (Data Query Language) – Commands such as SELECT.
  • 41. DDL (Data Definition Language)  1. DDL (Data Definition Language)  DDL commands are used to create, drop and alter the databases, aliases, indexes, tables etc.  Once a DDL statement is executed, it takes effect immediately in the database. Which means any changes done to the database using DDL command is permanent.  Popular DDL commands are: CREATE, DROP, ALTER and TRUNCATE.  a) CREATE: This command is used to create database and tables inside a database.  Syntax for creating database:  CREATE DATABASE database_name;  Syntax for creating table:  CREATE TABLE table_name (  column1 datatype,  column2 datatype,  column3 datatype,  ....  );  Desc table name;
  • 42. Examples  CREATE TABLE CUSTOMERS(  ID INT NOT NULL,  NAME VARCHAR (20) NOT NULL,  AGE INT NOT NULL,  ADDRESS CHAR (25),  SALARY DECIMAL (18, 2),  PRIMARY KEY (ID)  ); Field Type Null Key Default Extra ID int(11) NO PRI NULL NAME varchar( 20) NO NULL AGE int(11) NO NULL ADDRESS char(25) YES NULL SALARY decimal( 18,2) YES NULL
  • 43. Cont…  DROP: This command is used to drop database and tables.  Syntax for dropping database:  DROP DATABASE database_name;  Syntax for dropping table:  DROP TABLE table_name;  ALTER: This command is used to add, delete, or modify columns in an existing table.  Syntax: To add a new column in the existing table  ALTER TABLE table_name  ADD column_name datatype;  Example: The following ALTER TABLE statement will add a new column Address to the existing table Employees.  ALTER TABLE EMPLOYEES  ADD Address VARCHAR2(200);
  • 44. Cont….  TRUNCATE: This statement deletes all the rows from the table.  This is different from the DROP command, the DROP command deletes the entire table along with the table schema,  However TRUNCATE just delete all the rows and leaves an empty table.  Syntax:  TRUNCATE TABLE table_name;  Example: Deletes all the rows from the table Employees.  TRUNCATE TABLE EMPLOYEES;
  • 45. DML (Data Manipulation Language)  SQL commands that deals with the manipulation of data comes under DML category.  The popular commands that come under DML are:  INSERT − Insert data into a table.  UPDATE − Update existing data in the specified table.  DELETE − Delete records from the specified table in database.  a) INSERT: This command is used to insert records in a table  Syntax: When you are not inserting the data for all the columns and leaving some columns empty. In that case specify the column name and corresponding value.  INSERT INTO table_name (column1, column2, column3, ...)  VALUES (value1, value2, value3, ...);  Syntax: When inserting the data for all the columns. No need to specify column name.  INSERT INTO table_name  VALUES (value1, value2, value3, ...);
  • 46. Cont….  INSERT INTO EMPLOYEE (name, age) VALUES ("Chaitanya", "35");  UPDATE: This is used to modify the existing records in a table.  Syntax:  UPDATE table_name  SET column1 = value1, column2 = value2, ...  WHERE condition;  Example: Updating the name and city of the employee with employee id “101”. This will search all the records in the table where Employee_id is equal to 101 then it will update the name field to “Mukesh” and city field to “Nashik” for all the filtered records.  UPDATE EMPLOYEE  SET name = ‘Mukesh', city = ‘Nashik'  WHERE Employee_id = 101;
  • 47. Cont…  DELETE: It is used to delete the existing records from the table.  Syntax:  DELETE FROM table_name WHERE condition;  Example: The following SQL query will delete all the rows from the table Employees where name is equal to “Mukesh".  DELETE FROM EMPLOYEES  WHERE name=“Mukesh";
  • 48. DCL (Data Control Language)  DCL commands are used to set permissions on the table.  This is the command that is responsible for the security of database. By setting up the permission, user can prevent un-authorised access to the database.  DCL commands are:  GRANT  REVOKE  a) Grant: It is used to give user access privileges to a database.  Example: The following command will grant users USER1 & USER2, the select, update and delete access to the table TABLE1 .  GRANT SELECT, UPDATE, DELETE ON TABLE1 TO USER1, USER2;  b) Revoke: It revokes the given access to the user.  Example: Let’s revoke the access from USER1 & USER2 given above using GRANT command.  REVOKE SELECT, UPDATE, DELETE ON TABLE1 FROM USER1, USER2;
  • 49. TCL (Transaction Control Language)  The purpose of TCL commands is to maintain the consistency of the database. These commands are generally used along with the DML commands such as INSERT, UPDATE and DELETE.  The changes made by DML commands are either committed or rolled back by TCL commands. There is another TCL command that can place a save point in the transactions which makes it possible to rollback all the transaction till the last save point.  TCL commands are:  COMMIT  ROLLBACK  SAVEPOINT  a) Commit: Commit command make the changes made to the database permanent.  Syntax:  COMMIT;  Example: The following update command changes the name in the STUDENT table from “Harilal" to “Hiralal". By using COMMIT just after the update statement save these changes permanently in the table.
  • 50. Cont….  UPDATE STUDENT  SET NAME = ‘Hiralal’  WHERE NAME = ‘Harilal’;  COMMIT;  b) Rollback: Rollback command is used to undo the changes that have been made to the database temporarily. The important point to note here is that the changes saved using COMMIT command cannot be undone using ROLLBACK command.  Syntax:  ROLLBACK;  Example: The following commands would have deleted all the students from the STUDENT table who have age greater than 15. Since we have used the ROLLBACK command after the DELETE statement, these changes were undone and no record deleted from the table.  The important point to note here is that DELETE and ROLLBACK are two different commands, they are not written together. To understand this, let’s say the user mistakenly written the following DELETE command but as soon as he realises his mistake, he use ROLLBACK command to undo the changes that were made unintentionally.  DELETE FROM STUDENT  WHERE AGE > 30;  ROLLBACK;
  • 51. Cont…  SAVEPOINT: This command helps in roll backing the transactions till a certain point.  For example, a transaction consists of several DML commands and we want to undo the changes till a certain point and not completely, this can be achieved by using SAVEPOINT.  Syntax:  SAVEPOINT SAVEPOINT_NAME;
  • 52. SQL Operators  SQL Arithmetic Operators: +,-,*,/,%  SQL Bitwise Operators: &, |, ^  SQL Comparison Operators: =,>,<,…  SQL Compound Operators: +=,-=,*=,/=,…  SQL Logical Operators: AND,OR, Like,….  Examples: SELECT 30 + 20; output: 50  SELECT * FROM Products WHERE Price >= 30;  SELECT * FROM Customers  WHERE City = “Nashik" AND Country = “India";
  • 53. SET Operations in SQL  SQL supports few Set operations which can be performed on the table data.  These are used to get meaningful results from data stored in the table, under different special conditions.  4 different types of SET operations, along with examples: 1. UNION 2. UNION ALL 3. INTERSECT 4. MINUS SELECT * FROM First 1 x UNION 2 y SELECT * FROM Second;
  • 54. Cont…  UNION ALL  This operation is similar to Union. But it also shows the duplicate rows.  SELECT * FROM First  UNION ALL  SELECT * FROM Second; ID NAME  1 Rabi  2 Akash  2 Akash  3 Sarat
  • 55. INTERSECT  Intersect operation is used to combine two SELECT statements, but it only retuns the records which are common from both SELECT statements. In case of Intersect the number of columns and datatype must be same.  NOTE: MySQL does not support INTERSECT operator.  SELECT * FROM First  INTERSECT  SELECT * FROM Second; Akash
  • 56. MINUS  The Minus operation combines results of two SELECT statements and return only those in the final result, which belongs to the first set of the result.  SELECT * FROM First  MINUS  SELECT * FROM Second; Rabi
  • 57. Introduction to MongoDB  MongoDB is an open source, document oriented database that stores data in form of documents (key and value pairs).  That document based databases are one of types of NoSQL databases.  MongoDB was created by Eliot and Dwight (founders of DoubleClick) in 2007, when they faced scalability issues while working with relational database.  The organization that developed MongoDB was originally known as 10gen.
  • 59. Cont…  MongoDB provides high performance.  Most of the operations in the MongoDB are faster compared to relational databases. MongoDB provides auto replication feature that allows you to quickly recover data in case of a failure.  Horizontal scaling is possible in MongoDB because of sharing.  Sharding is partitioning of data and placing it on multiple machines in such a way that the order of the data is preserved.  Horizontal scaling vs vertical scaling:  Vertical scaling means adding more resources to the existing machine while horizontal scaling means adding more machines to handle the data.  Vertical scaling is not that easy to implement, on the other hand horizontal scaling is easy to implement.  Horizontal scaling database examples: MongoDB, Cassandra etc.
  • 60. Cont….  Load balancing:  Horizontal scaling allows MongoDB to balanace the load.  High Availabilty:  Auto Replication improves the availability of MongoDB database.  Indexing:  Index is a single field within the document.  Indexes are used to quickly locate data without having to search every document in a MongoDB database.  This improves the performance of operations performed on the MongoDB database.
  • 61. Codd's 12 Rules  Dr Edgar F. Codd, after his extensive research on the Relational Model of database systems, came up with twelve rules of his own, which according to him, a database must obey in order to be regarded as a true relational database.  Rule 1: Information Rule  The data stored in a database, may it be user data or metadata, must be a value of some table cell. Everything in a database must be stored in a table format.  Rule 2: Guaranteed Access Rule  Every single data element (value) is guaranteed to be accessible logically with a combination of table-name, primary-key (row value), and attribute-name (column value). No other means, such as pointers, can be used to access data.  Rule 3: Systematic Treatment of NULL Values  The NULL values in a database must be given a systematic and uniform treatment. This is a very important rule because a NULL can be interpreted as one the following − data is missing, data is not known, or data is not applicable.
  • 62. Cont…  Rule 4: Active Online Catalog  The structure description of the entire database must be stored in an online catalog, known as data dictionary, which can be accessed by authorized users. Users can use the same query language to access the catalog which they use to access the database itself.  Rule 5: Comprehensive Data Sub-Language Rule  A database can only be accessed using a language having linear syntax that supports data definition, data manipulation, and transaction management operations. This language can be used directly or by means of some application. If the database allows access to data without any help of this language, then it is considered as a violation.  Rule 6: View Updating Rule  All the views of a database, which can theoretically be updated, must also be updatable by the system.
  • 63. Cont…  Rule 7: High-Level Insert, Update, and Delete Rule  A database must support high-level insertion, updataion, and deletion. This must not be limited to a single row, that is, it must also support union, intersection and minus operations to yield sets of data records.  Rule 8: Physical Data Independence  The data stored in a database must be independent of the applications that access the database. Any change in the physical structure of a database must not have any impact on how the data is being accessed by external applications.  Rule 9: Logical Data Independence  The logical data in a database must be independent of its user’s view (application). Any change in logical data must not affect the applications using it. For example, if two tables are merged or one is split into two different tables, there should be no impact or change on the user application. This is one of the most difficult rule to apply.
  • 64. Cont…  Rule 10: Integrity Independence  A database must be independent of the application that uses it. All its integrity constraints can be independently modified without the need of any change in the application. This rule makes a database independent of the front-end application and its interface.  Rule 11: Distribution Independence  The end-user must not be able to see that the data is distributed over various locations. Users should always get the impression that the data is located at one site only. This rule has been regarded as the foundation of distributed database systems.  Rule 12: Non-Subversion Rule  If a system has an interface that provides access to low-level records, then the interface must not be able to subvert the system and bypass security and integrity constraints.