DBMS Unit-V 1
DBMS Unit-V 1
Unit: 5
DBMS
ACSAI0402 Raj Kumar Gupta
Assistant Professor
CSE(DS)
B-Tech IV Sem
LTP Credits
3–1–0 4
• From the 1980s to the Internet era in the late 1990s, SQL databases
dominated the development landscape. Large commercial applications, niche
products, and custom applications of all types were based on SQL.
• But the rise of the Internet has changed application development profoundly.
The amount of data, the structure of the data, the scale of applications, the
way applications have developed have all changed dramatically.
• These changes have led many organizations of all sizes to adopt NoSQL
database technology.
• In recent times you can easily capture and access data from various sources,
like Facebook, Google, etc.
• User’s personal information, geographic location data, user generated
content, social graphs and machine logging data are some of the examples
where data is increasing rapidly.
• To use above mentioned properties, it is necessary to process large volume of
data.
• For which relational databases are not suitable. The evolution of NoSQL
databases is to handle this large volume of data properly.
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 7
IT 05
Course Objective
Contd..
5. Modern tool usage: Create, select, and apply appropriate techniques,
resources, and modern engineering and IT tools including prediction and
modeling to complex engineering activities with an understanding of the
limitations.
Contd..
9. Individual and team work: Function effectively as an individual, and as a
member or leader in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities
with the engineering community and with society at large, such as, being able to
comprehend and write effective reports and design documentation, make
effective presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and
understanding of the engineering and management principles and apply these
to one’s own work, as a member and leader in a team, to manage projects and
in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and
ability to engage in independent and life-long learning in the broadest context of
technological change.
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
ASCAI0402.1
2 2 3 3 3 2 3 2 2 2 2 3
ACSAI0402.2
3 3 3 2 2 2 2 2 2 2 2 3
ACSAI0402.3
2 3 3 3 3 2 2 2 2 2 2 2
ACSAI0402.4
2 3 2 2 2 2 2 2 2 3 2 2
ACSAI0402.5
2 3 2 2 2 3 2 2 3 2 2 2
AVG
2.20 2.80 2.60 2.40 2.40 2.20 2.20 2.00 2.20 2.20 2.00 2.40
PSO1: The ability to identify, analyze real world problems and design their ethical
solutions using artificial intelligence, robotics, virtual/augmented reality, data
analytics, block chain technology, and cloud computing.
PSO2:The ability to design and develop the hardware sensor devices and related
interfacing software systems for solving complex engineering problems.
PSO4: The ability to conduct investigation of complex problem with the help of
technical, managerial, leadership qualities, and moder engineering tools provided
by industry sponsored laboratories.
ACSAI0402.1
3 1 3 1
ACSAI0402.2
3 1 3 1
ACSAI0402.3
3 1 3 1
ACSAI0402.4
3 1 3 1
ACSAI0402.5
3 1 3 1
AVG
3.00 1.00 3.00 1.00
PEO4: To have life-long learning for up-skilling and re-skilling for successful
professional career as engineer, scientist, entrepreneur and bureaucrat for
betterment of society
SECTION – B CO
Prerequisites:
• Linux/ Windows operating system.
• Database Management Software's such as Oracle
• Knowledge on SQL/PLSQL.
• Cloud Infrastructure.
• Handling Big Data on Unstructured Databases.
• Programming Languages (Python or Java)
• Recap:
• Discussion about Cloud and Database Management System.
The rise of NoSQL is an important event in computer science and in application development
because SQL has been so dominant for so long. Many other forms of database technology have
come and gone, but few have had the wide adoption of NoSQL.
By understanding the rise in popularity of NoSQL databases, we should be able to shed light on
when it makes sense to use NoSQL.
NoSQL covers a lot of different database structures and data models.
• http://www.nptelvideos.com/lecture.php?id=6516
• http://www.nptelvideos.com/lecture.php?id=6517
• http://www.nptelvideos.com/lecture.php?id=6518
• http://www.nptelvideos.com/lecture.php?id=6519
• https://www.youtube.com/watch?v=2yQ9TGFpDuM
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 21
IT 05
Content – Unit 5
Topic CO
Definition of NoSQL CO5
Topic CO
Introduction of Cloud database CO5
NoSQL with Cloud Database CO5
Introduction to Real time CO5
Database
• Introduction NoSQL
• Characteristic of NoSQL
Objective:
In this topic we focus on There are several advantages of working
with NoSQL databases such as MongoDB and Cassandra. The main
advantages are high scalability and high availability. High scalability:
NoSQL database such as MongoDB uses sharding for horizontal
scaling.
Recap:
Revision of Database Management Systems.
NoSQL databases (aka "not only SQL") are non-tabular databases and store data differently
than relational tables. NoSQL databases come in a variety of types based on their data
model. The main types are document, key-value, wide-column, and graph. They provide
flexible schemas and scale easily with large amounts of data and high user loads.
When people use the term “NoSQL database,” they typically use it to refer to any non-
relational database. Some say the term “NoSQL” stands for “non SQL” while others say it
stands for “not only SQL.” Either way, most agree that NoSQL databases are databases that
store data in a format other than relational tables.
Introduction NoSQL
1. Stands for Not Only SQL.
2. The idea of NoSQL founded in 1998 with term lightweight Schema Less
by Carlo Strozzi.
3. Open-source database.
4. NoSQL will be the future database.
5. Very compatible with distributed systems.
6. Lower cost.
7. High performance database.
8. Founded to handle huge data space.
9. Used by Facebook , Google , Wikipedia …
1. Basically Available.
3. Eventually Consistent.
4. Weak consistency.
5. Availability first.
Query Analysis
db.inventory.find( { type: 'food' } ).explain() Output Here
NoSQL :
Handle huge data.
High availability with small cost.
More data redundancy.
High performance. Pick the right tool for your job
Less administration time. !
Less standards. SQL :
• Good to solve ACID problems.
• Expensive.
• Less data redundancy.
• Increasing availability mean increasing cost.
• More standards.
• More administration.
Objective:
In this topic we focus on Motivations for this approach include
simplicity of design, simpler "horizontal" scaling to clusters of
machines (which is a problem for relational databases), finer control
over availability and limiting the object-relational impedance
mismatch.
Recap:
As storage costs rapidly decreased, the amount of data that applications needed
to store and query increased. This data came in all shapes and sizes — structured,
semi-structured, and polymorphic — and defining the schema in advance became
nearly impossible. NoSQL databases allow developers to store huge amounts of
unstructured data, giving them a lot of flexibility.
Additionally, the Agile Manifesto was rising in popularity, and software engineers
were rethinking the way they developed software. They were recognizing the
need to rapidly adapt to changing requirements. They needed the ability to iterate
quickly and make changes throughout their software stack — all the way down to
the database. NoSQL databases gave them this flexibility.
Cloud computing also rose in popularity, and developers began using public clouds
to host their applications and data. They wanted the ability to distribute data
across multiple servers and regions to make their applications resilient, to scale
out instead of scale up, and to intelligently geo-place their data. Some NoSQL
databases like MongoDB provide these capabilities.
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 42
IT 05
History of NoSQL and Different NoSQL products
NoSQL databases typically have very flexible schemas. A flexible schema allows
you to easily make changes to your database as requirements change. You can
iterate quickly and continuously integrate new application features to provide
value to your users faster.
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 43
IT 05
History of NoSQL and Different NoSQL products
2. Horizontal scaling
Most SQL databases require you to scale-up vertically (migrate to a larger, more expensive
server) when you exceed the capacity requirements of your current server. Conversely,
most NoSQL databases allow you to scale-out horizontally, meaning you can add cheaper,
commodity servers whenever you need to.
3. Fast queries
Queries in NoSQL databases can be faster than SQL databases. Why? Data in SQL databases
is typically normalized, so queries for a single object or entity require you to join data from
multiple tables. As your tables grow in size, the joins can become expensive. However, data
in NoSQL databases is typically stored in a way that is optimized for queries. The rule of
thumb when you use MongoDB is Data that is accessed together should be stored together.
Queries typically do not require joins, so the queries are very fast.
To address these use cases MongoDB added support for multi-document ACID transactions
in the 4.0 release, and extended them in 4.2 to span sharded clusters.
Since data models in NoSQL databases are typically optimized for queries and not for
reducing data duplication, NoSQL databases can be larger than SQL databases. Storage is
currently so cheap that most consider this a minor drawback, and some NoSQL databases
also support compression to reduce the storage footprint.
Depending on the NoSQL database type you select, you may not be able to achieve all of
your use cases in a single database. For example, graph databases are excellent for analyzing
relationships in your data but may not provide what you need for everyday retrieval of the
data such as range queries. When selecting a NoSQL database, consider what your use cases
will be and if a general purpose database like MongoDB would be a better option.
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 45
IT 05
History of NoSQL and Different NoSQL products
• Document databases
• Key-value stores
• Column-oriented databases
• Graph databases
Document Databases
A document database stores data in JSON, BSON , or XML documents (not Word documents
or Google docs, of course). In a document database, documents can be nested. Particular
elements can be indexed for faster querying.
Documents can be stored and retrieved in a form that is much closer to the data objects
used in applications, which means less translation is required to use the data in an
application. SQL data must often be assembled and disassembled when moving back and
forth between applications and storage.
Document databases are popular with developers because they have the flexibility to
rework their document structures as needed to suit their application, shaping their data
structures as their application requirements change over time. This flexibility speeds
development because in effect data becomes like code and is under the control of
developers. In SQL databases, intervention by database administrators may be required to
change the structure of a database.
The most widely adopted document databases are usually implemented with a scale-out
architecture, providing a clear path to scalability of both data volumes and traffic.
Use cases include ecommerce platforms, trading platforms, and mobile app
development across industries.
Key-Value Stores
The simplest type of NoSQL database is a key-value store . Every data element in
the database is stored as a key value pair consisting of an attribute name (or
"key") and a value. In a sense, a key-value store is like a relational database with
only two columns: the key or attribute name (such as state) and the value (such
as Alaska).
Use cases include shopping carts, user preferences, and user profiles.
Column-Oriented Databases
While a relational database stores data in rows and reads data row by row, a
column store is organized as a set of columns. This means that when you want to
run analytics on a small number of columns, you can read those columns directly
without consuming memory with the unwanted data. Columns are often of the
same type and benefit from more efficient compression, making reads even
faster. Columnar databases can quickly aggregate the value of a given column
(adding up the total sales for the year, for example). Use cases include analytics.
Graph Databases
A graph database focuses on the relationship between data elements. Each element is
stored as a node (such as a person in a social media graph). The connections between
elements are called links or relationships. In a graph database, connections are first-class
elements of the database, stored directly. In relational databases, links are implied, using
data to express the relationships.
A graph database is optimized to capture and search the connections between data
elements, overcoming the overhead associated with JOINing multiple tables in SQL.
Very few real-world business systems can survive solely on graph queries. As a result graph
databases are usually run alongside other more traditional databases.
Use cases include fraud detection, social networks, and knowledge graphs.
As you can see, despite a common umbrella, NoSQL databases are diverse in their data
structures and their applications.
• Mongo DB
• Data types
Objective:
In this topic we focus on MongoDB which is a source-available cross-
platform document-oriented database program. Classified as a
NoSQL database program, MongoDB uses JSON-like documents with
optional schemas. MongoDB is developed by MongoDB Inc. and
licensed under the Server Side Public License.
Recap:
About MongoDB
MongoDB
MongoDB is a cross-platform, document oriented database that provides, high
performance, high availability, and easy scalability. MongoDB works on concept of
collection and document.
Database
Database is a physical container for collections. Each database gets its own set of files on
the file system. A single MongoDB server typically has multiple databases.
Collection
Collection is a group of MongoDB documents. It is the equivalent of an RDBMS table. A
collection exists within a single database. Collections do not enforce a schema.
Documents within a collection can have different fields. Typically, all documents in a
collection are of similar or related purpose.
Document
A document is a set of key-value pairs. Documents have dynamic schema. Dynamic
schema means that documents in the same collection do not need to have the same set
of fields or structure, and common fields in a collection's documents may hold different
types of data.
The following table shows the relationship of RDBMS terminology with MongoDB.
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 55
IT 05
NoSQL Databases: Introduction to NoSQL & MongoDB
RDBMS MongoDB
Database Database
Table Collection
Tuple/Row Document
column Field
Mysqld/Oracle mongod
mysql/sqlplus mongo
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 56
IT 05
Introduction MongoDB
• Goal: bridge the gap between key-value stores (which are fast and
scalable) and relational databases (which have rich functionality).
What is MongoDB?
• Instead of storing your data in tables and rows as you would with a
relational database, in MongoDB you store JSON-like documents
with dynamic schemas (schema-free, schemaless).
• Document-Oriented DB
– Unit object is a document instead of a row (tuple) in relational
DBs
Objective:
In this topic we focus on introducing the essential ways of
interacting with NoSQL data stores. The types of NoSQL stores vary
and so do the ways of accessing and interacting with them. This
topic attempts to summarize a few of the most prominent of these
disparate ways of accessing and querying data in NoSQL databases.
Recap:
Objective:
In this topic we focus on MongoDB - Datatypes
1. String − This is the most commonly used datatype to store the data.
Recap:
Revision of Nosql Databases.
• Field Value
– Scalar (Int, Boolean, String,
One document
Date, …)
– Document (Embedding or
Nesting)
Remember it is stored in
binary formats (BSON)
One Collection (e.g., one Table in RDBMS) • Max size of single document
16MB
• Or:
• 1st 4 bytes timestamp
• Next 3 bytes machine id
• Next 2 bytes Process id
• Last 3 bytes incremental
values
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 74
IT 05
NoSQL Storage Architecture
Objective:
In this topic we focus on the NoSQL database approach which is
characterized by a move away from the complexity of SQL based
servers. The logic of validation, access control, mapping querieable
indexed data, correlating related data, conflict resolution,
maintaining integrity constraints, and triggered procedures is moved
out of the database layer.
Recap:
• Advantages:
• Can handle large amounts of data and heavy load,
• Easy retrieval of data by keys.
• Limitations:
• Complex queries may attempt to involve multiple key-value pairs which may
delay performance.
• Data can be involving many-to-many relationships which may collide.
• Examples:
• DynamoDB
• Berkeley DB
• Advantages:
• HBase
• Bigtable by Google
• Cassandra
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 79
IT 05
NoSQL Storage Architecture
3. Document Database:
The document database fetches and accumulates data in form of key-value pairs
but here, the values are called as Documents. Document can be stated as a
complex data structure. Document here can be a form of text, arrays, strings,
JSON, XML or any such format. The use of nested documents is also very
common. It is very effective as most of the data created is usually in form of
JSONs and is unstructured.
Advantages:
This type of format is very useful and apt for semi-structured
data.
Storage retrieval and managing of documents is easy.
Limitations:
Handling multiple documents is challenging
Aggregation operations may not work accurately.
Examples:
MongoDB
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 81
CouchDB IT 05
NoSQL Storage Architecture
• Advantages:
• Fastest traversal because of connections.
• Spatial data can be easily handled.
• Limitations:
• Wrong connections may lead to infinite loops.
•12/27/2024
Examples: Mr. Rajkumar Gupta ACSAI0402 DBMS UN 83
IT 05
NoSQL Storage Architecture
• Capped Collections
Objective:
In this topic we focus on CRUD Meaning: CRUD is an acronym that
comes from the world of computer programming and refers to the
four functions that are considered necessary to implement a
persistent storage application: create, read, update and delete.
Recap:
Manual: http://docs.mongodb.org/master/MongoDB-manual.pdf
(Focus on Ch. 3, 4 for now)
Dataset: http://docs.mongodb.org/manual/reference/bios-example-collection/
• Create
– db.collection.insert( <document> )
– db.collection.save( <document> )
– db.collection.update( <query>, <update>, { upsert: true } )
• Read
– db.collection.find( <query>, <projection> )
– db.collection.findOne( <query>, <projection> )
• Update
– db.collection.update( <query>, <update>, <options> )
• Delete
– db.collection.remove( <query>, <justOne> )
Objective:
In this topic we focus on Most NoSQL and NewSQL data stores
which implement some sort of horizontal partitioning or sharding,
which involves storing sets or rows/records into different segments
(or shards) which may be located on different servers.
Recap:
In RDBMS In MongoDB
Either insert the 1st document
• You can put condition on any field in the document (even _id)
Equivalent to in SQL:
Two
operators
Query Condition
New
doc
For the document having item = “BE10”, replace it with the given document
Objective:
In this topic we focus on MongoDB uses multikey indexes to index
the content stored in arrays. When you index on a column that holds
an array value, MongoDB creates separate index entries for every
element of the array. These multikey indexes allow queries to select
documents that contain arrays by matching on element or elements
of the arrays.
Recap:
Revision of DBMS architecture.
• Indexes support the efficient resolution of queries. Without indexes, MongoDB must
scan every document of a collection to select those documents that match the query
statement. This scan is highly inefficient and require MongoDB to process a large
volume of data.
• Indexes are special data structures, that store a small portion of the data set in an
easy-to-traverse form. The index stores the value of a specific field or set of fields,
ordered by the value of the field as specified in the index.
• Syntax
• The basic syntax of createIndex() method is as follows().
• >db.COLLECTION_NAME.createIndex({KEY:1})
• Here key is the name of the field on which you want to create index and 1 is for
ascending order. To create index in descending order you need to use -1.
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 107
IT 05
Indexing and ordering datasets (MongoDB)
Example
>db.mycol.createIndex({"title":1})
{
"createdCollectionAutomatically" : false,
"numIndexesBefore" : 1,
"numIndexesAfter" : 2,
"ok" : 1
}
>
In createIndex() method you can pass multiple fields, to create index on multiple
fields.
>db.mycol.createIndex({"title":1,"description":-1})
>
>db.COLLECTION_NAME.dropIndexes()
Example
Assume we have created 2 indexes in the named mycol collection as shown below −
> db.mycol.createIndex({"title":1,"description":-1})
Following example removes the above created indexes of mycol −
>db.mycol.dropIndexes({"title":1,"description":-1})
{ "nIndexesWas" : 2, "ok" : 1 }
>The getIndexes() method
This method returns the description of all the indexes int the collection.
Syntax
Following is the basic syntax od the getIndexes() method −
db.COLLECTION_NAME.getIndexes()
Example
Assume we have created 2 indexes in the named mycol collection as shown below −
> db.mycol.createIndex({"title":1,"description":-1})
Objective:
In this topic we focus on Capped collections are fixed-size collections
that support high-throughput operations that insert and retrieve
documents based on insertion order.
Recap:
Revision of NOSql architecture.
Store log information generated by high-volume systems. Inserting documents in a capped collection
without an index is close to the speed of writing log information directly to a file system.
Furthermore, the built-in first-in-first-out property maintains the order of events, while managing
storage use.
Cache small amounts of data in a Mr.
12/27/2024
capped collections. Since caches are read rather than write heavy,
Rajkumar Gupta ACSAI0402 DBMS UN 113
you would either need to ensure that
IT 05this collection always remains in the working set (i.e. in RAM) or
Capped Collections
_id Index
Capped collections have an _id field and an index on the _id field by default.
Restrictions and Recommendations Updates
If you plan to update documents in a capped collection, create an index so that these update
operations do not require a collection scan.
Document Size Changed in version 3.2.
If an update or a replacement operation changes the document size, the operation will fail.
Document Deletion
You cannot delete documents from a capped collection. To remove all documents from a collection,
use the drop() method to drop the collection and recreate the capped collection.
Sharding
You cannot shard a capped collection.
Query Efficiency
Use natural ordering to retrieve the most recently inserted elements from the collection efficiently.
This is similar to using the tail command on a log file.
Aggregation $out
The aggregation pipeline stage $out cannot write results to a capped collection.
Transactions
Starting in MongoDB 4.2, you cannot write to capped collections in transactions. Reads from capped
collections are still supported in transactions.
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 114
IT 05
Capped Collections
• Procedures
• Create a Capped Collection
• You must create capped collections explicitly using the db.createCollection()
method, which is a helper in the mongo shell for the create command. When
creating a capped collection you must specify the maximum size of the
collection in bytes, which MongoDB will pre-allocate for the collection. The size
of the capped collection includes a small amount of space for internal overhead.
• db.createCollection( "log", { capped: true, size: 100000 } )
• If the size field is less than or equal to 4096, then the collection will have a cap
of 4096 bytes. Otherwise, MongoDB will raise the provided size to make it an
integer multiple of 256.
• Additionally, you may also specify a maximum number of documents for the
collection using the max field as in the following document:
• The size parameter specifies the size of the capped collection in bytes.
• This holds a database exclusive lock for the duration of the operation. Other
operations which lock the same database will be blocked until the operation
completes. See What locks are taken by some common client operations? for
operations that lock the database.
• Tailable Cursor
• You can use a tailable cursor with capped collections. Similar to the Unix tail -f
command, the tailable cursor "tails" the end of a capped collection. As new
documents are inserted into the capped collection, you can use the tailable
cursor to continue retrieving documents.
a) Upper
b) Unique
c) Update
d) Uppercase
a) To retrieve data
b)To fetch data
c)Both A. and B.
d)None of the above
Objective:
In this topic we focus on cloud database which is a database service
built and accessed through a cloud platform. It serves many of the
same functions as a traditional database with the added flexibility of
cloud computing. Users install software on a cloud infrastructure to
implement the database.
Recap:
Key features:
• Scalability
• Cloud databases can expand their storage capacities on run-time to
accommodate changing needs. Organizations only pay for what they use.
• Disaster recovery
• In the event of a natural disaster, equipment failure or power outage,
data is kept secure through backups on remote servers.
• Users can opt for a virtual machine image managed like a traditional database or a provider’s
database as a service (DBaaS).
• Database technology
• SQL databases are difficult to scale but very common. NoSQL databases scale more easily but
do not work with some applications.
• Security
• Most cloud database providers encrypt data and provide other security measures;
organizations should research their options.
• Maintenance
• When using a virtual machine image, one should ensure that IT staffers can maintain the
underlying infrastructure.
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 123
IT 05
Cloud database: - Introduction of Cloud database
• Platform as a service(PaaS)
• Software as a service(SaaS)
• Infrastructure as a service(IaaS)
• Platform as a service or PaaS is the most common type here, providing the provision of servers,
data storage, and operating systems. It helps in the storage and acts as a platform for the virtual
database, saving the hardware cost and helping to access the data from all around the world.
• SaaS, on the other hand, provides the entire software as a service to the organization in exchange
for an amount and is an excellent business option for all those organizations involving a lot of web
users.
• CLOUCloud computing is on a rise because of the flexibility and the ease of services
that it provides. Several well-known IT giants are planning to capture the market.
Most of the cloud databases run on the well-known cloud computing platforms like
Rackspace, salesforce, GoGrid, and Amazon EC2.
• Here are the top five most beneficial cloud services for data storage.
Objective:
In this topic we focus on NoSQL databases are specifically designed
for low cost commodity hardware. These databases are mostly used
for storage and access of data across multiple storage cluster. For
example Google, Facebook, Google+, Google big table, Amazon
Dynamo, Twitter etc. collects and stores Terabytes of data for their
user every day.
Recap:
Most of the time (and for most of the remainder of this page), the
term “cloud database” refers to a cloud-based database-as-a-service.
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 127
IT 05
NoSQL with Cloud Database
• Why use a cloud database/DBaaS?
• The key benefits of cloud databases are that they are accessible from anywhere, scalable from day one,
and designed for reliability and performance.
• Common cloud database use cases
• Cloud databases work in most cases that traditional databases do. They are particularly valuable when
building software products that:
• Are cloud-native
• Database Technology
• Management System
• Cost Model
• Security
• Extras
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 129
IT 05
NoSQL with Cloud Database
• Simplified management
• Elastic autoscaling
• Charts
• Connectors
• Schema navigator
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 130
IT 05
NoSQL with Cloud Database
• The way a cloud database works is that rather than installing, configuring,
and maintaining a database instance or instances, an automated system is
able to provision, manage, and scale the underlying database cluster for you.
Objective:
In this topic we focus on cloud database which is a database service
built and accessed through a cloud platform. It serves many of the
same functions as a traditional database with the added flexibility of
cloud computing. Users install software on a cloud infrastructure to
implement the database.
Recap:
Definition
• Telecommunication Systems
– Routers and network management systems
– Telephone switching systems
• Control Systems
– Automatic tracking and object positioning
– Engine control in automobiles
• Multimedia servers for real-time streaming
• E-commerce and e-buisness
– Stock market: program stock trading
– Financial services: credit card transactions
• Web-based data services
• Soft-Deadline:
– desirable but not critical
– missing a soft-deadline does not cause a system failure or
compromises the system’s integrity
– Example: operator switchboard for a telephone
v(t)
Soft deadline
v0
• Firm-Deadline:
– Desirable but not critical (like Soft-Deadline case)
– It is not executed after its deadline and no value is gained by the
system from the tasks that miss their deadlines
– Example: an autopilot system
v(t)
Firm deadline
v0
d t
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 139
IT 05
Introduction to Real time Database.
Deadlines
• Hard-Deadline:
– Timely and logically correct execution is considered to be critical
– Missing a hard-deadline can result in catastrophic consequences
– Also known as Safety-Critical
– Example: data gathered by a sensor
v(t)
v0
Hard deadline
12/27/2024 d
Mr. Rajkumar Gupta ACSAI0402 DBMS UN t 140
IT 05
Introduction to Real time Database.
Design Paradigms
• Time-Triggered (TT)
– Systems are initiated as predefined instances
– Assessments of resource requirements and resource availability is
required
– TT architecture can provide predictable behavior due to its pre-planed
execution pattern.
• Prosodic Tasks
– Executes at regular intervals of time
– Corresponds to TT architecture
– Have Hard-Deadlines characterized by their periods (requires worst-
case analysis).
• Aperiodic Tasks
– Execution time cannot be priori anticipated
– Activation of tasks is random event caused by a trigger
– Corresponds to ET architecture
– Have Soft-Deadlines (no worst-case analysis)
• Sporadic Tasks
• Tasks which are aperiodic in nature, but have Hard-Deadlines
• Used to handle emergency conditions or exceptional situations
• Worst-case calculations is done using Schedulability-Constraint
• Schedulability-Constraint defines a minimum period between any two
sporadic events from the same source.
Scheduling
Scheduling (Cont)
– Non-preemptive
• A task must be rum without interruption until completion
• Hybrid
– Preemptive scheduler, but preemption is only allowed at
certain points within the code of each task.
• Real-Time scheduling algorithms can be :
– Static
» Known as fixed-priority where priorities are computed
off-line
» Requires complete priori knowledge of the real-time
environment in which is deployed
» Inflexible: scheme is workable only if all the tasks are
effectively periodic.
» Can work only for simple systems, performs inconsistently
as the load increases.
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 146
IT 05
Introduction to Real time Database.
Scheduling (Continue)
• Dynamic
– Assumes unpredictable task-arrival times
– Attempts to schedule tasks dynamically upon arrival
– Dynamically computes and assigns a priority value to each
task
– Decisions are based on task characteristics and the current
state of the system
– Flexible scheduler that can deal with unpredictable events.
Priority-Based Scheduling
Priority-Based Scheduling
Methods
• Earliest-Deadline-First (EDF):
• the task with the current closest (earliest) deadline is
assigned the highest priority in the system and executed
next
• Value-Functions : highest value (benefit) first
• the scheduler is required to assign priorities as well as
defining the system values of completing each task at any
instant in time
Synchronization (Continue)
Conventional Databases:
ACID Properties
Conventional Databases:
ACID Properties (Cont.)
• Strict: Read and write only committed written data. That is, if transaction
Tj reads from Ti, or overwrites a data item that was last written by Ti, then
Ti must be an already committed transaction; i.e.,
– Wi [x] → Rj [x] ⇒ Ci → Cj
Wj [x] ⇒ Ci → Cj
• Real-time systems
• Task centric
– Deadlines attached to tasks
• Real-time databases
• Data centric
– Data has temporal validity, i.e., deadlines also attached to data
– Transactions must be executed by deadline to keep the data
valid, in addition to produce results in a timely manner
– Terminating abort:
• An abort due to missing a deadline, or
• Self-abort – a transaction may abort itself due to an exceptional
condition.
• Deadlocks
– Whenever a set of transactions gets involved in a circular wait
in what is known as a wait-for graph
– Five deadlock resolution policies that take into account :
• the timing properties of the transactions
• the cost of abort operations
• Policy 1:
– Always aborts the transaction invoking deadlock detection.
• Policy 2:
– Trace the deadlock cycle
– abort the first tardy transaction encountered in a deadlock cycle.
– If no tardy transaction is found, abort the transaction with the
furthest deadline.
• Policy 3:
– Trace the deadlock cycle
– abort the first tardy transaction encountered in a deadlock cycle.
– If no tardy transaction is found, abort the transaction with the earliest
deadline.
• Policy 4:
– Trace the deadlock cycle, and abort the first tardy transaction
encountered in a deadlock cycle.
– If no tardy transaction is found, abort the transaction with the least
criticalness.
• Policy 5:
– Abort the infeasible transaction with the least criticalness.
– If all transactions are feasible, then abort a feasible transaction with
the least criticalness.
– This policy is sensitive to the accuracy of the computation time
because it requires information about remaining execution time
– So; Total execution time requirements at the start of each transaction
must be known.
• Admission Controller:
• Reject transaction
• Admit contingency action
• Scheduler:
• Drop transaction (firm/soft)
• Replace transaction with contingency action (hard)
• Postpone transaction execution (soft)
1. Most NoSQL databases support automatic __________ meaning that you get high
availability and disaster recovery.
(a) processing
(b) scalability
(c) replication
(d) all of the mentioned
3.________ stores are used to store information about networks, such as social connections.
(a) Key-value
(b) Wide-column
(c) Document
(d) Graph
12/27/2024 Mr. Rajkumar Gupta ACSAI0402 DBMS UN 181
IT 05
MCQ
4. NoSQL databases is used mainly for handling large volumes of ______________ data.
(a) unstructured
(b) structured
(c) semi-structured
(d) all of the mentioned
Assignment
Q1: What are NoSQL databases? What are the different types of NoSQL databases?
Q3: Explain difference between scaling horizontally and vertically for databases
Q7: Does MongoDB support ACID transaction management and locking functionalities?
Q9: How can you achieve primary key - foreign key relationships in MongoDB?
http://www.nptelvideos.com/lecture.php?id=6516
http://www.nptelvideos.com/lecture.php?id=6517
http://www.nptelvideos.com/lecture.php?id=6518
http://www.nptelvideos.com/lecture.php?id=6519
https://www.youtube.com/watch?v=2yQ9TGFpDuM