ABDMS-UNIT 2 AND UNIT 5 NOTES

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

UNIT 2

ACID Properties in DBMS


A transaction is a single logical unit of work that accesses and possibly modifies the
contents of a database. Transactions access data using read-and-write operations. To
maintain consistency in a database, before and after the transaction, certain
properties are followed. These are called ACID properties.

1) Atomicity-The term atomicity defines that the data remains atomic. It means if
any operation is performed on the data, either it should be performed or executed
completely or should not be executed at all. It further means that the operation should
not break in between or execute partially. In the case of executing operations on the
transaction, the operation should be completely executed and not partially

In the above diagram, it can be seen that after crediting $10, the amount is still $100 in
account B. So, it is not an atomic transaction
The below image shows that both debit and credit operations are done successfully. Thus the
transaction is atomic.
2) Consistency-The word consistency means that the value should remain preserved
always. In DBMS, the integrity of the data should be maintained, which means if a change in
the database is made, it should remain preserved always. In the case of transactions, the
integrity of the data is very essential so that the database remains consistent before and after
the transaction. The data should always be correct.

In the above figure, there are three accounts, A, B, and C, where A is making a
transaction T one by one to both B & C. There are two operations that take place, i.e.,
Debit and Credit. Account A firstly debits $50 to account B, and the amount in account
A is read $300 by B before the transaction. After the successful transaction T, the
available amount in B becomes $150. Now, A debits $20 to account C, and that time,
the value read by C is $250 (that is correct as a debit of $50 has been successfully
done to B). The debit and credit operation from account A to C has been done
successfully. We can see that the transaction is done successfully, and the value is
also read correctly. Thus, the data is consistent. In case the value read by B and C is
$300, which means that data is inconsistent because when the debit operation
executes, it will not be consistent.
3) Isolation-The term 'isolation' means separation. In DBMS, Isolation is the property
of a database where no data should affect the other one and may occur concurrently.
In short, the operation on one database should begin when the operation on the first
database gets complete. It means if two operations are being performed on two
different databases, they may not affect the value of one another. In the case of
transactions, when two or more transactions occur simultaneously, the consistency
should remain maintained. Any changes that occur in any particular transaction will
not be seen by other transactions until the change is not committed in the memory.
Example: If two operations are concurrently running on two different accounts, then
the value of both accounts should not get affected. The value should remain
persistent. As you can see in the below diagram, account A is making T1 and T2
transactions to account B and C, but both are executing independently without
affecting each other. It is known as Isolation.

4) Durability-Durability ensures the permanency of something. In DBMS, the term


durability ensures that the data after the successful execution of the operation
becomes permanent in the database. The durability of the data should be so perfect
that even if the system fails or leads to a crash, the database still survives. However,
if gets lost, it becomes the responsibility of the recovery manager for ensuring the
durability of the database. For committing the values, the COMMIT command must be
used every time we make changes.
Therefore, the ACID property of DBMS plays a vital role in maintaining the consistency
and availability of data in the database.
Transaction states with a diagram in DBMS.-Assignment Notebook
What is meant by concurrency control, and explain problems with
concurrency control in transactions.- Assignment Notebook
Explain lock-based protocols.- Assignment Notebook

UNIT 5

History of NoSQL Databases


The term and the concept NoSQL were invented in 1998 by Carl Strozz, in order to
designate his lightweight and open source relational database. This concept was then
adopted and popularized by GAFAMs such as Google, Facebook or Amazon faced with
huge volumes of data. Relational databases had become too slow.
Instead of upgrading their IT equipment to increase the performance of RDBMS
(Relational Database Management System), the tech giants chose to distribute the
load over multiple host servers
This is known as the “scaling out” method. NoSQL databases are ideal for scaling out,
since they are nonrelational.In the year 2000, the graphical database Neo4j was
launched. Then it was the turn of the Google Bigtable, in 2004, and CouchDB in 2005.
The history of NoSQL databases was also marked by Amazon Dynamo in 2007.Then,
in 2008, Facebook made open source the non-relational database it uses internally.
Need of NoSQL
1. Scalability: NoSQL databases are designed to scale horizontally, meaning that they
can handle large amounts of data and user traffic by adding more commodity
hardware. This makes it easier to handle the increasing demands of modern
applications, without having to make significant changes to the underlying
infrastructure.
2. Performance: NoSQL databases are optimized for handling large volumes of data,
which means that they can deliver faster performance compared to traditional
relational databases. This is particularly important for applications that require real-
time data access and low latency.
3. Flexibility: NoSQL databases are schema-less, meaning that they can handle
unstructured and semi-structured data in addition to structured data. This flexibility
makes it easier to store and manage a wide variety of data types, including
documents, graphs, and key-value pairs.
4. Cost-effectiveness: Because NoSQL databases are designed to run on commodity
hardware, they are often more cost-effective than traditional relational databases,
which can require expensive hardware and software licenses.
5. Availability: NoSQL databases are designed to handle high levels of traffic and data
throughput, which means that they can provide high availability and fault tolerance.
This is particularly important for mission-critical applications that require constant
uptime and minimal downtime.
Overall, NoSQL databases offer a range of benefits that make them an attractive
option for organizations that need to manage large amounts of data, handle high
levels of traffic, and deliver fast performance.

NoSQL
NoSQL is a type of database management system (DBMS) that is designed to handle
and store large volumes of unstructured and semi-structured data. Unlike traditional
relational databases that use tables with pre-defined schemas to store data, NoSQL
databases use flexible data models that can adapt to changes in data structures and
are capable of scaling horizontally to handle growing amounts of data.
The term NoSQL originally referred to “non-SQL” or “non-relational” databases, but the
term has since evolved to mean “not only SQL,” as NoSQL databases have expanded
to include a wide range of different database architectures and data models.
Four Types of NoSQL Databases
1. Document databases: These databases store data as semi-structured
documents, such as JSON or XML, and can be queried using document-oriented
query languages.
2. Key-value stores: These databases store data as key-value pairs, and are
optimized for simple and fast read/write operations.
3. Column-family stores: These databases store data as column families, which are
sets of columns that are treated as a single entity. They are optimized for fast
and efficient querying of large amounts of data.
4. Graph databases: These databases store data as nodes and edges, and are
designed to handle complex relationships between data.

Document databases: -The document-based database is a nonrelational database.


Instead of storing the data in rows and columns (tables), it uses the documents to
store the data in the database. A document database stores data in JSON, BSON,
or XML documents.
Key features of documents database:
 Flexible schema: Documents in the database has a flexible schema. It means
the documents in the database need not be the same schema.
 Faster creation and maintenance: the creation of documents is easy and
minimal maintenance is required once we create the document.
 No foreign keys: There is no dynamic relationship between two documents so
documents can be independent of one another. So, there is no requirement for a
foreign key in a document database.
 Open formats: To build a document we use XML, JSON, and others.

Key-value databases –A key-value store is a nonrelational database. The simplest


form of a NoSQL database is a key-value store. Every data element in the database is
stored in key-value pairs. The data can be retrieved by using a unique key allotted to
each element in the database. The values can be simple data types like strings and
numbers or complex objects.
A key-value store is like a relational database with only two columns which is the key
and the value.
Key features of the key-value store:
 Simplicity.
 Scalability.
 Speed.
• Key: user:12345
• Value: {"name": “kiran”, "email": “[email protected]", "designation": "software
developer"}

Column Oriented Databases-A column-oriented database is a non-relational


database that stores the data in columns instead of rows. That means when we want
to run analytics on a small number of columns, you can read those columns directly
without consuming memory with the unwanted data.
Columnar databases are designed to read data more efficiently and retrieve the data
with greater speed. A columnar database is used to store a large amount of data.

Key features of Columnar Oriented Database


 Scalability
 Compression
 Very responsive

Graph-Based Databases-Graph-based databases focus on the relationship between


the elements. It stores the data in the form of nodes in the database. The connections
between the nodes are called links or relationships.
Key features of Graph Database
 In a graph-based database, it is easy to identify the relationship between the
data by using the links.
 The Query’s output is real-time results.
 The speed depends upon the number of relationships among the database
elements.
 Updating data is also easy, as adding a new node or edge to a graph database
is a straightforward task that does not require significant schema changes.
Examples:Neo4j: Leading graph database, supports Cypher query language.
Amazon Neptune: Fully managed graph database.
ArangoDB: Multi-model database with strong graph capabilities.

Introduction to MongoDB Database


MongoDB is an open-source document-oriented database that is designed to
store a large scale of data and also allows you to work with that data very
efficiently.
MongoDB stands out as a leading NoSQL database, offering an open-source,
document-oriented approach that diverges from traditional relational
databases. Unlike SQL databases, MongoDB stores data in BSON format, akin
to JSON, allowing for more flexible data storage and retrieval.
Features of MongoDB
 Schema-less Database: It is the great feature provided by the MongoDB.
A Schema-less database means one collection can hold different types
of documents in it. Or in other words, in the MongoDB database, a single
collection can hold multiple documents and these documents may consist of the
different numbers of fields, content, and size. It is not necessary that the one
document is similar to another document like in the relational
databases. Due to this cool feature, MongoDB provides great flexibility to
databases.
 Document Oriented: In MongoDB, all the data stored in the documents
instead of tables like in RDBMS. In these documents, the data is stored in
fields(key-value pair) instead of rows and columns which make the data much
more flexible in comparison to RDBMS. And each document contains its unique
object id.
 Indexing: In MongoDB database, every field in the documents is indexed
with primary and secondary indices this makes easier and takes less
time to get or search data from the pool of the data. If the data is not
indexed, then database search each document with the specified query which
takes lots of time and not so efficient.
 Scalability: MongoDB provides horizontal scalability with the help of
sharding. Sharding means to distribute data on multiple servers, here a large
amount of data is partitioned into data chunks using the shard key, and these
data chunks are evenly distributed across shards that reside across many
physical servers. It will also add new machines to a running database.
 Replication: MongoDB provides high availability and redundancy with the help
of replication, it creates multiple copies of the data and sends these copies to a
different server so that if one server fails, then the data is retrieved from
another server.
 Aggregation: It allows to perform operations on the grouped data and
get a single result or computed result. It is similar to the SQL GROUPBY
clause. It provides three different aggregations i.e, aggregation pipeline, map-
reduce function, and single-purpose aggregation methods
 High Performance: The performance of MongoDB is very high and data
persistence as compared to another database due to its features like scalability,
indexing, replication, etc.
Advantages of MongoDB
 It is a schema-less NoSQL database. You need not to design the schema of the
database when you are working with MongoDB.
 It does not support join operation.
 It provides great flexibility to the fields in the documents.
 It contains heterogeneous data.
 It provides high performance, availability, scalability.
 It supports Geospatial efficiently.
 It is a document oriented database and the data is stored in BSON documents.
 It also supports multiple document ACID transition(string from MongoDB 4.0).
 It does not require any SQL injection.
 It is easily integrated with Big Data Hadoop

Disadvantages of MongoDB
 It uses high memory for data storage.
 You are not allowed to store more than 16MB data in the documents.
 The nesting of data in BSON is also limited you are not allowed to nest data
more than 100 levels.

JSON
JSON stands for JavaScript Object Notation
• JSON is a lightweight data-interchange format
• JSON is plain text written in JavaScript object notation
• JSON is used to send data between computers • JSON is language independent

Features of JSON
Easy to understand: JSON is easy to read and write.
Format: It is a text-based interchange format. It can store any kind of data in an array
of video, audio, and image anything that you required.
Support: It is light-weighted and supported by almost every language and OS. It has
a wide range of support for the browsers approx each browser supported by JSON.
Dependency: It is an Independent language that is text-based. It is much faster
compared to other text-based structured data.
JSON Syntax Rules: Data is in name/value pairs and they are separated by commas.
It uses curly brackets to hold the objects and square brackets to hold the arrays.
Advantages of JSON:
 JSON stores all the data in an array so data transfer makes easier. That’s why
JSON is the best for sharing data of any size even audio, video, etc.
 Its syntax is very easy to use. Its syntax is very small and light-weighted that’s
the reason that it executes and response in a faster way.
 JSON has a wide range for the browser support compatibility with the operating
systems, it doesn’t require much effort to make it all browser compatible.
 On the server-side parsing the most important part that developers want, if the
parsing will be fast on the server side then the user can get the fast response,
so in this case JSON server-side parsing is the strong point compare tot others.
Disadvantages of JSON:
 The main disadvantage for JSON is that there is no error handling in JSON, if
there was a slight mistake in the JSON script then you will not get the structured
data.
 JSON becomes quite dangerous when you used it with some unauthorized
browsers. Like JSON service return a JSON file wrapped in a function call that has
to be executed by the browsers if the browsers are unauthorized then your data
can be hacked.
 JSON has limited supported tools that we can use during JSON development.

FIREBASE
Firebase is the platform developed by Google for building and managing web and
mobile applications. It can provide developers with various tools and services that are
designed to simplify the process of app development. It allows them to focus more on
creating features and less on managing the infrastructure.
Firebase is the Backend-as-a-Service (BaaS) platform which is developed by Google
and provides a variety of tools and services for building web and mobile applications.
It simplifies the backend development tasks like database management,
authentication, file storage, and real-time data syncing. Allows the developers to focus
on building high-quality applications. The Firebase integrates well with other Google
Cloud products and offers cross-platform support.

Key Features of the Firebase


 Real-time database:The firebase is real-time NoSQL database allows the
developers to store and sync the data across all clients in real-time.
 Cloud Firestore: Firestore is the Firebase's scalable NoSQL cloud database that
offers an automatic scaling, high performance, and the real-time capabilities.
 Firebase Authentication:Firebase Authentication helps the developers to
implement secure authentication mechanisms using by various identity provider
such as Google, Facebook, Twitter, GitHub and emial/password.
 Cloud Functions:Cloud Functions allows the developer to write server-sides
code that automatically runs in response to the events triggered by Firebase
features and the HTTPs requests.
 Firebase Cloud Messaging(FCM): Firebase Cloud Messaging provides the
way to send notifications to users across the platforms(iOS,Android and the
web).
 Firebase Hosting: Firebase Hosting offer the fast, secure and reliable hosting
for a static and dynamic content. It is optimized for the web and mobile app
hosting, providing SSL certificates by the default for security.

Advantages of Firebase
 Simplified App Development: Firebase abstracts much of the complexity that
associted with backend services such as authentication, database and the cloud
functions which allow developers to focus on creating front-end and the
business logic of apps.
 Real-time Data Synchronization: With the real-time database and the
Firestore, Firebase make it easier to build the apps that require live updates.
 Cross-Platform Support: Firebase offer the strong support for cross-platform
apps that includes Android, iOS and Web. The unified API across all platforms
ensures that the developers do not have to write seperate codebases for each
the platform when using Firebase Services.
 Security: The Firebase provides built-in security rules and the policies to
protect all data accesses and prevent the unauthorized usage.
 Scalabilty: The Firebase automatically scales with our app's growth. Whether
we have the small user base or millions of users. Firebase can handle the load
without manual intervention.

Use Cases of Firebase


Social Media and Chat Apps: Firebase is the real-time database which is perfectly
suited for building the chat apps where messages need to be delivered
instantaneously across all the users.
Collaborative Platforms: Applications that allow for multiple users to collaborative
in the real-time, such as document editing tools or the project management apps that
benefit from Firebase's data synchronization capabilities.
E-commerce Apps: Firebase Authentication and the Cloud Firestore are frequently
used in the e-commerce apps for managing the user accounts, product catalogs and
the orders.
Game Development: The Firebase's cloud functions, real-time analytics and the
performance monitoring make it the popular coice for game developes looking to
manage the back-end infrastructure while optimizing the user experience

You might also like