Comprehensive Guide to Databases

Comprehensive Guide to Databases

Day 46 of 60 : Complete Overview of Database Management Systems

What is Data?

  • Data is a collection of a distinct small unit of information.

  • It can be used in a variety of forms like text, numbers, media, bytes, etc.

  • it can be stored in pieces of paper or electronic memory, etc.

  • Word 'Data' is originated from the word 'datum' that means 'single piece of information.'

  • It is plural of the word datum.

  • In computing, Data is information that can be translated into a form for efficient movement and processing.

  • Data is interchangeable.

What is Database?

  • A database is an organized collection of data, so that it can be easily accessed and managed.

  • You can organize data into tables, rows, columns, and index it to make it easier to find relevant information.

  • You can organize data into tables, rows, columns, and index it to make it easier to find relevant information.

  • A database is an organized collection of data stored in a computer system and usually controlled by a database management system (DBMS).

  • A database is a collection of data that is organized, which is also called structured data.

  • It can be accessed or stored in a computer system.

  • It can be managed through a Database Management System (DBMS), a software used to manage data. Database refers to related data in a structured form.

  • In a database, data is organized into tables consisting of rows and columns and it is indexed so data can be updated, expanded, and deleted easily.

Types of Databases :

1)Relational Database :

  • Relational Database is also know as SQl Database.

  • In SQL Database data is stored in Table .

  • 1970 - Present: It is the era of Relational Database and Database Management.

  • In 1970, the relational model was proposed by E.F. Codd.

  • Relational database model has two main terminologies called instance and schema.

  • The instance is a table with rows or columns

  • Schema specifies the structure like name of the relation, type of each column and name

  • This model uses some mathematical concept like set theory and predicate logic.

  • The first internet database application had been created in 1995.

  • During the era of the relational database, many more models had introduced like object-oriented model, object-relational model, etc.

  • Some examples of NoSQL database system with their category are:

    • MySQl

    • Oracle

    • Postgre SQl

2) Non-Relational Database :

  • Non- Relational Database is also know as No-SQl Database.

  • Data is not stored in table format

  • A NoSQL database is an approach to design such databases that can accommodate a wide variety of data models.

  • NoSQL stands for "not only SQL." It is an alternative to traditional relational databases in which data is placed in tables, and data schema is perfectly designed before the database is built.

  • NoSQL databases are useful for a large set of distributed data.

  • Some examples of NoSQL database system with their category are:

    • MongoDB, CouchDB, Cloudant (Document-based)

    • Memcached, Redis, Coherence (key-value store)

    • HBase, Big Table, Accumulo (Tabular)

What is DBMS?

  • DBMS provides the interface to perform the various operations like creation, deletion, modification, etc.

  • DBMS allows the user to create their databases as per their requirement.

  • DBMS accepts the request from the application and provides specific data through the operating system.

  • DBMS contains the group of programs which acts according to the user instruction.

  • It provides security to the database..

  • Database management System is software which is used to store and retrieve the database.

  • For example, Oracle, MySQL, etc.; these are some popular DBMS tools.

Advantage of DBMS

Controls redundancy

It stores all the data in a single database file, so it can control data redundancy.

Data sharing

An authorized user can share the data among multiple users.

Backup

It providesBackup and recovery subsystem. This recovery system creates automatic data from system failure and restores data if required.

Multiple user interfaces

It provides a different type of user interfaces like GUI, application interfaces.

Disadvantage of DBMS

Size

It occupies large disk space and large memory to run efficiently.

Cost

DBMS requires a high-speed data processor and larger memory to run DBMS software, so it is costly.

Complexity

DBMS creates additional complexity and requirements.

Database Challenges

Below are some challenges of Database.

  • absorbing substantial increases in the amount of data. Database administrators are constantly juggling the deluge of data pouring in from sensors, connected devices, and dozens of other sources in an attempt to effectively manage and organize the data of their organizations.

  • ensuring the safety of data. These days, data breaches are commonplace, and hackers are becoming more resourceful. Making sure that data is both easily available to users and secure is more crucial than ever.

  • meeting the demands. Companies require real-time access to their data in today’s fast-paced business climate in order to support prompt decision-making and seize new opportunities.

  • Taking care of and managing the infrastructure and database. Database administrators are responsible for doing preventive maintenance, applying software patches and upgrades, and continuously monitoring the database for issues.

  • removing scalability restrictions. If a business is to thrive, it must expand, and as a result, so too must its data management. However, database administrators find it extremely challenging to forecast the amount of capacity that a business will require, especially when dealing with on-premises databases.

  • ensuring latency needs, data sovereignty, or residence. Certain businesses have use cases that are more appropriate for on-premises deployment. Under such circumstances, pre-optimized and pre-configured engineered systems are perfect for executing the database.

SQL Create Database :

  • n SQL, the 'Create Database' statement is a first step for storing the structured data in the database.

  • The database developers and the users use this statement in SQL for creating the new database in the database systems.

  • It creates the database with the name which has been specified in the Create Database statement.

Syntax of Create Database statement in SQL

  1. CREATE DATABASE Database_Name;
  • In this syntax, Database_Name specifies the name of the database which we want to create in the system.

  • We have to type the database name in query just after the 'Create Database' keyword.

  • Following are the most important points which are required to learn while creating a database:

    • The database we want to create should be a simple and unique name, which can be easily identified.

    • Database name should be no more than 128 characters.

  • You can also verify that your database is created in SQL or not by using the following query:
  1. SHOW DATABASE ;
  • SQL does not allow developers to create the database with the existing database name.

  • Suppose if you want to create another Student database in the same database system, then the Create Database statement will show the following error in the output:

Can't create database 'Student'; database exists
  • So, firstly you have to delete the existing database by using the Drop Statement.

  • You can also replace the existing database with the help of Replace keyword.

If you want to replace the existing Student database, then you have to type the following SQL query:

  1. CREATE OR REPLACE DATABASE Student ;

Example:

Suppose, we want to create the Employee database in the system.

Firstly, we have to type the following command in Structured Query Language:

  1. CREATE DATABASE Employee ;

When this query is executed successfully, then it will show the following output:

Database created successfully

You can also check that your database is created in SQL by typing the following query:

  1. SHOW DATABASE ;

SQL DROP Database :

  • The SQL Drop Database statement deletes the existing database permanently from the database system.

  • This statement deletes all the views and tables if stored in the database, so be careful while using this query in SQL.

  • Following are the most important points which are required to learn before removing the database from the database system:

    • This statement deletes all the data from the database. If you want to restore the deleted data in the future, you should keep the backup of data of that database which you want to delete.

    • Another most important point is that you cannot delete that database from the system which is currently in use by another database user. If you do so, then the drop statement shows the following error on screen:

    • Cannot drop database "name_of_the_database" because it is currently in use

Syntax of Drop Database Statement in SQL

  1. DROP DATABASE Database_Name;

In this SQL syntax, we have to specify the name of that database which we want to delete permanently from the database system. We have to write the name of the database after the DROP DATABASE keyword in every example.

We can also delete multiple databases easily by using the single DROP syntax

  1. DROP DATABASE Database_Name1, [ Database_Name2, ......., Database_NameN ]

SQL RENAME Database

  • In some situations, database users and administrators want to change the name of the database for some technical reasons.

  • So, the Rename Database statement in SQL is used to change the name of the existing database.

  • Sometimes, the Rename Database statement is used because the developers think that the original name is not more relevant to the data of the database, or they want to give a temporary name to that database.

Syntax of Rename Database in SQL

  1. ALTER DATABASE old_database_name MODIFY NAME = new_database_name;
  1. EXEC sp_renamedb'old_database_name' , 'new_database_name'

Syntax of Rename Database in MySQL

  1. RENAME DATABASE old_database_name TO new_database_name;

This syntax is used when we want to change the name of the database in MySQL.