0% found this document useful (0 votes)
31 views7 pages

DBNNNNN

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)
31 views7 pages

DBNNNNN

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

Database: A database is a collection of related data which represents some aspect of the real world.

A
database system is designed to be built and populated with data for a certain task
Database Management System (DBMS) is a software for storing and retrieving users' data while considering
appropriate security measures. It consists of a group of programs which manipulate the database. The DBMS
accepts the request for data from an application and instructs the operating system to provide the specific
data. In large systems, a DBMS helps users and other third-party software to store and retrieve data.
Database management systems were developed to handle the following difficulties of typical File-
processing systems supported by conventional operating systems.
1. Data redundancy and inconsistency
2. Difficulty in accessing data
3. Data isolation – multiple files and formats
4. Integrity problems
5. Atomicity of updates
6. Concurrent access by multiple users
7. Security problems
ER diagram:
● ER diagram or Entity Relationship diagram is a conceptual model that gives the graphical
representation of the logical structure of the database.
● It shows all the constraints and relationships that exist among the different components.
● An ER diagram is mainly composed of following three components- Entity Sets, Attributes and
Relationship Set.
Roll_no is a primary key that can identify each entity uniquely.
Thus, by using a student's roll number, a student can be identified uniquely.
Entity Set:
An entity set is a set of the same type of entities.
Strong Entity Set:
A strong entity set is an entity set that contains sufficient attributes to uniquelyidentify all its entities.
In other words, a primary key exists for a strong entity set.
Primary key of a strong entity set is represented by underlining it.
Weak Entity Set:
o A weak entity set is an entity set that does not contain sufficient attributes to uniquely identify its
entities.
o In other words, a primary key does not exist for a weak entity set.
o However, it contains a partial key called a discriminator.
o Discriminator can identify a group of entities from the entity set.
o Discriminator is represented by underlining with a dashed line
Relationship:
A relationship is defined as an association among several entities.
● Unary Relationship Set - Unary relationship set is a relationship set where only one entity set
participates in a relationship set.
● Binary Relationship Set - Binary relationship set is a relationship set where two entity sets participate in a
relationship set.
● Ternary Relationship Set - Ternary relationship set is a relationship set where three entity sets
participate in a relationship set.
● N-ary Relationship Set - N-ary relationship set is a relationship set where ‘n’ entity sets participate in a
relationship set.
Cardinality Constraint:
Cardinality constraint defines the maximum number of relationship instances in which an entity can
participate.

● One-to-One Cardinality - An entity in set A can be associated with at most one entity in set B. An entity in
set B can be associated with at most one entity in set A.
● One-to-Many Cardinality - An entity in set A can be associated with any number (zero or
more) of entities in set B. An entity in set B can be associated with at most one entity inset A.
Many-to-One Cardinality - An entity in set A can be associated with at most one entity in set B. An entity in
set B can be associated with any number of entities in set A. ●
Many-to-Many Cardinality - An entity in set A can be associated with any number (zero or more) of entities
in set B. An entity in set B can be associated with any number (zero or more) of entities in set A.
Attributes:
Attributes are the descriptive properties which are owned by each entity of an Entity Set.
Types of Attributes:
● Simple Attributes - Simple attributes are those attributes which cannot be dividedfurther. Ex. Age
● Composite Attributes - Composite attributes are those attributes which are composed of many other
simple attributes. Ex. Name, Address
Multi Valued Attributes - Multi valued attributes are those attributes which can take more than one
value for a given entity from an entity set. Ex. Mobile No, Email ID ● Derived Attributes - Derived
attributes are those attributes which can be derived fromother attribute(s). Ex. Age can be derived from
DOB.
● Key Attributes - Key attributes are those attributes which can identify an entity uniquelyin an entity set. Ex.
Roll No.
Closure of an Attribute Set:
The set of all those attributes which can be functionally determined from an attribute set is called a
closure of that attribute set.
Keys:
A key is a set of attributes that can identify each tuple uniquely in the given relation.Types of Keys
● Super Key - A superkey is a set of attributes that can identify each tuple uniquely in the given relation. A
super key may consist of any number of attributes.
● Candidate Key - A set of minimal attribute(s) that can identify each tuple uniquely in the given relation is
called a candidate key.
● Primary Key - A primary key is a candidate key that the database designer selects while designing the
database. Primary Keys are unique and NOT NULL.
● Alternate Key - Candidate keys that are left unimplemented or unused after implementing the
primary key are called as alternate keys.
● Foreign Key - An attribute ‘X’ is called as a foreign key to some other attribute ‘Y’ when its values are
dependent on the values of attribute ‘Y’. The relation in which attribute ‘Y’ is present is called as the
referenced relation. The relation in which attribute ‘X’ is presentis called as the referencing relation.
● Composite Key - A primary key composed of multiple attributes and not just a single attribute is called a
composite key.
● Unique Key - It is unique for all the records of the table. Once assigned, its value cannotbe changed i.e. it is
non-updatable.ItmayhaveaNULLvalue
Normalization:
In DBMS, database normalization is a process of making the database consistent by-
● Reducing the redundancies
● Ensuring the integrity of data through lossless decomposition
Normal Forms:
● First Normal Form (1NF) - A given relation is called in First Normal Form (1NF) if each cell of the table
contains only an atomic value i.e. if the attribute of every tuple is either single valued or a null value.
● Second Normal Form (2NF) - A given relation is called in Second Normal Form (2NF) ifand only if
o Relation already exists in 1NF.
o No partial dependency exists in the relation.
A → B is called a partial dependency if and only if- A is a subset of some candidate key and B is a
non-prime attribute.
● Third Normal Form (3NF) - A given relation is called in Third Normal Form (3NF) if andonly if
o Relation already exists in 2NF. No transitive dependency exists for non-prime attributes.
A → B is called a transitive dependency if and only if- A is not a super key and Bis a non-prime attribute.
● Boyce-Codd Normal Form - A given relation is called in BCNF if and only if
o Relation already exists in 3NF.
o For each non-trivial functional dependency ‘A → B’, A is a super key of therelation.
Transaction:
Transaction is a single logical unit of work formed by a set of operations.
Operations in Transaction:
● Read Operation - Read(A) instruction will read the value of ‘A’ from the database and will store it in the
buffer in main memory.
● Write Operation – Write(A) will write the updated value of ‘A’ from the buffer to thedatabase.
Transaction States:
● Active State –
o This is the first state in the life cycle of a transaction.
o A transaction is called in an active state as long as its instructions are gettingexecuted.
o All the changes made by the transaction now are stored in the buffer in mainmemory.
● Partially Committed State –
o After the last instruction of the transaction has been executed, it enters into apartially committed state.
o After entering this state, the transaction is considered to be partially committed.
o It is not considered fully committed because all the changes made by the transaction are still stored
in the buffer in main memory.
● Committed State –
o After all the changes made by the transaction have been successfully stored into the database, it enters into
a committed state.
o Now, the transaction is considered to be fully committed.
● Failed State –
o When a transaction is getting executed in the active state or partially committed state and some failure
occurs due to which it becomes impossible to continue the execution, it enters into a failed state.
● Aborted State –
o After the transaction has failed and entered into a failed state, all the changes made by it have to be undone.
After the transaction has rolled back completely, it enters into an aborted state.
o To undo the changes made by the transaction, it becomes necessary to roll backthe transaction.
● Terminated State – This is the last state in the life cycle of a transaction.After entering the committed state or
aborted state, the transaction finallyenters into a terminated state where its life cycle finally comes to an end.
ACID Properties:
To ensure the consistency of the database, certain properties are followed by all the transactions
occurring in the system. These properties are called as ACID Properties of atransaction.
● Atomicity –
o This property ensures that either the transaction occurs completely or it does notoccur at all.
o In other words, it ensures that no transaction occurs partially.
● Consistency –
o This property ensures that integrity constraints are maintained.
o In other words, it ensures that the database remains consistent before and afterthe transaction.
● Isolation –
o This property ensures that multiple transactions can occur simultaneously without causing any
inconsistency.
o The resultant state of the system after executing all the transactions is the same as the state that would be
achieved if the transactions were executed serially oneafter the other.
● Durability –
o This property ensures that all the changes made by a transaction after its successful execution are
written successfully to the disk.
o It also ensures that these changes exist permanently and are never lost even ifthere occurs a failure of any
kind.
Schedules:
The order in which the operations of multiple transactions appear for execution is called as aschedule.
● Serial Schedules –
o All the transactions execute serially one after the other.
o When one transaction executes, no other transaction is allowed to execute.
o Serial schedules are always- Consistent, Recoverable, Cascadeless and Strict. ●
Non-Serial Schedules –
o Multiple transactions execute concurrently.
o Operations of all the transactions are inter leaved or mixed with each other.
o Non-serial schedules are not always- Consistent, Recoverable, Cascadeless andStrict.
Serializability –
Some non-serial schedules may lead to inconsistency of the database. ● Serializability is a concept that
helps to identify which non-serial schedules are correct and will maintain the consistency of the
database.
● Serializable Schedules –
o If a given non-serial schedule of ‘n’ transactions is equivalent to some serial schedule of ‘n’ transactions,
then it is called as a serializable schedule.
o Serializable schedules are always- Consistent, Recoverable, Cascadeless andStrict.
Types of Serializability –
● Conflict Serializability - If a given non-serial schedule can be converted into a serial schedule by
swapping its non-conflicting operations, then it is called a conflict serializable schedule.
● View Serializability - If a given schedule is found to be viewed as equivalent to some serial schedule,
then it is called a view serializable schedule.
Non-Serializable Schedules –
A non-serial schedule which is not serializable is called a non-serializable schedule. ● A non-serializable
schedule is not guaranteed to produce the same effect as produced by some serial schedule on any
consistent database. * Non-serializable schedules- may or may not be consistent, may or may not b
Rule 0: The Foundation Rule
The database must be in relational form. So that the system can handle the database through its
relational capabilities.
Rule 1: Information Rule
A database contains various information, and this information must be stored in each cell of a table in
the form of rows and columns.
Rule 2: Guaranteed Access Rule
Every single or precise data (atomic value) may be accessed logically from a relational database using
the combination of primary key value, table name, and column name.
Rule 3: Systematic Treatment of Null Values
This rule defines the systematic treatment of Null values in database records. The null value has
various meanings in the database, like missing the data, no value in a cell, inappropriate information,
unknown data and the primary key should not be null.
Rule 4: Active/Dynamic Online Catalog based on the relational model
It represents the entire logical structure of the descriptive database that must be stored online and is
known as a database dictionary. It authorizes users to access the database and implement a similar
query language to access the database.
Rule 5: Comprehensive Data SubLanguage Rule
The relational database supports various languages, and if we want to access the database, the
language must be the explicit, linear or well-defined syntax, character strings and supports the
comprehensive: data definition, view definition, data manipulation, integrity constraints, and limit
transaction management operations. If the database allows access to the data without any language, it
is considered a violation of the database.
Rule 6: View Updating Rule
All views table can be theoretically updated and must be practically updated by the database systems.
Rule 7: Relational Level Operation (High-Level Insert, Update and delete) Rule
A database system should follow high-level relational operations such as insert, update, and delete in
each level or a single row. It also supports union, intersection and minus operation in the database
system.
Rule 8: Physical Data Independence Rule
All stored data in a database or an application must be physically independent to access the database.
Each data should not depend on other data or an application. If data is updated or the physical
structure of the database is changed, it will not show any effect on external applications that are
accessing the data from the database.
Rule 9: Logical Data Independence Rule
It is similar to physical data independence. It means, if any changes occurred to the logical level (table
structures), it should not affect the user's view (application). For example, suppose a table either split
into two tables, or two table joins to create a single table, these changes should not be impacted on
the user view application.
Rule 10: Integrity Independence Rule
A database must maintain integrity independence when inserting data into table's cells using the SQL
query language. All entered values should not be changed or rely on any external factor or application
to maintain integrity. It is also helpful in making the database-independent for each front-end
application.
Rule 11: Distribution Independence Rule
The distribution independence rule represents a database that must work properly, even if it is stored
in different locations and used by different end-users. Suppose a user accesses the database through
an application; in that case, they should not be aware that another user uses particular data, and the
data they always get is only located on one site. The end users can access the database, and these
access data should be independent for every user to perform the SQL queries.
Rule 12: Non Subversion Rule
The non-submersion rule defines RDBMS as a SQL language to store and manipulate the data in the
database. If a system has a low-level or separate language other than SQL to access the database
A Database stores a lot of critical information to access data quickly and securely. Hence
it is important to select the correct architecture for efficient data management. DBMS
Architecture helps users to get their requests done while connecting to the database. We
choose database architecture depending on several factors like the size of the database,
number of users, and relationships between the users. There are two types of database
models that we generally use, logical model and physical model. Several types of
architecture are there in the database which we will deal with in the next section.
Types of DBMS Architecture
There are several types of DBMS Architecture that we use according to the usage
requirements. Types of DBMS Architecture are discussed here.
 1-Tier Architecture
 2-Tier Architecture
 3-Tier Architecture
1-Tier Architecture
In 1-Tier Architecture the database is directly available to the user, the user can directly
sit on the DBMS and use it that is, the client, server, and Database are all present on the
same machine. For Example: to learn SQL we set up an SQL server and the database
on the local system. This enables us to directly interact with the relational database and
execute operations. The industry won’t use this architecture they logically go for 2-tier
and 3-tier Architecture.
Advantages of 1-Tier Architecture
Below mentioned are the advantages of 1-Tier Architecture.
 Simple Architecture: 1-Tier Architecture is the most simple architecture to set up, as
only a single machine is required to maintain it.
 Cost-Effective: No additional hardware is required for implementing 1-Tier
Architecture, which makes it cost-effective.
 Easy to Implement: 1-Tier Architecture can be easily deployed, and hence it is
mostly used in small projects.
2-Tier Architecture
The 2-tier architecture is similar to a basic client-server model. The application at the
client end directly communicates with the database on the server side. APIs like ODBC
and JDBC are used for this interaction. The server side is responsible for providing query
processing and transaction management functionalities. On the client side, the user
interfaces and application programs are run. The application on the client side
establishes a connection with the server side to communicate with the DBMS.
An advantage of this type is that maintenance and understanding are easier, and
compatible with existing systems. However, this model gives poor performance when
there are a large number of users.
Advantages of 2-Tier Architecture
Easy to Access: 2-Tier Architecture makes easy access to the database, which makes
fast retrieval.
Scalable: We can scale the database easily, by adding clients or upgrading hardware.
Low Cost: 2-Tier Architecture is cheaper than 3-Tier Architecture and Multi-Tier Archite
Easy Deployment: 2-Tier Architecture is easier to deploy than 3-Tier Architecture.
Simple: 2-Tier Architecture is easily understandable as well as simple because of only
two components.
3-Tier Architecture
In 3-Tier Architecture, there is another layer between the client and the server. The client
does not directly communicate with the server. Instead, it interacts with an application
server which further communicates with the database system and then the query
processing and transaction management takes place. This intermediate layer acts as a
medium for the exchange of partially processed data between the server and the client.
This type of architecture is used in the case of large web applications
Advantages of 3-Tier Architecture.
Enhanced scalability: Scalability is enhanced due to the distributed deployment of
application servers. Now, individual connections need not be made between the client
and server.
Data Integrity: 3-Tier Architecture maintains Data Integrity. Since there is a middle layer
between the client and the server, data corruption can be avoided/removed.
Security: 3-Tier Architecture Improves Security. This type of model prevents direct
interaction of the client with the server thereby reducing access to unauthorized data.
Disadvantages of 3-Tier Architecture
More Complex: 3-Tier Architecture is more complex in comparison to 2-Tier
Architecture. Communication Points are also doubled in 3-Tier Architecture.
Difficult to Interact: It becomes difficult for this sort of interaction to take place due to
the presence of middle layers.

SQL NoSQL

RELATIONAL DATABASE MANAGEMENT Non-relational or distributed database


SYSTEM (RDBMS) system.

These databases have fixed or static or


They have a dynamic schema
predefined schema

These databases are not suited for hierarchical These databases are best suited for
data storage. hierarchical data storage.

These databases are best suited for complex These databases are not so good for
queries complex queries

Vertically Scalable Horizontally scalable

Follows CAP(consistency, availability,


Follows ACID property
partition tolerance)

Examples: MySQL, PostgreSQL, Oracle, MS- Examples: MongoDB, HBase, Neo4j,


SQL Server, etc Cassandra, etc

You might also like