0% found this document useful (0 votes)
26 views17 pages

Unit 3

This document provides an overview of database concepts, including the definition and functions of Database Management Systems (DBMS), characteristics of databases, and types of data independence. It discusses various database architectures (1-tier, 2-tier, 3-tier) and models (Hierarchical, Network, E/R, Relational), along with key attributes and relationships in databases. Additionally, it explains different types of keys, including primary, foreign, and composite keys, essential for maintaining data integrity and relationships between tables.

Uploaded by

vasanikevin730
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)
26 views17 pages

Unit 3

This document provides an overview of database concepts, including the definition and functions of Database Management Systems (DBMS), characteristics of databases, and types of data independence. It discusses various database architectures (1-tier, 2-tier, 3-tier) and models (Hierarchical, Network, E/R, Relational), along with key attributes and relationships in databases. Additionally, it explains different types of keys, including primary, foreign, and composite keys, essential for maintaining data integrity and relationships between tables.

Uploaded by

vasanikevin730
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/ 17

UNIT-3: Concepts of Database

• 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.
• 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.
• It provides protection and security to the database. In the case of multiple
users, it also maintains data consistency.

3.1 Database characteristics:


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

3.1.1 Data Independence (Logical and Physical)


Data Independence is defined as a property of DBMS that helps you to change
the Database schema at one level of a database system without requiring to
change the schema at the next higher level. Data independence helps you to
keep data separated from all programs that make use of it.

You can use this stored data for computing and presentation. In many systems,
data independence is an essential function for components of the system.

Types of Data Independence


In DBMS there are two types of data independence
1. Physical data independence
2. Logical data independence.
UNIT-3: Concepts of Database

3.1.2 Components of Database (User, Application, DBMS,


Database)

3.1.3 Database Architecture (1-tier, 2-tier, 3-tier)


• The DBMS design depends upon its architecture. The basic client/server
architecture is used to deal with a large number of PCs, web servers,
database servers and other components that are connected with networks.
• The client/server architecture consists of many PCs and a workstation
which are connected via the network.
• DBMS architecture depends upon how users are connected to the database
to get their request done.

1-Tier Architecture

• In this architecture, the database is directly available to the user. It means


the user can directly sit on the DBMS and uses it.
• Any changes done here will directly be done on the database itself. It
doesn't provide a handy tool for end users.
• The 1-Tier architecture is used for development of the local application,
where programmers can directly communicate with the database for the
quick response.
UNIT-3: Concepts of Database

2-Tier Architecture

• The 2-Tier architecture is same as basic client-server. In the two-tier


architecture, applications on the client end can directly communicate with
the database at the server side. For this interaction, API's
like: ODBC, JDBC are used.
• The user interfaces and application programs are run on the client-side.
• The server side is responsible to provide the functionalities like: query
processing and transaction management.
• To communicate with the DBMS, client-side application establishes a
connection with the server side.

Fig: 2-tier Architecture

3-Tier Architecture

• The 3-Tier architecture contains another layer between the client and
server. In this architecture, client can't directly communicate with the
server.
• The application on the client-end interacts with an application server which
further communicates with the database system.
UNIT-3: Concepts of Database

• End user has no idea about the existence of the database beyond the
application server. The database also has no idea about any other user
beyond the application.
• The 3-Tier architecture is used in case of large web application.

Fig: 3-tier Architecture

S.NO Two-Tier Database Architecture Three-Tier Database Architecture


1 It is a Client-Server Architecture. It is a Web-based application.

In two-tier, the application logic is In three-tier, the application logic or


either buried inside the user process resides in the middle-tier, it is
interface on the client or within the separated from the data and the user
2 database on the server (or both). interface.

Two-tier architecture consists of Three-tier architecture consists of three


two layers : Client Tier and layers : Client Layer, Business Layer
3 Database (Data Tier). and Data Layer.
UNIT-3: Concepts of Database

4 It is easy to build and maintain. It is complex to build and maintain.

5 Two-tier architecture runs slower. Three-tier architecture runs faster.

It is less secured as client can


communicate with database It is secured as client is not allowed to
6 directly. communicate with database directly.

It results in performance loss whenever


It results in performance loss the system is run on Internet but gives
whenever the users increase more performance than two-tier
7 rapidly. architecture.

Example – Contact Management


System created using MS-Access Example – Designing registration form
or Railway Reservation System, which contains text box, label, button or
8 etc. a large website on the Internet, etc.

3.2 Database Models (Hierarchical, Network,


E/R, Relational)
A Database model defines the logical design and structure of a database and
defines how data will be stored, accessed and updated in a database
management system.

Hierarchical Model

• This database model organises data into a tree-like-structure, with a


single root, to which all the other data is linked. The heirarchy starts
from the Root data, and expands like a tree, adding child nodes to the
parent nodes.
• In this model, a child node will only have a single parent node.
• This model efficiently describes many real-world relationships like index
of a book, recipes etc.
• In hierarchical model, data is organised into tree-like structure with one
one-to-many relationship between two different types of data, for
UNIT-3: Concepts of Database

example, one department can have many courses, many professors and
of-course many students.

Network Model

• This is an extension of the Hierarchical model. In this model data is


organised more like a graph, and are allowed to have more than one
parent node.
• In this database model data is more related as more relationships are
established in this database model. Also, as the data is more related,
hence accessing the data is also easier and fast. This database model was
used to map many-to-many data relationships.
UNIT-3: Concepts of Database

3.2.1 E/R model: Entity, Relationship, Attribute


• In this database model, relationships are created by dividing object of
interest into entity and its characteristics into attributes.
• Different entities are related using relationships.
• E-R Models are defined to represent the relationships into pictorial form
to make it easier for different stakeholders to understand.
• This model is good to design a database, which can then be turned into
tables in relational model(explained below).
• Let's take an example, If we have to design a School Database,
then Student will be an entity with attributes name, age, address etc.
As Address is generally complex, it can be
another entity with attributes street name, pincode, city etc, and there
will be a relationship between them.
UNIT-3: Concepts of Database

• Entity − An entity in an ER Model is a real-world entity having properties


called attributes. Every attribute is defined by its set of values
called domain. For example, in a school database, a student is considered
as an entity. Student has various attributes like name, age, class, etc.
• Relationship − The logical association among entities is
called relationship. Relationships are mapped with entities in various
ways. Mapping cardinalities define the number of association between
two entities.

3.2.2 E/R Diagram: One to one, one to many, many to one,


many to many
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
UNIT-3: Concepts of Database

3. Many to One
4. Many to Many

1. One to One Relationship

When a single instance of an entity is associated with a single instance of


another entity then it is called one to one relationship. For example, a person
has only one passport and a passport is given to one person.

2. One to Many Relationship

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. For example – a
customer can place many orders but a order cannot be placed by many
customers.

3. Many to One Relationship


UNIT-3: Concepts of Database

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. For example – many
students can study in a single college but a student cannot study in many
colleges at the same time.

4. Many to Many Relationship

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. For
example, a can be assigned to many projects and a project can be assigned to
many students.

3.2.3 Strong entity, weak entity


Strong Entity:
• A strong entity is not dependent on any other entity in the schema. A
strong entity will always have a primary key. Strong entities are
represented by a single rectangle. The relationship of two strong entities
is represented by a single diamond.
• Various strong entities, when combined together, create a strong entity
set.

Weak Entity:
• A weak entity is dependent on a strong entity to ensure its existence.
Unlike a strong entity, a weak entity does not have any primary key. It
instead has a partial discriminator key. A weak entity is represented by a
double rectangle.
• The relation between one strong and one weak entity is represented by a
double diamond.
UNIT-3: Concepts of Database

S.NO Strong Entity Weak Entity


Strong entity always has a While a weak entity has a partial
1. primary key. discriminator key.
Strong entity is not dependent
2. on any other entity. Weak entity depends on strong entity.
Strong entity is represented Weak entity is represented by a double
3. by a single rectangle. rectangle.
Two strong entity’s While the relation between one strong
relationship is represented by and one weak entity is represented by a
4. a single diamond. double diamond.
Strong entities have either While weak entity always has total
5. total participation or not. participation.

3.2.4 key attribute, derived attribute, Multi-valued


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:

1. Key attribute
2. Composite attribute
3. Multivalued attribute
4. Derived attribute

1. Key attribute:
UNIT-3: Concepts of Database

A key attribute can uniquely identify an entity from an entity set. For example,
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.

2. Composite attribute:

An attribute that is a combination of other attributes is known as composite


attribute. For example, In student entity, the student address is a composite
attribute as an address is composed of other attributes such as pin code, state,
country.

3. Multivalued attribute:
UNIT-3: Concepts of Database

An attribute that can hold multiple values is known as multivalued attribute. It


is represented with double ovals in an ER Diagram. For example – A person can
have more than one phone numbers so the phone number attribute is
multivalued.

4. Derived attribute:

A derived attribute is one whose value is dynamic and derived from another
attribute. It is represented by dashed oval in an ER Diagram. For example –
Person age is a derived attribute as it changes over time and can be derived from
another attribute (Date of birth).

E-R diagram with multivalued and derived attributes:

3.3 Types of keys:


3.3.1 Super key, candidate key, Primary key, Composite key,
Foreign key, Unique key.

• KEYS in DBMS is an attribute or set of attributes which helps you to


identify a row(tuple) in a relation(table).
• They allow you to find the relation between two tables.
• Keys help you uniquely identify a row in a table by a combination of one
or more columns in that table.
• Key is also helpful for finding unique record or row from the table.
• Database key is also helpful for finding unique record or row from the
table.
UNIT-3: Concepts of Database

What is the Super key?


A superkey is a group of single or multiple keys which identifies rows in a table.
A Super key may have additional attributes that are not needed for unique
identification.

Example:

EmpSSN EmpNum Empname


9812345098 AB05 Shown
9876512345 AB06 Roslyn
199937890 AB07 James

In the above-given example, EmpSSN and EmpNum name are superkeys.

What is a Primary Key?


PRIMARY KEY in DBMS is a column or group of columns in a table that uniquely
identify every row in that table. The Primary Key can’t be a duplicate meaning
the same value can’t appear more than once in the table. A table cannot have
more than one primary key.
Rules for defining Primary key:

• Two rows can’t have the same primary key value


• It must for every row to have a primary key value.
• The primary key field cannot be null.
• The value in a primary key column can never be modified or updated if
any foreign key refers to that primary key.

Example:

In the following example, <code>StudID</code> is a Primary Key.

StudID Roll No First Name LastName Email


1 11 Tom Price [email protected]
2 12 Nick Wright [email protected]
3 13 Dana Natan [email protected]
UNIT-3: Concepts of Database

What is a Candidate Key?


CANDIDATE KEY in SQL is a set of attributes that uniquely identify tuples in a
table. Candidate Key is a super key with no repeated attributes. The Primary key
should be selected from the candidate keys. Every table must have at least a
single candidate key. A table can have multiple candidate keys but only a single
primary key.
Properties of Candidate key:

• It must contain unique values


• Candidate key in SQL may have multiple attributes
• Must not contain null values
• It should contain minimum fields to ensure uniqueness
• Uniquely identify each record in a table

Candidate key Example: In the given table Stud ID, Roll No, and email are
candidate keys which help us to uniquely identify the student record in the table.

StudID Roll No First Name LastName Email


1 11 Tom Price [email protected]
2 12 Nick Wright [email protected]
3 13 Dana Natan [email protected]

Candidate Key in DBMS

What is the Foreign key?


FOREIGN KEY is a column that creates a relationship between two tables. The
purpose of Foreign keys is to maintain data integrity and allow navigation
between two different instances of an entity. It acts as a cross-reference
between two tables as it references the primary key of another table.
UNIT-3: Concepts of Database

Example:

DeptCode DeptName
001 Science
002 English
005 Computer
Teacher ID Fname Lname
B002 David Warner
B017 Sara Joseph
B009 Mike Brunton

• In this key in dbms example, we have two table, teach and department in
a school. However, there is no way to see which search work in which
department.
• In this table, adding the foreign key in Deptcode to the Teacher name, we
can create a relationship between the two tables.

Teacher ID DeptCode Fname Lname


B002 002 David Warner
B017 002 Sara Joseph
B009 001 Mike Brunton

This concept is also known as Referential Integrity.

What is the Composite key?


A composite key is the DBMS key having two or more attributes that together
can uniquely identify a tuple in a table. Such a key is also known as Compound
Key, where each attribute creating a key is a foreign key in its own right.
UNIT-3: Concepts of Database

What is the Unique key?


• A unique key is a set of one or more than one fields/columns of a table
that uniquely identify a record in a database table.
• You can say that it is little like primary key but it can accept only one null
value and it cannot have duplicate values.
• The unique key and primary key both provide a guarantee for uniqueness
for a column or a set of columns.
• There is an automatically defined unique key constraint within a primary
key constraint.

You might also like