0% found this document useful (0 votes)
10 views36 pages

DBMS Unit 1 Complete Notes

The document provides an overview of Database Management Systems (DBMS), covering their definitions, applications, advantages, and disadvantages. It discusses the structure of DBMS, including components like storage managers and query processors, as well as levels of data abstraction and data models. Additionally, it outlines SQL commands for data definition and manipulation.

Uploaded by

funnyanimals2314
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views36 pages

DBMS Unit 1 Complete Notes

The document provides an overview of Database Management Systems (DBMS), covering their definitions, applications, advantages, and disadvantages. It discusses the structure of DBMS, including components like storage managers and query processors, as well as levels of data abstraction and data models. Additionally, it outlines SQL commands for data definition and manipulation.

Uploaded by

funnyanimals2314
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Database Management Systems

CONTENTS:

1. INTRODUCTION: introduction to database management systems,


2. database system applications,
3. database systems versus file systems,
4. view of data, ,
5. Database users and administrators,
6. database system structure.
7. SQL - PART I: database languages- DDL , DML, DCL and TCL commands

INTRODUCTION:

• Data: Data represents known facts or raw information in unorganized form (such as
alphabets or numbers or symbols ) .

• Database: Database is a organized collection of data describing the activities of one or


more related organizations.

• Database management system(DBMS) is a software designed to assist in storing,


maintaining and utilizing large collections of data.

or

A database-management system (DBMS) is a computer-software application which interacts with


end-users, other applications, and the database itself to access,update,manage and analyze data
with the help of set of application programs.

RDBMS (relational database management system) applications store data in a tabular form and
relation exist among the tables. while DBMS applications stores data in tables but there will be
no “relation” between the tables, like in a RDBMS

Database Applications
1. Banking: all transactions
2. Airlines: reservations, schedules
3. Universities: registration, grades
4. Sales: customers, products, purchases
5. Online retailers: order tracking, customized recommendations
6. Manufacturing: production, inventory, orders, supply chain
7. Human resources: employee records, salaries, tax deductions
8. Databases touch all aspects of our lives

1
Database Management Systems

Disadvantages of file system or drawbacks of using file systems/conventional/ traditional file


systems to store data:
 Data redundancy and inconsistency
 Multiple file formats, duplication of information in different files
 Difficulty in accessing data
 Need to write a new program to carry out each new task
 Data isolation — multiple files and formats
 Integrity problems
 Integrity constraints (e.g. account balance > 0) become
“buried” in program code rather than being stated explicitly
 Hard to add new constraints or change existing ones
 Atomicity of updates
 Failures may leave database in an inconsistent state with partial updates carried out
Example: Transfer of funds from one account to another should either complete or not
happen at all
 Concurrent access by multiple users
Concurrent accessed needed for performance
Uncontrolled concurrent accesses can lead to inconsistencies
Example: Two people reading a balance and updating it at the same time
 Security problems
 Hard to provide user access to some, but not all, data
 Database systems offer solutions to all the above problems

2
Database Management Systems

Advantages of database management systems

 Program-Data independence
 Data Independence
 Efficient data access
 Data integrity and security
 Data administration
 Concurrent access and crash recovery
 Reduced application development time
 Centralized control of data(data ownership)
 Data redundancy eliminated
 Data can be shared
 Improved data consistency
 Improved data integrity
 Improved data accessibility and response
 Reduced program maintenance
 Improved security for data
 Multiple access of data
 Protection from failure

3
Database Management Systems

Disadvantages of DBMS
 Higher cost -More sophisticated hardware and software, higher operating cost
 Greater complexity
 Backup/recovery procedures complex
 DBMS occupy more memory space
 Application need to process large amount of data

Database users
o Application Programmers – queries+C ,C++,java
o Sophisticated users-SQL select/create/update/insert etc
o Specialized users – complex programs
o Stand-alone users-
o Native Users -

Database Administrator[DBA] responsibilities


 Creates and maintains database
 Create schema, subschema of database
 Define storage structure and access methods
 Responsible for schema and physical organization modifications
 Grants authorization for data access. Regulates who can access which part of database
 Responsible for
-database backup
-database recovery
-disk space management
-performance monitoring
 Responsible for procedures for database integrity and security

4
Database Management Systems

Levels of Abstraction

VIEWS OF DATA

Major purpose of database system is to provide users with an abstract view of data
The system hide certain details of how the data are stored and maintained

Abstraction: Hiding unnecessary details and showing only essentials.


Developers hide the complexity from users through several levels of abstraction
Dbms hides from user details of how data stored in database and how data is retrieved
3 levels of abstraction
1. Physical level
2. Logical level
3. View Level

Physical level
• Lowest level of abstraction
• About how data is stored
• Low level data structures , data storage
• Handled by DBMS
Logical level
• Describe what data is stored and what relationship exist among the data
• Logical data structure
• Independent of any particular technology
• Handled by DBA
View level
• Highest level of abstraction
• Describes only part of database

5
Database Management Systems

• Independent of DBMS technology


• Required for the user to do his work
• Simplifies user’s interaction with database
• Defined in programming language terms

Instance & schema


Instance:
• The collection data stored in a database at a particular movement is called data base.
• Database instance change over time as data is inserted/ deleted / modified
Schema
• The overall design of database is called the data schema
• Declaration of variable –Schema
• Value of the variable - Instance

The database have several schemas


 physical schema: describe database design at physical level
 Logical schema: describe the database design at logical level
Subschema: A data base may have several schemas at view level sometimes called subschema

Data independence:

Data Independence – The ability to modify a schema definition in one level with out affecting a
schema definition in next higher level is called data independence.

1. Physical data independence: The ability to modify the physical schema without
changing logical schema
2. Logical data independence: The ability to modify the logical or conceptual schema
without changing application programs

In general, the interfaces between the various levels and components should be well defined so
that changes in some parts do not seriously influence others

6
Database Management Systems

Data models
 The structure of a database is data model

 A collection of conceptual tools describing the data


 A data model is the underlying structure of database
 Data model is a collection of conceptual tools for describing data, data relationship, data
semantics and data constraints
 Various data models that have been processed fall into three different groups

Two different groups


• Object –based logical model
• Record based logical model
Object based logical model
• The models are describing at logical and view levels
– Entity- relationship model
– Object oriented model
• While object –based logical models describes data in terms of entities and relationship
among entities
• record based logical model are concerned with how these entities and relationships have
to be represented in the database system
Record based logical model
• Hierarchical model
• Network model
• Relational model

Hierarchical Model
• Data represented by a collection of records and relationships among data represented by
links
• Records are organized as a collection of trees
• Some data redundancy can be avoided
• Complex data structures are need
• Can not be possible to represent many-to-many relationship
• Data represented in parent –child relationship
• One –to many relationship can easily represented
• Eg: IMS (information management system)
• RAMIS- rapid access management information system

Network model
• Data represented by collection of records and relationship among the data represented
by links
• Records are organized into a collection of graphs
• Data redundancy is minimum
• High degree of complexity
• Represented many –to – many & one- many relation ship

7
Database Management Systems

• Relation ship among the data are represented by links


• It is represented by graphs & more complex
• Eg: Integrated database management system
• ADABAS- Adaptable database system

Relational models
 Relational model proposed by Dr.E.F.Codd in 1976
 The relational model uses a collection of tables.
 Data represented in the form of tables(relations)
 Tables are logically equivalent to files and consists of rows
 Rows called tuples
 Rows have fixed number of columns called attributes

Relational database
• Any database for which the logical organization is based on relational data models
• RDBMS: A DBMS that manages the relational database
• An RDBMS is a type of DBMS that stores data in the form of related tables
• The relational model expresses the data and relationship among the data in the form of
TABLES.
• Relational Data Model was first proposed by Ted Codd of IBM in the 1970s
• The database is a set of related relations (table of values).
• Each relation has a name which indicates what type of tuples the relation has. For
example, a relation named ‘Student’ indicates that it has student entities in it.
Each relation has a set of attributes (column names) which represents, what type of
information, the entities or tuples have?
• A tuple (row) in a relation, is a real-world entity, it has a set of values for corresponding
attributes.
Each data value in a row or tuple is called field.

8
Database Management Systems

DBMS SYSTEM STRUCTURE:

DATABASE SYSTEM STRUCTURE

A Database system is partitioned into modules that deal with each of the responsibilities of the
overall system.

The functional components of a database system can be broadly divided into:


 storage manager and
 query processor components.

Storage Manager
A storage manager is a program module that provides the interface between the low level data
stored in the database and the application programs and queries submitted to the system. The
storage manager is responsible for the interaction with the file manager. The raw data are stored
on the disk using the file system, which is usually provided by a conventional operating system.

9
Database Management Systems

The storage manager translates the various DML statements into low level file system
commands. Thus, the storage manager is responsible for storing, retrieving and updating data in
the database.
The storage manager components include:
 Authorization and integrity manager
Which tests for the satisfaction of integrity constraints and checks the authority of users to
access data.
 Transaction manager
Which ensures that the database remains in a consistent correct) state despite system failures,
and that concurrent transaction executions proceed without conflicting.
 File Manager
Which manages the allocation of space on disk storage and the data structures used to represent
information stored on disk.
 Buffer manager
Which is responsible for fetching data from disk storage into main memory, and deciding what
data to cache in main memory. The buffer manager is a critical part of the database system,
since it enables the database to handle data sizes that are much larger than the size of main
memory.
The storage manager implements several data structures as part of the physical system
implementation:
 Data files, which store the database itself.
 Data dictionary, which stores metadata about the structure of the database, in particular
the schema of the database.
 Indices, which provide fast access to data items that hold particular values.

The Query Processor


The query processor components include
 DDL interpreter, which interprets DDL statements and records the definitions in the data
dictionary.
 DML compiler, which translates DML statements in a query language into an evaluation
plan consisting of low level instructions that the query evaluation engine understands.

A query can usually be translated into any of a number of alternative evaluation plans that all
give the same result. The DML compiler also performs query optimization, that is it picks the
lowest cost evaluation plan from among the alternatives.
o Query evaluation engine, which executes low level instructions generated by the
DML compiler.

10
Database Management Systems

11
Database Management Systems

Data Definition Language (DDL) Commands


COMMAND : CREATE
This command is used to create the structure of database

Syntax :
Create table <table name > ( column_name1 type(size), Column_name2 type(size), …);
Example

COMMAND :ALTER
This command is used to add a column or to increase the size of the column

Syntax:
alter table <table name> add/modify (column data type(size));
Example

COMMAND: DROP
This command is used to delete the table from database.

12
Database Management Systems

Syntax:
drop table <tablename>; Example

COMMAND :TRUNCATE
This command is used delete the rows but structure remains

Syntax:
truncate table <table name>; example

Data manipulation commands (DML) commands:

COMMAND :INSERT
Inserting a single row into a table

Syntax:
insert into <table name> values (value list);
SQL> insert into s values(‘s3’,’sup3’,’blore’,10)

Inserting more than one record using a single insert commands:


INPUT:
SQL> insert into emp
Values(&empno,'&ename','&job','&mgr','&hirdate',&sal,'&comm',&deptno,'&empgen');
Enter value for empno: 23
Enter value for ename: aaa
Enter value for job: clerk
Enter value for mgr: 45
Enter value for hirdate: 12-dec-89
Enter value for sal: 5000
Enter value for comm: 20
Enter value for deptno: 30
Enter value for empgen: m
old 1: insert into emp
values(&empno,'&ename','&job','&mgr','&hirdate',&sal,'&comm',&deptno,'&emp
new 1: insert into emp values(23,'aaa','clerk','45','12-dec-89',5000,'20',30,'m')

1 row created.

SQL> /
Enter value for empno: 24
Enter value for ename: bbb
Enter value for job: manager
Enter value for mgr: 46
Enter value for hirdate: 13-jan-89
Enter value for sal: 6000

13
Database Management Systems

Enter value for comm: 60


Enter value for deptno: 20
Enter value for empgen: female
old 1: insert into emp
values(&empno,'&ename','&job','&mgr','&hirdate',&sal,'&comm',&deptno,'&emp
new 1: insert into emp values(24,'bbb','manager','46','13-jan-89',6000,'60',20,'female')

1 row created.

OUTPUT:
emp table
EMPNO ENAME JOB MGR HIREDATE SAL COMM. DEPTNO
----------- ------------ ---------------- -------- ----------------------- ------- ------------ --------------
7369 SMITH CLERK 7902 17 – DEC – 80 800 20
7499 ALLEN SALESMAN 7698 20 – FEB – 81 1600 300 30
7521 WARD SALESMAN 7698 22 – FEB – 81 1250 500 30
7566 JONES MANAGER 7839 02 – APR – 81 2975 20
7654 MARTIN SALESMAN 7698 28 – SEP – 81 1250 1400 30
7698 BLAKE MANAGER 7839 01 – MAY – 81 2850 30
7782 CLARK MANAGER 7839 09 – JUN – 81 2450 10
7788 SCOTT ANALYST 7566 19 – APR – 87 3000 20
7839 KING PRESIDENT 17 – NOV – 81 5000 10
7844 TURNER SALESMAN 7698 08 – SEP – 81 1500 0 30
7876 ADAMS CLERK 7788 23 - MAY – 87 1100 20
7900 JAMES CLERK 7698 03 – DEC – 81 950 30
7902 FORD ANALYST 7566 03 – DEC – 81 3000 20
7934 MILLER CLERK 7782 23 – JAN – 82 1300 10

Skipping the fields while inserting


Syntax:
insert into <tablename>(coln names to which data to be inserted)> values (list of values);
Other way is to give null while passing the values

COMMAND : SELECT
To retrieve all rows from a table

Syntax:
SQL>Select * from table name;

INPUT:
SQL>Select * from emp;

OUTPUT:
EMPNO ENAME JOB MGR HIREDATE SAL COMM. DEPTNO
14
Database Management Systems

----------- ------------ ---------------- -------- ----------------------- ------- ------------ --------------


7369 SMITH CLERK 7902 17 – DEC – 80 800 20
7499 ALLEN SALESMAN 7698 20 – FEB – 81 1600 300 30
7521 WARD SALESMAN 7698 22 – FEB – 81 1250 500 30
7566 JONES MANAGER 7839 02 – APR – 81 2975 20
7654 MARTIN SALESMAN 7698 28 – SEP – 81 1250 1400 30
7698 BLAKE MANAGER 7839 01 – MAY – 81 2850 30
7782 CLARK MANAGER 7839 09 – JUN – 81 2450 10
7788 SCOTT ANALYST 7566 19 – APR – 87 3000 20
7839 KING PRESIDENT 17 – NOV – 81 5000 10
7844 TURNER SALESMAN 7698 08 – SEP – 81 1500 0 30
7876 ADAMS CLERK 7788 23 - MAY – 87 1100 20

To retrieve specific columns from a table


Syntax:
Select column_name1, …..,column_namen from table name;

INPUT:
SQL> select ename, deptno, sal from emp;

OUTPUT:
ENAME DEPTNO SAL
---------- ------- ------- ------
adams 20 1100
allen 30 1600
blake 30 2850
clark 10 2450
ford 20 3000
james 30 950
jones 20 2975

KEYWORD : DISTINCT
Elimination of duplicates from the select clause: It prevents retrieving the duplicated values.
Distinct keyword is to be used.

Syntax:
SQL>Select DISTINCT col1, col2 from table name;

INPUT:
SQL>select distinct job from emp;

OUTPUT:
JOB
------
15
Database Management Systems

CLERK
SALESMAN
MANAGER
ANALYST
PRESIDENT

To select specific rows from a table we include ‘where’ clause in the select command. It can
appear only after the ‘from’ clause
Syntax:
Select column_name1, …..,column_name from table name where condition;

INPUT:
SQL> select ename, job from emp where job = 'manager';
OUTPUT:
ENAME JOB
---------- ---------
jones manager
blake manager
clark manager

COMMAND: UPDATE
To modify column or group of columns
Syntax:
update <tablename> set field=values where condition;

INPUT:
SQL>update std set branch='mca' where sno=03;
1 row updated.
sql> select * from std;

OUTPUT:
SNO SNAME BRANCH
---------- ---------- ----------
1 ram B.Tech
2 ravi B.Tech
3 krish mca
4 rfde B.Tech

COMMAND :DELETE
The command is used to delete the rows in a table
Syntax:
Delete from <table_name> where conditions;

16
Database Management Systems

INPUT:
SQL> delete from emp where empno=7369;

DATA CONTROL LANGUAGE (DCL) COMMANDS IN RDBMS

COMMAND : COMMIT

Syntax:
commit [work] [comment 'comment_text']
commit [work] [force 'force_text' [,int] ]

INPUT:
SQL>commit;

OUTPUT:
Commit complete;
COMMAND : ROLLBACK
The ROLLBACK command is the transactional control command to undo the transactions that
have not already been committed to the database. The ROLLBACK command can be issued to
undo the changes since the last COMMIT or ROLLBACK.

Syntax:
ROLLBACK [WORK] [TO [SAVEPOINT]'savepoint_text_identifier'];
ROLLBACK [WORK] [FORCE 'force_text'];

INPUT:
SQL>rollback;

OUTPUT:
Rollback complete;

17
Database Management Systems

INTEGRITY CONSTRAINTS
data integrity refers to maintaining and assuring the accuracy and consistency of data over its
entire life-cycle. Integrity constraints are used to ensure accuracy and consistency of data in a
relational database.

TYPES OF INTEGRITY CONSTRAINTS

Various types of integrity constraints are-

• Domain Integrity

• Entity Integrity Constraint

• Key Constraints

• Referential Integrity Constraint

Domain Integrity-

• Domain integrity means the definition of a valid set of values for an attribute.

18
Database Management Systems

• You define data type, length or size, It also allows null value. It is the value unique or not
for an attribute ,the default value, the range (values in between) and/or specific values
for the attribute

Entity Integrity Constraint-

• This rule states that in any database relation value of attribute of a primary key can't be
null.

Key Constraints

• An attribute or set of attributes that uniquely identifies rows in a table is called as Key

• Constraints can be defined in two ways

• 1.column-level
The constraints can be specified immediately after the column definition. This is called
column-level definition.

• 2. Table-level
The constraints can be specified after all the columns are defined. This is called table-
level definition

Not Null Constraint

 By default, all columns in a table allow nulls.

 Null means the absence of a value.

 A NOT NULL constraint requires a column of a table contain no null values

 Syntax :

[CONSTRAINT constraint name] NOT NULL

Example:

CREATE TABLE employee


( id number(5),
name char(20) CONSTRAINT nm_nn NOT NULL,
dept char(10),
age number(2),
salary number(10),
location char(10)

19
Database Management Systems

);

Unique Key

 A UNIQUE key integrity constraint requires that every value in a column or set of columns
(key) be unique--that is, no two rows of a table have duplicate values in a specified
column or set of columns

 A column(s) can have a null value but the values cannot be duplicated

Column level:

Syntax

[CONSTRAINT constraint_name] UNIQUE

Table level:

Syntax

[CONSTRAINT constraint_name] UNIQUE(column_name)

Example:

CREATE TABLE employee


( id number(5) PRIMARY KEY,
name char(20),
dept char(10),
age number(2),
salary number(10),
location char(10) UNIQUE
);

or

CREATE TABLE employee


( id number(5) PRIMARY KEY,
name char(20),
dept char(10),
age number(2),
salary number(10),
location char(10) CONSTRAINT loc_un UNIQUE

20
Database Management Systems

);

table level:

CREATE TABLE employee


( id number(5) PRIMARY KEY,
name char(20),
dept char(10),
age number(2),
salary number(10),
location char(10),
CONSTRAINT loc_un UNIQUE(location)
);

Primary key

 An attribute or a set of attributes which uniquely identify an entity

 No two rows of a table have duplicate values in the specified column or set of columns.

 The primary key columns do not allow nulls. That is, a value must exist for the primary
key columns in each row.

 Each table have at most only one primary key

 Syntax:

 [CONSTRAINT constraint_name] PRIMARY KEY (column_name1,column_name2,..)

 Note: The syntax within the bracket i.e. [CONSTRAINT constraint_name] is optional

 column level

CREATE TABLE employee


( id number(5) PRIMARY KEY,
name char(20),
dept char(10),
age number(2),
salary number(10),
location char(10)

);

CREATE TABLE employee

21
Database Management Systems

( id number(5) CONSTRAINT emp_id_pk PRIMARY KEY,


name char(20),
dept char(10),
age number(2),
salary number(10),
location char(10)
);

Table level:

CREATE TABLE employee


( id number(5),
name char(20),
dept char(10),
age number(2),
salary number(10),
location char(10),
CONSTRAINT emp_id_pk PRIMARY KEY (id)
);

• CREATE TABLE employee


( id number(5), NOT NULL,
name char(20),
dept char(10),
age number(2),
salary number(10),
location char(10),
ALTER TABLE employee ADD CONSTRAINT PK_EMPLOYEE_ID PRIMARY KEY (id)
);

 A primary key can consist of one or more fields on a table.

composite primary key:

 When multiple fields are used as a primary key, they are called a composite primary key.

Foreign key or Referential Integrity

 Foreign key is the key i.e. attribute which refers to another table primary key.

 Reference key is the primary key of table referred by another table.

22
Database Management Systems

 Foreign keys help you create logical ties within the information in a database

Foreign Key at column level:

 CREATE TABLE product


( product_id number(5) CONSTRAINT pd_id_pk PRIMARY KEY,
product_name char(20),
supplier_name char(20),
unit_price number(10)
);

 CREATE TABLE order_items


( order_id number(5) CONSTRAINT od_id_pk PRIMARY KEY,
product_id number(5) CONSTRAINT pd_id_fk REFERENCES, product(product_id),
product_name char(20),
supplier_name char(20),
unit_price number(10)
);

Foreign Key at table level:

CREATE TABLE order_items


( order_id number(5) ,
product_id number(5),
product_name char(20),
supplier_name char(20),
unit_price number(10)
CONSTRAINT od_id_pk PRIMARY KEY(order_id),
CONSTRAINT pd_id_fk FOREIGN KEY(product_id) REFERENCES product(product_id)
);

check constraint

 It specifies a range of values with in which the attribute should take

 It allows you to specify a condition on each row in a table

 A check constraint can be defined in either an SQL CREATE TABLE statement or an SQL
ALTER TABLE statement.

Syntax:

23
Database Management Systems

 CREATE TABLE table_name ( column1 datatype null/not null, column2 datatype null/not
null, ... CONSTRAINT constraint_name CHECK (column_name condition) [DISABLE] );

Example:

 CREATE TABLE suppliers ( supplier_id numeric(4), supplier_name varchar2(50),


CONSTRAINT check_supplier_id CHECK (supplier_id BETWEEN 100 and 9999) );

Alter command to add a constraint

• ALTER TABLE Persons ADD PRIMARY KEY (ID);

• ALTER TABLE Persons ADD CONSTRAINT PK_Person PRIMARY KEY (ID,LastName);

DROP Constraint

• ALTER TABLE Persons DROP CONSTRAINT PK_Person;

ALTER TABLE Persons DROP PRIMARY KEY

24
DATABASE DESIGN
Topics
 Introduction to database design
 Entities, Attributes And Entity Sets
 Relationships And Relationship Sets
 Additional features of the E-R model
 Conceptual design with the E-R model
 Conceptual design for large enterprises

1. DATABASE DESIGN
The database design process can be divided into six steps. The ER model is most relevant
to the first three steps. Those six steps are-
i. Requirement Analysis
ii. Conceptual Database Design
iii. Logical Database Design
iv. Schema Refinement
v. Physical Database Design
vi. Application and Security Design
i. Requirements Analysis:

 This is the first step in designing any database application.


 This is an informal process that involves discussions and studies and analyzing the
expectations of the users & the intended uses of the database.
 Under this, we have to understand the following.
a) What data is to be stored n a database?
b) What applications must be built?
c) What operations can be used?
d) What the users want from the database.

Example: For customer database, data is customer name, customer city, and customer
no.

ii. Conceptual database design:

 The information gathered in the requirements analysis step is used to develop a higher-
level description of the data.
 The goal of conceptual database design is a complete understanding of the database
structure, meaning (semantics), inter-relationships and constraints. This step is often
carried out using the ER model, or a similar high-level data model.
iii. Logical Database Design:

 Under this convert the conceptual database design into a database schema, we must
choose a DBMS to implement our database design.

Beyond ER Design
 Once we have logical schema, we must consider performance criteria and design the
physical schema. Finally, we must address security issues and ensure that users are able
to access the data they need, but not data that we wish to hide from them.
iv. Schema Refinement:

 Under this, we have to analyze the collection of relations (tables) in our relational
database schema to identify the potential problems and to refine (clear) it.

v. Physical Database Design:

 Physical database design is the process of choosing specific storage structures and
access paths for the database files to achieve good performance for the various database
applications.
 This step involves building indexes on some tables and clustering some tables.
vi. Security Design:

 In this step, we must identify different user groups and different roles played by various
users.
 For each role, and user group, we must identify the parts of the database that they must
be able to access, which are as below.

The ER model is widely used to develop an initial data base design. ER model describes the
physical database model; it is basically useful in the design & communication of the logical
database model.

2. Entities, Attributes And Entity Sets :


ENTITY
 An entity is an object that is distinguishable from other objects by a set of attributes.
 This is the basic object of E-R Model, which is a 'thing' in the real world with an
independent existence.
 An entity may be an 'object' with a physical existence.
 Consists of a collection of objects.
 Entities can be represented by 'Ellipses'.
Example: Customer, account etc.

ENTITY SET:-
 An entity set is a collection of similar entities (or) an entity set is a group of similar
objects.
 Example: all customers, all account details

ATTRIBUTES
 Characteristics of an entity are called as an attribute.
 The properties of a particular entity are called as attributes of that specified entity.
 Example:
 Name, street address, city --- customer database.
 Acc-no, balance --- account database.
TYPES OF ATTRIBUTES:
These can be classified into following types.

 Simple Attributes.
 Descriptive attribute
 Composite Attributes.
 Single Valued Attributes.
 Mutivalued Attributes.
 Derived Attributes.

a) Simple Attributes:

 The attributes that are not divisible are called as 'simple or atomic attributes'.
 Example: cust_name, acc_no
b) Composite Attributes:

 The attributes that can be divided into smaller subparts, which represent more basic
attributes with independent meaning.
 These are useful to model situations in which a user sometimes refers to the composite
attribute as unit but at other times refers specifically to its components.

Example: Street_address can be divided into 3 simple attributes as Number, Street and
Apartment_no.

Street_address

City State Zip

c) Single Valued Attribute:

 The attributes having a single value for a particular entity are called as 'Single Valued
Attributes'.
 Example: 'adaar number ' is a single valued attribute of 'Person'.

d) Muti Valued Attribute:

 The attributes, which are having a set of values for the same entity, are called as 'Multi
Valued Attributes'.
 Example: A 'College Degree' attribute for a person.i.e, one person may not have a
college degree, another person may have one and a third person may have 2 or more
degrees.

e) Derived Attributes:

 An attribute which is derived from another attribute is called as a ‘derived attribute.


 Example: ‘Age’ attribute is derived from another attribute ‘Date’.
f) Descriptive attribute:

 Descriptive attributes are used to record information about relationship, rather than about
any one of the participating entities.
 Examples: since is an attribute in works in relationship capture the information about
participating entities employee & departments.

since

employee Works company

h) Null Attribute:-
 It is an attribute that uses a null value when an entity does not have a value for an
attribute.
Relationship & Relationship Set
 A relationship is an association among two or more entities
 A relationship set is a set of relationships of the same type. A relationship set can be
thought of as a set of n- tuples
f(e1; : : : ; en) j e1 2 E1; : : : ; en 2 Eng
 Each n-tuple denotes a relationship involving n entities e1 through en, where entity ei
is in entity set Ei. we show the relationship set Works

since

employee Works company

Fig:- Works in relation ship


Fig:- An instance of works in relationship

The symbols that can be used in this model are as follows.

 Rectangles Entities.

 Ellipses Attributes.
 Lines Links.
 Diamonds Relationships.

 Under Lined Ellipse Primary key.

Doubled Lined Ellipse Multi Valued Attribute.

Dashed Ellipse Derived Attributes.

Double Lined Rectangle Weak Entity Set.

Dno
Name Street Since Dname
City
Budget

Customer Works_in Departments


Instance:

 An instance of a relationship set is a set of relationships.


 It is a snapshot of the relationship at some instant of time.
EX:
1111 1/1/91 60

2222 2/2/94 70
3333
3/3/96

Mapping Cardinalities:- Mapping cardinalities, or cardinality ratios, express the number of


entities to which another entity can be associated via a relationship set. These are categorized
into 4 types.

1. Many to Many:
An employee is allowed to work in different departments and a department is allowed
to have several employees.

Street Dno
Name City Since Dname
Budget

Works_in Departments
employee
2. One to Many: 1 employee can be associated with many departments, where as each
department can be associated with at most 1 employee as its manager.

Name Since Dno


Street Dname
City
Budget

employee
Works_in Departments
3.Many to One: Each employee works in at most 1 department.i.e, many employees can work
in same department.

Dno
Name Street Since Dname
City
Budget

employee Works_in Departments

4.One to One: Each employee can manage at most 1 department.

Dno
Name Street Since Dname
City
Budget

employee Works_in Departments

Role: We indicate roles in E-R diagrams by labeling the lines that connect diamonds to
rectangles.

Role indicator - If an entity set plays more than one role, role indicators describe the different
purpose in the relationship.

Here an example is a single Employee entity set with a relation Reports-To that relates
supervisors and subordinates. Here the emp1,emp2 are entities of employee .
3. ADDITIONAL FEATURES OF THE E-R MODEL

3.1. Key Constraints:

 A key is a set of attributes for one entity set such that no two entities in this set agree
on all the attributes of the key.

 Sometimes, an additional constraint exists for a given relationship set. For example,
consider a relationship set "Manages" which associates departments with employees. If
a department cannot have more than one manager, this is an example of a one-to-many
relationship set. This type of constraint is called a key constraint.
 It is represented in the ER diagrams by drawing an arrow from an entity set E to a
relationship set R when each entity in an instance of E appears in at most one
relationship in (a corresponding instance of) R.

3.2 Participation Constraints:


 The participation constraint specifies whether the existence of an entity depends on its
being related to another entity via the relationship type.
 A department has at most one manager. This requirement is an example of participation
constraints.
 There are 2 types of participation constraints, which are as below.
1.Total.

2.Partial.

3.2.1. Total: An entity set dependent on a relationship set and having one to many
relationships is said to be ‘total’. The participation of the entity set ‘departments’ in the
relationship set ‘manages’ is said to be total.

3.2.2.Partial: A participation that is not total is said to be partial.


Example: Participation of the entity set ‘employees’ in ‘manages’ is partial, since not every
employee gets to manage a department.
 In E-R diagram, the total participation is displayed as a ‘double line’ connecting the
participating entity type to the relationship, where as partial participation is represented
by a single line.
 If the participation of an entity set in a relationship set is total, then a thick line connects
the two.
 The presence of an arrow indicates a key constraint.

No
Name
Dname Budget

Partial Participation

Employees Manages
Department
Works_in

You might also like