0% found this document useful (0 votes)
24 views

Notes

Uploaded by

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

Notes

Uploaded by

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

DATABASE APPLICATIONS

UNIT 1
DATA IN FORMATION AND INFORMATION PROCESSING
INTRODUCTION:
Data processing means to process the data i.e. to convert its format. As we all know data is
the very useful and when it is well presented and it becomes informative + useful. Data
processing system is also referred as information system. It is also right to say that data
processing becomes the process of converting information into data and also vice-versa.

In simple words, data processing can be expressed as :


 Process of conversion of data in the computer understandable format.
 The sorting or processing of data by a computer.
Types of data processing :
Data processing is broadly divides into two categories : Business, Scientific, and Real time
Data Processing. These are explained as following below.
1. Business Data Processing :
The process of data in the accounting or business management referred as business or
administrative data processing. In this type of data processing, data is usually in the
numeric form. It refers to the all the computing functions that occur in an enterprise. The
computer that is oriented towards business data processing will demand for high speed
input and output so that conversion of stored data into report format can occur easily.
2. Scientific Data Processing :
Data processing in scientific and engineering problems is termed as scientific data
processing. Basically, it is the application of computer simulation and other forms of
computation to problems in various scientific disciplines. It is characterized by relatively
little input and output but extensive internal computation. It emphasize on high speed
internal processing but may have limited input and output capabilities.
3. Real time Data Processing :
There are many types of large applications that may require the real time data processing.
In this, the result is presented at the same time when the data enters. We can easily analyze
this type of data processing in the stock market and currency trends. The technology which
is mostly used in real time data processing is stream processing.
Advantages of Data Processing :
 Highly efficient
 Time-saving
 High speed
 Reduces errors
Disadvantages of Data Processing :
 Large power consumption
 Occupies large memory
 The cost of installation is high
 Wastage of memory

DEFINITION OF INFORMATION
What is information?
Information is stimuli that has meaning in some context for its receiver. When information is
entered into and stored in a computer, it is generally referred to as data. After processing --
such as formatting and printing -- output data can again be perceived as information. When
information is compiled or used to better understand something or to do something, it
becomes knowledge.

The data-information-knowledge-wisdom model illustrates this hierarchy. Structured as a


pyramid, the model was created to show that data can be captured in different formats,
analyzed and converted into different forms. Each level of the pyramid represents a different
perspective or level of abstraction as follows:

 The discrete, raw facts about a given situation with no analysis or interpretation applied.
 Applying description and meaning to data to make it useful.
 Information that has insight, context and a frame of reference applied so it can be
interpreted.
 Knowledge is converted into wisdom by applying judgment and action to the information.
QUALITY OF INFORMATION

Quality of information is an important concept. Information quality is a multi-attribute


concept. If the attributes that define quality of information are of good quality or of high
value then the information is said to have good quality. The attributes of quality of
information are:

1. Timeliness- The speed at which the information is received. Normally, faster the


information better is its quality.
2. Appropriateness- is the suitability matching of the receiver and the information, more
the suitability of the information to the receiver, better its quality.
3. Reliability – the reliability of information is a key attribute of quality. Only if the
information is reliable is it of any use. The understanding of reliability comes from past
experience, the standing/reliability of the source, the methodology adopted to acquire
and process the information and the channel of delivery.
4. Accuracy – is the correctness of the information. Normally, the higher the accuracy of
the information, the better is its quality.
5. Completeness – is the measure of comprehensiveness. It is required to ensure that the
information provided gives the complete picture of reality and not a part of the picture.
6. These attributes define the quality of information. A high score on each of the attributes
indicate that the quality of information is good.

Information Processing :

What is Information Processing?

In cognitive psychology, information processing is described as an approach taken to


understand human thinking in terms of how it can process the same type of information as
computers. It puts its onus on specific aspects of memory retrieval and encoding and
discusses the various mechanisms via which learning occurs

The term information processing is applied to computer-based operations. It refers to a


process where the digitalized information is manipulated by a digital electronic machine, for
instance, a computer. The information processing system includes

 Business software
 Computers
 Operating systems
 Mainframes
 Networks

 Whenever the information and data need to be managed or transferred, the method is then
known as information processing. The processor first processes the information and later
provides understandable results.

1. Accurate

If the information is accurate, it will have a direct impact on the decision-making process.
Hence it is essential to remove any possibility of errors

2. Timely

The information must be available as per the need of the hour because a delay in obtaining it
can make the information useless
3. Complete

The information has no meaning until and unless it is finished because incomplete data and
information can lead to incorrect results

4. Comprehensive

Only comprehensive information is useful, and if it is not so then it is considered useless for
the receiver and thus has no real meaning and worth The concept of information processing
has been in existence for a very long time. Governments and business entities used to process
a large amount of information from the gathered data.

In the current scenario, the capability to process information has reached new heights and
gigantic proportions. It is possible to process trillions of bytes every minute by an equal
number of devices, satellites and software applications.

DBMS Tutorial provides basic and advanced concepts of Database. Our DBMS Tutorial is
designed for beginners and professionals both.

Database management system is software that is used to manage the database.

Our DBMS Tutorial includes all topics of DBMS such as introduction, ER model, keys,


relational model, join operation, SQL, functional dependency, transaction, concurrency
control, etc.

What is Database

The database is a collection of inter-related data which is used to retrieve, insert and delete the
data efficiently. It is also used to organize the data in the form of a table, schema, views, and
reports, etc.

For example: The college Database organizes the data about the admin, staff, students and
faculty etc.

Using the database, you can easily retrieve, insert, and delete the information.

Database Management System


o Database management system is a software which is used to manage the database. For
example: MySQL, Oracle, etc are a very popular commercial database which is used in
different applications.
o DBMS provides an interface to perform various operations like database creation,
storing data in it, updating data, creating a table in the database and a lot more.
o It provides protection and security to the database. In the case of multiple users, it also
maintains data consistency.

DBMS allows users the following tasks:

o Data Definition: It is used for creation, modification, and removal of definition that
defines the organization of data in the database.
o Data Updation: It is used for the insertion, modification, and deletion of the actual
data in the database.
o Data Retrieval: It is used to retrieve the data from the database which can be used by
applications for various purposes.
o User Administration: It is used for registering and monitoring users, maintain data
integrity, enforcing data security, dealing with concurrency control, monitoring
performance and recovering information corrupted by unexpected failure.

Characteristics of DBMS
o It uses a digital repository established on a server to store and manage the information.
o It can provide a clear and logical view of the process that manipulates data.
o DBMS contains automatic backup and recovery procedures.
o It contains ACID properties which maintain data in a healthy state in case of failure.
o It can reduce the complex relationship between data.
o It is used to support manipulation and processing of data.
o It is used to provide security of data.
o It can view the database from different viewpoints according to the requirements of the
user.

Advantages of DBMS
o Controls database redundancy: It can control data redundancy because it stores all
the data in one single database file and that recorded data is placed in the database.
o Data sharing: In DBMS, the authorized users of an organization can share the data
among multiple users.
o Easily Maintenance: It can be easily maintainable due to the centralized nature of the
database system.
o Reduce time: It reduces development time and maintenance need.
o Backup: It provides backup and recovery subsystems which create automatic backup
of data from hardware and software failures and restores the data if required.
o multiple user interface: It provides different types of user interfaces like graphical
user interfaces, application program interfaces

Disadvantages of DBMS
o Cost of Hardware and Software: It requires a high speed of data processor and large
memory size to run DBMS software.
o Size: It occupies a large space of disks and large memory to run them efficiently.
o Complexity: Database system creates additional complexity and requirements.
o Higher impact of failure: Failure is highly impacted the database because in most of
the organization, all the data stored in a single database and if the database is damaged
due to electric failure or database corruption then the data may be lost forever.

Types of Database Management System:

A relational database management system is one of four common types of systems you can
use to manage your business data. The other three include:

 hierarchical database systems


 network database systems
 object-oriented database systems
A hierarchical database model resembles a tree structure, similar to a folder architecture in
your computer system. The relationships between records are pre-defined in a one to one
manner, between 'parent and child' nodes. They require the user to pass a hierarchy in order to
access needed data. Due to limitations, such databases may be confined to specific uses.

The Hierarchical Model was the first database management system model. This concept uses
a hierarchical tree structure to organise the data. The hierarchy begins at the root, which
contains root data, and then grows into a tree as child nodes are added to the parent node.
Network database models also have a hierarchical structure. However, instead of using a
single-parent tree hierarchy, this model supports many to many relationships, as child tables
can have more than one parent.
Relational database models  A relational database is a type of database that stores and
provides access to data points that are related to one another. Relational databases are based
on the relational model, an intuitive, straightforward way of representing data in tables.

Unit -2

1. Data definition:
 A database is an organized collection of structured information, or
data, typically stored electronically in a computer system.
 A database is usually controlled by a database management system
(DBMS).
 A DBMS serves as an interface between the database and its end users
or programs, allowing users to retrieve, update, and manage information
is organized and optimized.

 Database languages can be used to read, store and update the data in the
database.
 Data definition or data description language (DDL) is a syntax for
creating and modifying database
 DDL is used for specifying the database schema.
 It is used for creating tables, schema, indexes, constraints etc. in database
 DDL commands CREATE, DROP,,ALTER,RENAME,TRUNCATE
 DML name of Data Manipulation Language which deals with data
manipulation and includes most common SQL statements such SELECT,
INSERT, UPDATE, DELETE, etc.,
 DML used to store, modify, retrieve, delete and update data in a database.

SQL

 SQL stands for Structured Query Language. It is used for storing and
managing data in relational database management system (RDMS).
 It is a standard language for Relational Database System. It enables a user to
create, read, update and delete relational databases and tables.
 All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server
use SQL as their standard database language.
Characteristics of SQL

o SQL is easy to learn.


o SQL is used to access data from relational database management systems.
o SQL can execute queries against the database.
o SQL is used to describe the data.
o SQL is used to define the data in the database and manipulate it when
needed.
o SQL is used to create and drop the database and table.
o SQL is used to create a view, stored procedure, function in a database.
o SQL allows users to set permissions on tables, procedures, and views.

Types of SQL Commands

There are five types of SQL commands: DDL, DML, DCL, TCL, and DQL.
1. Data Definition Language (DDL)
o DDL changes the structure of the table like creating a table, deleting a table,
altering a table, etc.
o All the command of DDL are auto-committed that means it permanently
save all the changes in the database.

Here are some commands that come under DDL:

o CREATE
o ALTER
o DROP
o RENAME
o TRUNCATE

a. CREATE It is used to create a new table in the database.

Syntax:

1. CREATE TABLE TABLE_NAME (COLUMN_NAME DATATYPES[,....]);

Example:

1. CREATE TABLE EMPLOYEE(Name VARCHAR2(20), Email VARCHAR2(100


), DOB DATE);

b. DROP: It is used to delete both the structure and record stored in the table.

Syntax

1. DROP TABLE table_name;

Example

1. DROP TABLE EMPLOYEE;


c. ALTER: It is used to alter the structure of the database. This change could be
either to modify the characteristics of an existing attribute or probably to add a new
attribute.

Syntax:

To add a new column in the table

1. ALTER TABLE table_name ADD column_name COLUMN-definition;

To modify existing column in the table:

1. ALTER TABLE table_name MODIFY(column_definitions....);

EXAMPLE

1. ALTER TABLE STU_DETAILS ADD(ADDRESS VARCHAR2(20));


2. ALTER TABLE STU_DETAILS MODIFY (NAME VARCHAR2(20));

RENAME COMMAND

 RENAME command is used to rename an object.


 It renames a database table.
Syntax:

RENAME TABLE <old_name> TO <new_name>;

Example:
RENAME TABLE emp TO employee;

TRUNCATE: It is used to delete all the rows from the table and free the space
containing the table.

Syntax:

1. TRUNCATE TABLE table_name;


Example:

1. TRUNCATE TABLE EMPLOYEE;


Data Manipulation Language
o DML commands are used to modify the database. It is responsible for all
form of changes in the database.
o The command of DML is not auto-committed that means it can't
permanently save all the changes in the database. They can be rollback.

o INSERT
o UPDATE
o DELETE

a. INSERT: The INSERT statement is a SQL query. It is used to insert data into
the row of a table.

Syntax:

1. INSERT INTO TABLE_NAME


2. (col1, col2, col3,.....col N)
3. VALUES (value1, value2, value3,.....valueN);

For example:

1. INSERT INTO javatpoint (Author, Subject) VALUES ("Sonoo", "DBMS");

b. UPDATE: This command is used to update or modify the value of a column in


the table.

Syntax:

1. UPDATE table_name SET [column_name1= value1,. column_nameN = valueN] [


WHERE CONDITION]
For example:

1. UPDATE students
2. SET User_Name = 'Sonoo'
3. WHERE Student_Id = '3'

c. DELETE: It is used to remove one or more row from a table.

Syntax:

1. DELETE FROM table_name [WHERE condition];

For example:

1. DELETE FROM javatpoint


2. WHERE Author="Sonoo";
3. Data Control Language

DCL commands are used to grant and take back authority from any database user.

Here are some commands that come under DCL:

o Grant
o Revoke

a. Grant: It is used to give user access privileges to a database.

Example

1. GRANT SELECT, UPDATE ON MY_TABLE TO SOME_USER, ANOTHER_U


SER;

b. Revoke: It is used to take back permissions from the user.

Example

1. REVOKE SELECT, UPDATE ON MY_TABLE FROM USER1, USER2;


4. Transaction Control Language

TCL commands can only use with DML commands like INSERT, DELETE and
UPDATE only.

These operations are automatically committed in the database that's why they
cannot be used while creating tables or dropping them.

Here are some commands that come under TCL:

o COMMIT
o ROLLBACK
o SAVEPOINT

a. Commit: Commit command is used to save all the transactions to the database.

Syntax:

1. COMMIT;

Example:

1. DELETE FROM CUSTOMERS


2. WHERE AGE = 25;
3. COMMIT;

b. Rollback: Rollback command is used to undo transactions that have not already
been saved to the database.

Syntax:

1. ROLLBACK;

Example:

1. DELETE FROM CUSTOMERS


2. WHERE AGE = 25;
3. ROLLBACK;

c. SAVEPOINT: It is used to roll the transaction back to a certain point without


rolling back the entire transaction.

Syntax:

1. SAVEPOINT SAVEPOINT_NAME;
5. Data Query Language

DQL is used to fetch the data from the database.

It uses only one command:

o SELECT

a. SELECT: This is the same as the projection operation of relational algebra. It is


used to select the attribute based on the condition described by WHERE clause.

Syntax:

1. SELECT expressions
2. FROM TABLES
3. WHERE conditions;

For example:

1. SELECT emp_name
2. FROM employee
3. WHERE age > 20;
Basic Structure of SQL Queries

The fundamental structure of SQL queries includes three clauses that are select,
from, and where clause.

 Final result relation is specified in the select clause.


 Relations need to access to get the result is specified in from clause.
 Relation must be operated to get the result is specified in the where clause.
select A1, A2, . . . , An

from r1, r2, . . . , rm

where P;

 In the select clause, specify the attributes in the result relation


 In the from clause, specify the list of relations that has to be accessed
for evaluating the query.
 In the where clause involves a predicate that includes attributes of
the relations listed in the from clause.
Queries on Single Relation

Consider that we have a relation ‘instructor’ with the attributes instr_id, name,
dept_name, and salary.
The SQL query we would structure to get a result relation with instructor’s names
along with their department name.

select name,

from instructor;
dept_name in the above query by default it would have listed names of all the
departments retaining the duplicates. To eliminate the duplicates you can make use
of the distinct keyword.

select distinct dept_name

from instructor;

Arithmetic expression in the select clause using operators such as +, -, *, and /.

select instr_name, salary*0.9

from instructor;
where clause we can make use of logical connectives and, or & not. Along with
these, we can include expressions where we can use comparison operators to
compare operands in the expression

Queries on Multiple Relation

The SQL queries often need to access multiple relations from the data set in
order to get the required result. Let us take an example we have two relations
instructor and department.

Retrieve the names of all the instructors along with their department names and the
corresponding department building. We will get the instructor’s name and
department name in the instructor relation but building name in the department
relation. So the query would be:

select name, instructor.dept_name, building

from instructor, department

where instructor.dept_name= department.dept_name;


SQL Datatype

o SQL Datatype is used to define the values that a column can contain.
o Every column is required to have a name and data type in the database
table.

Datatype of SQL:
SQL Numeric Data Types

Datatyp Fro To
e m
bit 0 1

tinyint 0 255

smallint -32,768 32,767

int -2,147,483,648 2,147,483,647

bigint -9,223,372,036, 9,223,372,036,


854,775,808 854,775,807
decimal -10^38 +1 10^38 -1

numeric -10^38 +1 10^38 -1

float -1.79E + 308 1.79E + 308

real -3.40E + 38 3.40E + 38

SQL Date and Time Data Types

Datatype Descriptio
n
DATE Stores date in the format YYYY-MM-DD

TIME Stores time in the format HH:MI:SS


DATETIM Stores date and time information in the format YYYY-MM-DD
E HH:MI:SS
Stores number of seconds passed since the Unix epoch (‘1970-
TIMESTA
MP 01-01 00:00:00’ UTC)

Stores year in 2 digits or 4 digit format. Range 1901 to 2155 in 4-


YEAR
digit format. Range 70 to 69, representing 1970 to 2069.

SQL Character and String Data Types

Datatype Descriptio
n
CHAR Fixed length with a maximum length of 8,000 characters

VARCHAR Variable-length storage with a maximum length of 8,000


characters
Variable-length storage with provided max characters, not
VARCHAR(m
ax) supported in MySQL

TEXT Variable-length storage with maximum size of 2GB data

SQL Unicode Character and String Data Types

Datatype Descriptio
n
NCHAR Fixed length with maximum length of 4,000 characters

NVARCHAR Variable-length storage with a maximum length of 4,000


characters
NVARCHAR(m Variable-length storage with provided max characters
ax)
NTEXT Variable-length storage with a maximum size of 1GB data

SQL Binary Data Types

Datatype Descriptio
n
BINARY Fixed length with a maximum length of 8,000 bytes

VARBINARY Variable-length storage with a maximum length of 8,000


bytes
VARBINARY(m Variable-length storage with provided max bytes
ax)
IMAGE Variable-length storage with maximum size of 2GB
binary data

SQL Miscellaneous Data Types

Datatyp Descriptio
e n
CLOB Character large objects that can hold up to
2GB
BLOB For binary large objects

XML for storing XML data

JSON for storing JSON data


Database Schema

A database schema is a structure that represents the logical storage of the data in a
database. It represents the organization of data and provides information about the
relationships between the tables in a given database

1. A database schema is the logical representation of a database,


which shows how the data is stored logically in the entire database.
It contains list of attributes and instruction that informs the database
engine that how the data is organized and how the elements are
related to each other.
2. A database schema contains schema objects that may include
tables, fields, packages, views, relationships, primary key, foreign
key,
3. The schema does not physically contain the data itself; instead,
it gives information about the shape of data
4. A database schema object includes the following:
a. Consistent formatting for all data entries.
b. Database objects and unique keys for all data entries.
c. Tables with multiple columns, and each column contains its
name and datatype.
5. The complexity & the size of the schema vary as per the size
of the project. It helps developers to easily manage and
structure the database before coding it.

Types of Database Schema

1. Physical Database Schema


This schema pertains to the actual storage of data and its form of
storage like files, indices, etc. It defines how the data will be
stored in a secondary storage.
2. Logical Database Schema
This schema defines all the logical constraints that need to be
applied on the data stored. It defines tables, views, and integrity
constraints.
3. View Schema
The view level design of a database is known as view
schema. This schema generally describes the end-user
interaction with the database systems.
Built-in Data Types
 Built-in Data types are those data types that are pre-defined by the
programming language
 such Data types are called Built-in Data Types. These data types can be
used directly in the program
 Every programming language has its own specific set of built-in data types
 The term Built-in itself tells us that these categories of data types are defined
by the programming language at prior.
 Built-in Data types are those data types that can be directly used by
the programmer to declare and store different variables in a program.
 They are also called Primary or Primitive Data Types
 The syntax used for defining these data types is different for each
programming language

Real-Time Example of Built-in Data type

 create an automatic exam grading system for the students of a school.


 The data which we require will be Names, Roll numbers, Class, Division,
Subjects, Marks, Grades. This data consists of various categories of data
like Alphabets, Strings, Characters, Integers, Decimal numbers, Symbols,
etc.
 For this purpose, we can use the built-in data types which are provided by
the programming languages.
1. Int
This Built-in data type represents an integer number. It does not support any decimal
or fractional number. Generally, Int has been allocated 4 bytes/32 bits of memory
space. Integer numbers can contain Positive as well as Negative numbers.

Int Data Type is further divided into 2 type –

Signed Int – Allows positive as well as negative numbers.


Unsigned Int – Allows only positive

numbers. Ex:- 29, -50, 1947, 50384

2. Char
This data type accepts character values from the user. These characters include
single letter, digit, symbol, special characters, etc. Char data type occupies 2
bytes/16 bits of memory space.

Ex:- ‘A’, ‘$’, ‘g’, ‘5’


3. Float
Float data type represents numbers that are in decimal format. They are commonly
called floating-point numbers. Float takes up 4 bytes/32 bits of memory space.

Ex:- 25.56, 785.383, -3674.7358, -10

4. Boolean
This data type consists of only 2 values: True or False. It is a logical type of built-in
data type. The default value of Boolean data type is False.

5. Double
It is a variant of the Floating-point data type which is also used to represent
fractional and decimal numbers. Generally, 8 bytes/64 bits of memory space is
allocated to it.

6. Void
This data type is widely used in C and C++ languages. It indicates that it has no
value/empty. This data type is mainly used as a return type for functions that do not
return a value to the caller function.

USERDEFINED DATATYPE:

 User-defined data types are data types based on intrinsic system types given
a name by the user, which may then be used in future DDL statements within
the database where they were created.

 It is particularly useful to create a user-defined data type for a unique key


that has foreign key columns (usually in another table) that refer to it.
Creating a user-defined type and using it for the unique key and foreign key
column definitions ensures that they are the same data type.
The following parts of user-defined data types must be provided when created.

 Name.

 Underlying System Data Type— see Table 2-50.

 Nullability—

Create and Manage a User-Defined Data Type


 Create

1. Expand the console tree to the database in which you want the new type.

2. Right click on User-Defined Types and select New User-Defined Data


Type.

3. Enter the desired values.

 Drop, Copy, Rename, Properties or Generate Script

1. Expand the console tree to the database and User Defined Types.

2. Right click on the user-defined data type and select the operation desired.

Create and Manage a User-Defined Data Type


Four phrases can be used to create and manage a user-defined data type:

 sp_addtype: Creates a user-defined data type in the current database.

 sp_droptype: Deletes a user-defined data type from the current database.

 sp_rename: Changes the name of the user-created object.

 sp_help <typename>: Displays the definition of the user-defined data type (or
system data type).
Integrity Constraints

o Integrity constraints are a set of rules. It is used to maintain the quality of


information.
o 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.
o Thus, integrity constraint is used to guard against accidental damage to the
database.

Types of Integrity Constraint

1. Domain constraints
o Domain constraints can be defined as the definition of a valid set of values
for an attribute.
o The data type of domain includes string, character, integer, time, date,
currency, etc. The value of the attribute must be available in the
corresponding domain.

Example:

2. Entity integrity constraints


o The entity integrity constraint states that primary key value can't be null.
o This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those
rows.
o A table can contain a null value other than the primary key field.

Example:
3. Referential Integrity Constraints

o A referential integrity constraint is specified between two tables.


o In the Referential integrity constraints, if a foreign key in Table 1 refers to
the Primary Key of Table 2, then every value of the Foreign Key in Table 1
must be null or be available in Table 2.

Example:

4. Key constraints
o Keys are the entity set that is used to identify an entity within its entity set
uniquely.
o An entity set can have multiple keys, but out of which one key will be the
primary key. A primary key can contain a unique and null value in the
relational table.
Example:

Large Objects Datatypes


Binary Large Object (BLOB) Stores any kind of data in binary format such as images,
audio, and video.
Character Large Object (CLOB) Stores string data in the database having
character set format. Used for large set of characters/strings or documents that use
the database character.
National Character Large Object (NCLOB) Stores string data in National
Character Set format. Used for large set of characters/strings or documents in the
National Character Set. Supports characters of varying width format.
External Binary File (BFILE) BFILEs can be accessed from your application on a read-only
basis. Use BFILEs to store static data, such as image data, that does
UNIT – 3

ENTITY-RELATIONAL (E-R) MODELING

ER (Entity Relationship) Diagram in DBMS


o ER model stands for an Entity-Relationship model. It is a high-level data
model. This model is used to define the data elements and relationship for
a specified system.
o It develops a conceptual design for the database. It also develops a very
simple and easy to design view of data.
o In ER modeling, the database structure is portrayed as a diagram called
an entity-relationship diagram.

For example, Suppose we design a school database. In this database, the


student will be an entity with attributes like address, name, id, age, etc. The
address can be another entity with attributes like city, street name, pin code, etc
and there will be a relationship between them.
Component of ER Diagram

1. Entity:

An entity may be any object, class, person or place. In the ER diagram, an entity
can be represented as rectangles.

Consider an organization as an example- manager, product, employee,


department etc. can be taken as an entity.

774.4K
67
Java Try Catch
a. Weak Entity

An entity that depends on another entity called a weak entity. The weak entity
doesn't contain any key attribute of its own. The weak entity is represented by a
double rectangle.

2. Attribute

The attribute is used to describe the property of an entity. Eclipse is used to


represent an attribute.

For example, id, age, contact number, name, etc. can be attributes of a student.

a. Key Attribute
The key attribute is used to represent the main characteristics of an entity. It
represents a primary key. The key attribute is represented by an ellipse with the
text underlined.

b. Composite Attribute

An attribute that composed of many other attributes is known as a composite


attribute. The composite attribute is represented by an ellipse, and those ellipses
are connected with an ellipse.

c. Multivalued Attribute
An attribute can have more than one value. These attributes are known as a
multivalued attribute. The double oval is used to represent multivalued attribute.

For example, a student can have more than one phone number.

d. Derived Attribute

An attribute that can be derived from other attribute is known as a derived


attribute. It can be represented by a dashed ellipse.

For example, A person's age changes over time and can be derived from
another attribute like Date of birth.

3. Relationship

A relationship is used to describe the relation between entities. Diamond or


rhombus is used to represent the relationship.
Types of relationship are as follows:

a. One-to-One Relationship

When only one instance of an entity is associated with the relationship, then it is
known as one to one relationship.

For example, A female can marry to one male, and a male can marry to one
female.

b. One-to-many relationship

When only one instance of the entity on the left, and more than one instance of
an entity on the right associates with the relationship then this is known as a
one-to-many relationship.

For example, Scientist can invent many inventions, but the invention is done by
the only specific scientist.
c. Many-to-one relationship

When more than one instance of the entity on the left, and only one instance of
an entity on the right associates with the relationship then it is known as a
many-to-one relationship.

For example, Student enrolls for only one course, but a course can have many
students.

d. Many-to-many relationship

When more than one instance of the entity on the left, and more than one
instance of an entity on the right associates with the relationship then it is
known as a many-to-many relationship.

For example, Employee can assign by many projects and project can have
many employees.

Degree:

Overview. In DBMS, the degree of relationship is the number of entities


that have taken part in the relationship. We can analyze the E-R diagram and
tell the degree of relationship between various entities. The degree of
relationship in DBMS can be categorized as Unary, Binary, Ternary or N-ary
relationship.
Connectivity:

The connectivity of a relationship describes the mapping of associated


entity instances in the relationship. The values of connectivity are “one” or
“many”. The cardinality of a relationship is the actual number of related
occurrences for each of the two entities.

Cardinality:
Cardinality in DBMS is a vital piece of information about a
relation between two entities. Cardinality of a relationship can be
defined as the number of times an entity of an entity set participates
in a relationship set. Cardinality shows how the entities are
connected to each other.
Dependency:
  A dependency is a constraint that governs or defines the
relationship between two or more attributes. In a database, it
happens when information recorded in the same table uniquely
determines other information stored in the same table.

You might also like