Professional Documents
Culture Documents
1. Create a database, and table, insert values, and queries using SQL codes.
Create a database, and create 3 tables with proper attributes. Insert at least 3 values
in each table. Apply 3 SQL queries.
Advantages of DBMS –
• Data Independence - Application programs should be as independent as possible
from details of data representation and storage. The DBMS can provide an abstract
view of the data to insulate application code from such details.
• Efficient Data Access - A DBMS utilizes a variety of sophisticated techniques to
store and retrieve data efficiently. This feature is especially important if the data is
stored on external storage devices.
• Data Integrity and Security - If data is always accessed through the DBMS, the
DBMS can enforce integrity constraints on the data. For example, before inserting
salary information for an employee, the DBMS can check that the department
budget is not exceeded. Also, the DBMS can enforce access controls that govern
what data is visible to different classes of users.
• Concurrent Access and Crash Recovery - A database system allows several users
to access the database concurrently. Answering different questions from different
users with the same (base) data is a central aspect of an information system. Such
concurrent use of data increases the economy of a system. An example of
concurrent use is the travel database of a bigger travel agency. The employees of
different branches can access the database concurrently and book journeys for their
clients. Each travel agent sees on his interface if there are still seats available for a
specific journey or if it is already fully booked.
• A DBMS also protects data from failures such as power failures and crashes etc. by
the recovery schemes such as backup mechanisms and log files etc.
• Data Administration - When several users share the data, centralizing the
administration of data can offer significant improvements. Experienced
professionals, who understand the nature of the data being managed, and how
different groups of users use it, can be responsible for organizing the data
representation to minimize redundancy and fine-tuning the storage of the data to
make retrieval efficient.
• Reduced Application Development Time - DBMS supports many important
functions that are common to many applications accessing data stored in the
DBMS. This, in conjunction with the high-level interface to the data, facilitates the
quick development of applications. Such applications are also likely to be more
robust than applications developed from scratch because many important tasks are
handled by the DBMS instead of being implemented by the application.
DISADVANTAGES OF DBMS -
• The danger of Overkill - For small and simple applications for single users a
database system is often not advisable.
• Complexity - A database system creates additional complexity and requirements.
The supply and operation of a database management system with several users and
databases is quite costly and demanding.
• Qualified Personnel - The professional operation of a database system requires
appropriately trained staff. Without a qualified database administrator, nothing will
work for long.
• Costs - Through the use of a database system, new costs are generated for the
system itself but also for additional hardware and the more complex handling of
the system.
• Lower Efficiency - A database system is a multi-use software that is often less
efficient than specialized software which is produced and optimized exactly for
one problem.
Advantages of MYSQL -
• Data Protection - It is one of the most popular database management systems in
terms of security and dependability. It is used in many web applications, including
Twitter, Facebook, Joomla, Drupal, and WordPress. For transactional processing,
data support and security might be beneficial to your organization, particularly if
you work in the e-commerce industry.
• Scalability on Demand - This platform’s incredible scalability can help with the
management of embedded applications. This is true even if there is a big
warehouse with massive amounts of data. In fact, one of the system’s major
characteristics is on-demand adaptability. The benefit of this open-source platform
is that it allows for complete customization, which is very useful if you have an
eCommerce store to manage.
• High Efficiency - My SQL includes a unique storage engine that makes it easier to
administer your system. Furthermore, you may configure the MySQL database
server to achieve peak performance. In other words, even if you have a high-speed
processing system or a website that receives millions of hits every day, you may
benefit from this technology.
• 24/7 Uptime - The MySQL system is unique in that it assures continuous uptime.
Aside from that, it provides a plethora of options, such as slave/master replication
settings and unique cluster servers.
• Outstanding Transactional Support - MySQL is at the top of the list of fast
transactional database solutions available today. It has several features, such as
consistent and automated transaction support. Aside from that, it is one of the
greatest options for complete data integrity.
• Excellent Workflow Control - You don’t need to set aside much time to set up this
program because downloading and installation take less than 30 minutes. You may
make use of the advantages of this fantastic solution regardless of your platform. It
may be used to automate a wide range of processes, including database
management, data design, and space growth.
• Lower Total Ownership Cost - You may save a lot of money if you convert your
existing database programs to this platform. The simplicity of management and
dependability might aid in troubleshooting. As a result, you will not experience
any downtime or performance difficulties.
Disadvantages Of MySQL –
• MySQL does not support a huge database size efficiently.
• It is challenging to debug stored procedures.
• MySQL is not fully SQL compliant. Because of this, developers find it challenging
to cope with the syntax of SQL in MySQL.
NoSQL
SQL
Horizontally scalable
Vertically Scalable
• Data Redundancy and Inconsistency - Since files and application programs are
created by different programmers over a long period of time, the files are likely to
be having different formats and the programs may be written in several
programming languages. Moreover, the same piece of information may be
duplicated in several places. This redundancy leads to higher storage and access
cost. In addition, it may lead to data inconsistency.
• Difficulty in Accessing Data - The conventional file processing environments do
not allow needed data to be retrieved in a convenient and efficient manner. Better
data retrieval system must be developed for general use.
• Data Isolation - Since data is scattered in various files, and files may be in different
formats, it is difficult to write new application programs to retrieve the appropriate
data.
• Concurrent Access Anomalies - In order to improve the overall performance of the
system and obtain a faster response time, many systems allow multiple users to
update the data simultaneously. In such an environment, the interaction of
concurrent updates may result in inconsistent data.
• Security Problems - Not every user of the database system should be able to access
all the data. For example, in the banking system, payroll personnel need only that
part of the database that has information about various bank employees. They do
not need access to information about customer accounts. It is difficult to enforce
such security constraints.
• Integrity Problems - The data values stored in the database must satisfy certain
types of consistency constraints. For example, the balance of a bank account may
never fall below a prescribed amount. These constraints are enforced in the system
by adding appropriate code in the various application programs. When new
constraints are added, it is difficult to change the programs to enforce them. The
problem is compounded when constraints involve several data items for different
files.
• Atomicity Problem - A computer system like any other mechanical or electrical
device is subject to failure. In many applications, it is crucial to ensure that once a
failure has occurred and has been detected, the data are restored to the consistent
state that existed prior to the failure.
6. Explain all the different types of database users.
• System Analyst:
System Analyst is a user who analyzes the requirements of parametric end users. They
check whether all the requirements of end users are satisfied.
• Sophisticated Users:
Sophisticated users can be engineers, scientists, and business analysts, who are familiar
with the database. They can develop their own database applications according to their
requirement. They don’t write the program code but they interact with the database by
writing SQL queries directly through the query processor.
Fragmentation is a process of dividing the whole or full database into various sub-tables
or sub-relations so that data can be stored in different systems. The small pieces of sub-
relations or sub-tables are called fragments. These fragments are called logical data units
and are stored at various sites.
All of these fragments are independent which means these fragments cannot be derived
from others. The users needn’t be logically concerned about fragmentation which means
they should not concern that the data is fragmented and this is called fragmentation
Independence or we can say fragmentation transparency.
Advantages:
• As the data is stored close to the usage site, the efficiency of the database system will
increase.
• Local query optimization methods are sufficient for some queries as the data is available
locally.
• In order to maintain the security and privacy of the database system, fragmentation is
advantageous.
Disadvantages:
• Access speeds may be very high if data from different fragments are needed.
• If we are using recursive fragmentation, then it will be very expensive.
Types –
• Horizontal data fragmentation
Horizontal fragmentation divides a relation(table) horizontally into a group of rows to
create subsets of tables.
Example:
Account (Acc_No, Balance, Branch_Name, Type).
In this example, if values are inserted in table Branch_Name as Pune, Baroda, Delhi.
The query can be written as:
SELECT*FROM ACCOUNT WHERE Branch_Name= “Baroda”.
• Vertical Fragmentation
Vertical fragmentation divides a relation(table) vertically into groups of columns to
create subsets of tables.
Example:
Acc_No Balance Branch_Name
A_101 5000 Pune
A_102 10,000 Baroda
A_103 25,000 Delhi
Fragmentation1:
SELECT * FROM Acc_No
Fragmentation2:
SELECT * FROM Balance
• Hybrid Fragmentation
Hybrid fragmentation can be achieved by performing horizontal and vertical partitions
together.
Mixed fragmentation is a group of rows and columns in relation.
Fragmentation1:
SELECT * FROM Emp_Name WHERE Emp_Age < 40
Fragmentation2:
SELECT * FROM Emp_ID WHERE Emp_Address= 'Pune' AND Salary < 14000.
8. Explain 3 major problems in DBMS.
• Atomicity - When a bunch of tasks is coming at the same point of time as DBMS is
used by multiple users.
It is essential to database consistency that either both the credit and debit occur, or that
neither occurs. That is, the funds’ transfer must be atomic—it must happen in its
entirety or not at all. It is difficult to ensure atomicity in a conventional file-processing
system.
• Integrity - When tables are distributed with different users, they can change the values
however they want. No one should get the allowance of altering the data. This has
been solved by RDBMS.
As the database is getting updated in real-time, so it is required that data remains
accurate during operations. For that some technical safeguards are necessary. Several
users attempting to update the data create the main threat to data integrity.
• Concurrency - When multiple transactions execute concurrently in an uncontrolled or
unrestricted manner, then it might lead to several problems. These problems are
commonly referred to as concurrency problems in a database environment. The five
concurrency problems that can occur in the database are:
➢ Temporary Update Problem
➢ Incorrect Summary Problem
➢ Lost Update Problem
➢ Unrepeatable Read Problem
➢ Phantom Read Problem.
➢ Weak entity - A weak entity type is a dependent table that relies on another table
for its existence; it has no meaningful attributes of its own except for the foreign
key from the parent table.
➢ Strong Entity - A strong entity in DBMS is an independent table that doesn't rely
on any other tables for its existence. A primary key uniquely identifies each row in
the table, and foreign keys are used to relate this table to other tables.
DML –
• DML stands for Data Manipulation Language. Using DML commands in SQL, we
can make changes in the data present in tables.
• Whenever we wish to manipulate the data or fetch the data present in SQL tables,
we can use DML commands in SQL.
• DML commands in SQL will change the data, such as inserting new records, or
deleting or updating existing records from the SQL tables. We can also retrieve all
the data from SQL tables according to our requirements.
• Commands covered under DDL are:
➢ INSERT
➢ SELECT
➢ UPDATE
➢ DELETE
DCL –
TCL –
• TCL stands for Transaction Control Language. TCL commands are generally used
in transactions.
• Using TCL commands in SQL, we can save our transactions to the database and
roll them back to a specific point in our transaction. We can also save a particular
portion of our transaction using the SAVEPOINT command.
• Commands covered under TCL are:
➢ COMMIT
➢ ROLLBACK
➢ SAVEPOINT
DQL –
• More Reliable − In case of database failures, the total system of centralized databases
comes to a halt. However, in distributed systems, when a component fails, the
functioning of the system continues may be at a reduced performance. Hence DDBMS is
more reliable.
• Better Response − If data is distributed in an efficient manner, then user requests can be
met from local data itself, thus providing a faster response. On the other hand, in
centralized systems, all queries have to pass through the central computer for processing,
which increases the response time.
Disadvantages of DDBMS -
• Complex nature:
Distributed Databases are a network of many computers present at different locations and
they provide an outstanding level of performance, availability, and of course reliability.
Therefore, the nature of Distributed DBMS is comparatively more complex than a
centralized DBMS. Complex software is required for Distributed DBMS. Also, it ensures
no data replication, which adds even more complexity to its nature.
• Overall Cost:
Various costs such as maintenance cost, procurement cost, hardware cost,
network/communication costs, labor costs, etc., add up to the overall cost and make it
costlier than normal DBMS.
• Security issues:
In a Distributed Database, along with maintaining no data redundancy, the security of
data, as well as a network, is a prime concern. A network can be easily attacked for data
theft and misuse.
• Integrity Control:
In a vast Distributed database system, maintaining data consistency is important. All
changes made to data at one site must be reflected on all the sites. The communication
and processing cost is high in Distributed DBMS in order to enforce the integrity of data.
• Lacking Standards:
Although it provides effective communication and data sharing, still there are no standard
rules and protocols to convert a centralized DBMS to a large Distributed DBMS. Lack of
standards decreases the potential of Distributed DBMS.
Data Replication -
Data replication is the process of storing separate copies of the database at two or more
sites. It is a popular fault tolerance technique of distributed databases.
Advantages of Data Replication -
• Reliability − In case of failure of any site, the database system continues to work since a
copy is available at another site(s).
• Reduction in Network Load − Since local copies of data are available, query processing
can be done with reduced network usage, particularly during prime hours. Data updating
can be done during non-prime hours.
• Quicker Response − Availability of local copies of data ensures quick query processing
and consequently quick response time.
• Increased Cost and Complexity of Data Updating − Each time a data item is updated,
the update needs to be reflected in all the copies of the data at the different sites. This
requires complex synchronization techniques and protocols.
➢ Snapshot replication
➢ Near-real-time replication
➢ Pull replication.
14.How data replication helps to protect against the loss of data?
Data replication involves copying data from one location and creating another exact copy
version in another location. For example, data can be replicated between two onsite
servers, between servers in different locations, across multiple storage mediums on the
same server, and to and from a cloud-based host.
How Data Replicates –
➢ Between two onsite servers.
➢ Between servers in different locations.
➢ Across multiple storage mediums on the same server.
➢ To and from a cloud-based host.
You’ll have the option to copy data instantly, transfer it in large chunks or small
batches, set a schedule for when you want data moved, and replicate data in real time
as the master server’s data is written, changed, or deleted completely.
Additionally, you can use full replication where a full database is copied to each
server location or partial replication where only some of the most frequently used data
is replicated across servers.
Replicating data can occur over a local area network, a storage area network, a local
wide area network, or through the cloud.
Being a NoSQL tool means that it does not use the usual rows and columns that you so
much associate with relational database management. It is an architecture that is built on
collections and documents. The basic unit of data in this database consists of a set of key-
value pairs. It allows documents to have different fields and structures. This database
uses a document storage format called BSON which is a binary style of JSON
documents.
The data model that MongoDB follows is a highly elastic one that lets you combine and
store data of multivariate types without having to compromise on powerful indexing
options, data access, and validation rules. There is no downtime when you want to
dynamically modify the schemas. What it means is that you can concentrate more on
making your data work harder rather than spending more time preparing the data for the
database.
MongoDB is a NoSQL (Not only SQL) database that stores large volumes of data in the
form of documents. MongoDB removes the concept of rows of conventional and
relational data models by introducing documents. This offers the developers the
flexibility to work with evolving data models.
MongoDB Advantages -
• MongoDB is schema-less. It is a document database in which one collection holds
different documents.
• There may be a difference between the number of fields, content, and size of the
document from one to another.
• Structure of a single object is clear in MongoDB.
• There are no complex joins in MongoDB.
• MongoDB provides the facility of deep query because it supports a powerful
dynamic query on documents.
• It is very easy to scale.
• It uses internal memory for storing working sets and this is the reason for its fast
access.
Disadvantages Of MongoDB -
• Joins not Supported - MongoDB doesn’t support joins like a relational database.
Yet one can use joins functionality by adding by coding it manually. But it may
slow execution and affect performance.
• High Memory Usage - MongoDB stores key names for each value pair. Also, due
to the no functionality of joins, there is data redundancy. This results in increasing
unnecessary usage of memory.
• Limited Data Size - You can have a document size, of not more than 16MB.
• Limited Nesting - You cannot perform the nesting of documents for more than 100
levels.
5 commands of mongo dB -
• show dbs.
• use DATABASE_NAME.
• db.
• db.dropDatabase ()
• db.createCollection(name)
16. Aggregate functions of Mongo dB.
For performing such an aggregate function, the aggregate () method is used. The syntax
of this method looks something like this:
db. collection_name. aggregate(aggregate_operation);
$min finds and returns the minimum of all values from within a
collection.
$max finds and returns the maximum of all values from within a
collection.