Author: Md Jakaria Nur

  • Bubble Sort Algorithms

    Bubble Sort Algorithm

    Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in the wrong order. This algorithm is not suitable for large data sets as its average and worst-case time complexity are quite high.

    How does Bubble Sort Work?

    Suppose we are trying to sort the elements in ascending order.

    1. First Iteration (Compare and Swap)

    1. Starting from the first index, compare the first and the second elements.
    2. If the first element is greater than the second element, they are swapped.
    3. Now, compare the second and the third elements. Swap them if they are not in order.
    4. The above process goes on until the last element

    Below is the implementation of the bubble sort. It can be optimized by stopping the algorithm if the inner loop didn’t cause any swap.

    #include <stdio.h>
    int main()
    {
    int arr[100], size, i, j, swap;

    printf(“Enter Array size: “);
    scanf(“%d”, &size);

    printf(“Enter %d integers: “, size);

    for (i=0; i<size; i++){
    scanf(“%d”, &arr[i]);
    }
    for (i=0 ; i<size-1; i++)
    {
    for (j=0; j<size-i-1; j++)
    {
    if (arr[j] > arr[j+1])
    {
    swap = arr[j];
    arr[j] = arr[j+1];
    arr[j+1] = swap;
    }
    }
    }
    printf(“\nSorted list in ascending order: \n”);
    for (i=0; i<size; i++)
    printf(“%d “, arr[i]);

    return 0;
    }

    Complexity Analysis of Bubble Sort:

    Time Complexity: O(n2)
    Auxiliary Space: O(1)

    Advantages of Bubble Sort:

    • Bubble sort is easy to understand and implement.
    • It does not require any additional memory space.
    • It is a stable sorting algorithm, meaning that elements with the same key value maintain their relative order in the sorted output.

    Disadvantages of Bubble Sort:

    • Bubble sort has a time complexity of O(n2) which makes it very slow for large data sets.
    • Bubble sort is a comparison-based sorting algorithm, which means that it requires a comparison operator to determine the relative order of elements in the input data set. It can limit the efficiency of the algorithm in certain cases.
  • Dynamic Programming

    Dynamic Programming


    Dynamic Programming is a general algorithm design technique for solving problems defined by recurrences with overlapping subproblems.

    • Invented by American mathematician Richard Bellman in the 1950s to solve optimization problems and later assimilated by CS.
    • “Programming” here means “planning.”
    • Main idea:
      • Set up a recurrence relating a solution to a larger instance to solutions of some smaller instances.
      • Solve smaller instances once.
      • Record solutions in a table.
      • Extract solution to the initial instance from that table.

    Dynamic programming is a very powerful, general tool for solving optimization problems.

    Once understood it is relatively easy to apply, but many people have trouble understanding it.

  • Inheritance in Java | OOP Fundamental Concept

    Inheritance in Java | OOP Fundamental Concept

    Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object.

    • It is an important feature of OOPs.
    • Inherited class is called as parent class or super class or base class
    • Class that inherits a parent class is called as child class or sub class or derived class
    • ‘extends’ keyword is used to inherit a class
    • Inheritance represents the IS-A relationship which is also known as a parent-child relationship.

    Method Overriding used in Inheritance

    If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in Java.
    • In other words, if a subclass provides the specific implementation of the method that has been declared by one of its parent class, it is known as method overriding.
    • Method overriding is used for runtime polymorphism

    Rules for Method Overriding

    The method must have the same name as in the parent class
    • The method must have the same parameter as in the parent class.
    • There must be an IS-A relationship (inheritance)

    ‘super’ keyword

    The super keyword is similar to this keyword.
    • It is used to differentiate the members of super_class from the members of sub_class if they have same name.
    • It is used to invoke the constructor of super_class from the sub_class. Usage of super Keyword
    1. super is used to refer immediate parent class instance variable.

    super.variable;

    2. super is used to invoke immediate parent class method.

    super.method();

    3. super() is used to invoke immediate parent class constructor.
    super();

    super is used to refer immediate parent class instance variable

    If a class is inheriting the properties of another class and if the members of the superclass have the
    names same as the sub class, to differentiate these variables we use super keyword as shown below.

    class Vehicle{
    int speed = 50;
    }
    class Bike extends Vehicle{
    int speed =100;
    void display(){
    System.out.println(super.speed);
    }
    public static void main(String args[]){
    Bike b = new Bike();
    b.display();
    }
    }

    Output: ?
    50

  • Polymorphism in Java | OOP Fundamental Concept

    Polymorphism in Java | OOP Fundamental Concept

    Two types of Polymorphism
    1. Compile-time Polymorphism : Method Overloading
    1. Run-time Polymorphism : Method Overriding

    Methods in Java

    Java Method is a collection of statements that are grouped together to
    perform a specific task.
    • A method must be declared within a class.

    Types of Methods:

    In Java, there are two types of methods:
    • Standard Library Methods: These are built-in methods in Java that are
    available to use. Such as, print(), nextInt(), sqrt() and many more
    • User-defined Methods: We can create our own method based on our
    requirements.

    Syntax of Defining a function
    modifier return_type methode_name (parameter list)
    {
    // body of the method
    }

    Here,
    • Modifier: it defines the access type of the method
    • Return_type: specifies the type of data returned by the method
    • Methode_name: name of the method
    • Parameter_list: list of parameters. It is the type, order and number of
    parameters of the method
    • Body_of_method: defines what the method does

    Categories of User-Defined Methods:
    For better understanding of arguments and return type in methods,
    user-defined methods can be categorized as:
    1. Method with no arguments and no return value
    2. Method with arguments but no return value
    3. Method with no arguments but with return value
    4. Method with arguments and return value.

    Note: *Without using object, If we want to call any method without any object, then we have to declare the method as static.

    Method Overloading in Java

    When a class has two or more methods by same name but different parameters, it is known as method overloading.
    • Method overloading increases the readability of the program.

    Different ways to overload the method
    • There are two ways to overload the method in java
    1. By changing number of arguments
    1. By changing the data type

    1. By changing number of arguments
    public class MethodOverloading {

    void sum(int a,int b)
    {
    System.out.println(a+b);
    }
    void sum(int a,int b,int c)
    {
    System.out.println(a+b+c);
    }
    public static void main(String args[]){
    MethodOverloading obj = new MethodOverloading();
    obj.sum(20,20);
    obj.sum(10,20,30);
    }
    }

    2. By changing data type of argument
    public class MethodOverloading2 {
    void sum(int a,int b)
    {
    System.out.println(a+b);
    }
    void sum(double a, double b)
    {
    System.out.println(a+b);
    }
    public static void main(String args[]){
    MethodOverloading2 obj=new MethodOverloading2();
    obj.sum(10.5,10.5);
    obj.sum(20,20);
    }
    }

    Why Method Overloading is not possible by changing the
    return type of method only?
    ❑ In java, method overloading is impossible by changing the method’s return type
    only because of ambiguity. Let’s see how ambiguity may occur:
    class Adder{
    static int add(int a,int b){return a+b;}
    static double add(int a,int b){return a+b;}
    }
    class Test{
    public static void main(String[] args){
    System.out.println(Adder.add(11,11));//ambiguity
    }} //compile time error

    Can we overload java main() method?
    ❑ Yes, by method overloading. You can have any number of main methods in a
    class by method overloading. But JVM calls main() method which receives
    string array as arguments only. Let’s see the simple example:
    class Test{
    public static void main(String[] args){System.out.println(“main with String[]”);}
    public static void main(String args){System.out.println(“main with String”);}
    public static void main(){System.out.println(“main without args”);}
    }

    Important Points to remember
    ❑ Two or more methods can have the same name inside the same class if they
    accept different arguments. This feature is known as method overloading.
    ❑ Method overloading is achieved by either:
    ▪ changing the number of arguments.
    ▪ or changing the data type of arguments.
    ❑ It is not method overloading if we only change the return type of methods.
    There must be differences in the number of parameters.

  • Basic Concepts of Graph

    Basic Concepts of Graph

    What is a graph?
    • A data structure that consists of a set of nodes or vertices and a set of edges that relate the nodes to each other
    • The set of edges describes relationships among the vertices

    Undirected graphs
    • When the edges in a graph have no direction, the graph is
    called undirected

    Directed Graph

    When the edges in a graph have a direction, the graph is called directed graph.

    Graph Representation
    Vertices can be represent as one dimensional array.
    Graph edges are commonly represented in two ways:

    1. Adjacency Matrix
    An adjacency matrix is 2D array of V x V vertices. Each row and column represent a vertex.
    If the value of any element a[i][j] is 1, it represents that there is an edge connecting vertex i and vertex j.

    2. Adjacency List
    Adjacency list is a collection of unordered lists used to represent a finite graph.

    Graph terminology
    Complete graph: A graph in which every vertex is directly connected to every other vertex.

  • Introduction to Knapsack Problem

    Introduction to Knapsack Problem

    its Types and How to solve them

    The Knapsack problem is an example of the combinational optimization problem. This problem is also commonly known as the “Rucksack Problem“. The name of the problem is defined from the maximization problem as mentioned below:

    Given a bag with maximum weight capacity of W and a set of items, each having a weight and a value associated with it. Decide the number of each item to take in a collection such that the total weight is less than the capacity and the total value is maximized.

    Types of Knapsack Problem:

    The knapsack problem can be classified into the following types:

    1. Fractional Knapsack Problem
    2. 0/1 Knapsack Problem
    3. Bounded Knapsack Problem
    4. Unbounded Knapsack Problem

    1. Fractional Knapsack Problem

    The Fractional Knapsack problem can be defined as follows:

    Given the weights and values of N items, put these items in a knapsack of capacity W to get the maximum total value in the knapsack. In Fractional Knapsack, we can break items for maximizing the total value of the knapsack.

  • Introduction to Algorithms

    Introduction to Algorithms

    What is an Algorithms?

    An algorithm is a set of step by step or well-defined instructions for solving a specific problem.

    This means that the method you use to arrive at the same solution may differ from mine, but we should both get the same result.

    Because there are various ways to solve a problem, there must be a way to evaluate these solutions or algorithms in terms of performance and efficiency (the time it will take for your algorithm to run/execution and the total amount of memory it will consume).

    What is Big O?

    Big O or Big O notation, represents an algorithm’s worst case complexity.

    It uses algebraic terms to describe the complexity of an algorithm.

    Big O defines the runtime required to execute an algorithm identifying how the performance of your algorithm will change as the input size grows.

    But it does not tell you how fast your algorithm’s runtime is.

    Big O notation measures the efficiency and performance of yo algorithm using time and space complexity.

    What is Time and Space Complexity?

    An algorithm’s time complexity specifies how long it will take execute an algorithm as a function of its input size.

    Similarly, an algorithm’s space complexity specifies the total amount of space memory required to execute an algorithm as a function of the size of the input.

    In Big O, there are six major types of complexities (time and space):
    1. Constant: O(1)
    2. Linear time: O(n)
    3. Logarithmic time: O(n log n)
    4. Quadratic time: O(n^2)
    5. Exponential time: O(2^n)
    6. Factorial time: O(n!)
    • O(1): Constant complexity.
    • O(logn): Logarithmic complexity.
    • O(n): Linear complexity.
    • O(nlogn): Loglinear complexity.
    • O(n^x): Polynomial complexity.
    • O(X^n): Exponential time.
    Amon them

    O(1) – Excellent/Best
    O(log n) – Good
    O(n) – Fair
    O(n log n) – Bad
    O(n^2), O(2^n) and O(n!) – Horrible/Worst

    • When your calculation is not dependent on the input size, it is a constant time complexity (O(1)).
    • When the input size is reduced by half, maybe when iterating, handling recursion, or whatsoever, it is a logarithmic time complexity (O(log n)).
    • When you have a single loop within your algorithm, it is linear time complexity (O(n)).
    • When you have nested loops within your algorithm, meaning a loop in a loop, it is quadratic time complexity (O(n^2)).
    • When the growth rate doubles with each addition to the input, it is exponential time complexity (O2^n).
    https://bigocheatsheet.io

    Thanks for your time!

  • Introduction to SQL Database

    Introduction to SQL Database

    What is a SQL database?

    SQL databases, also known as relational databases, are systems that store collections of tables and organize structured sets of data in a tabular columns-and-rows format, similar to that of a spreadsheet.

    The databases are built using structured query language (SQL), the query language that not only makes up all relational databases and relational database management systems (RDBMS), but also enables them to “talk to each other”.

    Why do SQL Databases exist?

    The history of database technology / relational databases

    SQL was invented as a language in the early 1970s, which means SQL databases have been around for as long as the Internet itself. Dubbed the structured English query language (SEQUEL), SQL was created to streamline access to relational database systems and to assist with the processing of information. Today, SQL remains one of the most popular and widely used query languages in open-source database technology due to its flexibility, ease of use, and seamless integration with a variety of different programming languages. You’ll find SQL being used throughout all types of high-performing, data-centric applications.

    What’s the difference between SQL and NoSQL databases?

    SQL databases organize data in columns and rows. The rows contain data sets that apply to each item, while the columns define the different properties of those items, such as product ID, name, quantity, and unit price. In contrast, NoSQL databases store all incoming data in a single document with no overt structure. This makes SQL databases conducive to storing structured forms of data while NoSQL databases are equipped to handle large volumes of structured, semi-structured, and unstructured data from non-traditional sources.

    What is SQL?

    • SQL stands for Structured Query Language
    • SQL lets you access and manipulate databases
    • SQL became a standard of the American National Standards Institute (ANSI) in 1986 and of the International Organization for Standardization (ISO) in 1987

    What Can SQL do?

    • SQL can execute queries against a database
    • SQL can retrieve data from a database
    • SQL can insert records in a database
    • SQL can update records in a database
    • SQL can delete records from a database
    • SQL can create new databases
    • SQL can create new tables in a database
    • SQL can create stored procedures in a database
    • SQL can create views in a database
    • SQL can set permissions on tables, procedures, and views

    Some of The Most Important SQL Commands

    • SELECT – extracts data from a database
    • UPDATE – updates data in a database
    • DELETE – deletes data from a database
    • INSERT INTO – inserts new data into a database
    • CREATE DATABASE – creates a new database
    • ALTER DATABASE – modifies a database
    • CREATE TABLE – creates a new table
    • ALTER TABLE – modifies a table
    • DROP TABLE – deletes a table
    • CREATE INDEX – creates an index (search key)
    • DROP INDEX – deletes an index

    The SQL CREATE DATABASE Statement

    The CREATE DATABASE statement is used to create a new SQL database.

    Syntax

    CREATE DATABASE databasename;

    The SQL DROP DATABASE Statement

    The DROP DATABASE statement is used to drop an existing SQL database.

    Syntax

    DROP DATABASE databasename;

    SQL PRIMARY KEY on CREATE TABLE

    The following SQL creates a PRIMARY KEY on the “ID” column when the “Persons” table is created:

    Syntax

    CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    PRIMARY KEY (ID)
    );

    SQL FOREIGN KEY Constraint

    A FOREIGN KEY is a key used to link two tables together.

    A FOREIGN KEY is a field (or collection of fields) in one table that refers to the PRIMARY KEY in another table.

    The table containing the foreign key is called the child table, and the table containing the candidate key is called the referenced or parent table.

    Look at the following two tables:

    “Persons” table:

    Syntax

    CREATE TABLE Orders (
    OrderID int NOT NULL,
    OrderNumber int NOT NULL,
    PersonID int,
    PRIMARY KEY (OrderID),
    FOREIGN KEY (PersonID) REFERENCES Persons(PersonID)
    );

    The SQL WHERE Clause

    The WHERE clause is used to filter records. The WHERE clause is used to extract only those records that fulfill a specified condition.
     

    WHERE Syntax

    SELECT column1, column2, … FROM table_name WHERE condition;

    Example

    SELECT * FROM Customers WHERE Country=’Mexico’;

    SELECT * FROM Customers WHERE CustomerID=1;

     

    The SQL AND, OR and NOT Operators

    The WHERE clause can be combined with AND, OR, and NOT operators.

    The AND and OR operators are used to filter records based on more than one condition:

    • The AND operator displays a record if all the conditions separated by AND are TRUE.
    • The OR operator displays a record if any of the conditions separated by OR is TRUE.
    • The NOT operator displays a record if the condition(s) is NOT TRUE.

    AND Syntax

    SELECT column1, column2, … FROM table_name WHERE condition1 AND condition2 AND condition3 …;

    OR Syntax

    SELECT column1, column2, … FROM table_name WHERE condition1 OR condition2 OR condition3 …;

    NOT Syntax

    SELECT column1, column2, … FROM table_name WHERE NOT condition;

    Different Types of SQL JOINs

    Here are the different types of the JOINs in SQL:

    • (INNER) JOIN: Returns records that have matching values in both tables
    • LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
    • RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
    • FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
    SQL INNER JOIN
    SQL LEFT JOIN
    SQL RIGHT JOIN
    SQL FULL OUTER JOIN
  • Introduction to MongoDB Database

    Introduction to MongoDB Database

    MongoDB is an open-source, document-based, and cross-platform NoSQL database that offers high performance, high availability, and easy scalability.

    It differs from traditional relational databases by utilizing a flexible, schema-less data model built on top of BSON (Binary JSON), allowing for non-structured data to be easily stored and queried.

    MongoDB is a powerful and flexible solution for handling modern data needs. As a leading NoSQL database, MongoDB offers a dynamic schema design, enabling developers to store and manage data in a way that aligns seamlessly with contemporary application requirements.

    Unlike traditional relational databases, MongoDB’s document-oriented architecture allows for greater agility and scalability, making it a preferred choice for businesses and developers aiming to handle large volumes of unstructured or semi-structured data.

    What is Mongo-DB?

    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.

    It is categorized under the NoSQL (Not only SQL) database because the storage and retrieval of data in the MongoDB are not in the form of tables.

    The MongoDB database is developed and managed by MongoDB.Inc under SSPL(Server Side Public License) and initially released in February 2009. It also provides official driver support for all the popular languages like C, C++, C#, and .Net, Go, Java, Node.js, Perl, PHP, Python, Motor, Ruby, Scala, Swift, Mongoid. So, that you can create an application using any of these languages. Nowadays there are so many companies that used MongoDB like Facebook, Nokia, eBay, Adobe, Google, etc. to store their large amount of data.

    Key Features of MongoDB

    • Document-oriented: MongoDB stores data in JSON-like documents (BSON format), meaning that the data model is very flexible and can adapt to real-world object representations easily.
    • Scalability: MongoDB offers automatic scaling, as it can be scaled horizontally by sharding (partitioning data across multiple servers) and vertically by adding storage capacity.
    • Indexing: To enhance query performance, MongoDB supports indexing on any attribute within a document.
    • Replication: MongoDB provides high availability through replica sets, which are primary and secondary nodes that maintain copies of the data.
    • Aggregation: MongoDB features a powerful aggregation framework to perform complex data operations, such as transformations, filtering, and sorting.
    • Support for ad hoc queries: MongoDB supports searching by field, range, and regular expression queries.

    When to use MongoDB

    MongoDB is a suitable choice for various applications, including:

    • Big Data: MongoDB’s flexible data model and horizontal scalability make it a great fit for managing large volumes of unstructured or semi-structured data.
    • Real-time analytics: MongoDB’s aggregation framework and indexing capabilities help analyze and process data in real-time.
    • Content management: With its dynamic schema, MongoDB can handle diverse content types, making it a suitable choice for content management systems.
    • Internet of Things (IoT) applications: MongoDB can capture and store data from a large number of devices and sensors, proving beneficial in IoT scenarios.
    • Mobile applications: MongoDB provides a flexible data model, which is an essential requirement for the dynamic nature and varying data types of mobile applications.

    What is MongoDB Atlas?

    MongoDB Atlas is a fully managed cloud-based database service built and maintained by MongoDB. The Atlas platform is available on major cloud providers like AWS, Azure, and Google Cloud Platform, allowing developers to deploy, manage, and scale their MongoDB clusters in a seamless and efficient manner.

    Some of the standout features and benefits of MongoDB Atlas include:

    • Database as a Service (DBaaS): MongoDB Atlas takes care of database-related operations like backups, monitoring, scaling, and security, allowing developers to focus on their application logic.
    • Global Cluster Support: Atlas enables the creation of globally distributed clusters. Data can be stored and replicated across multiple geographies for improved performance, high availability, and reduced latency.
    • Security: Atlas offers built-in security features, such as end-to-end encryption, role-based access control, and IP whitelisting. This ensures your data remains secure and compliant with industry standards.
    • Performance: MongoDB Atlas provides tools for monitoring and optimizing the performance of your database. Advanced features like performance advisor and index suggestions help keep your database running at optimal speed.
    • Easy Scaling: With Atlas, you can easily scale your cluster either vertically or horizontally, depending on your requirements. Atlas supports auto-scaling of both storage and compute resources.
    • Data Automation and Integration: Atlas allows seamless integration with other services, like BI tools and serverless functions. The platform also supports easy data migration from on-premises or cloud-based deployments.
  • Database System

    Database System

    A database system is a collection of interrelated files and a set of programs that allow users to access and modify these files.

    The need for efficiency has led designers to use complex data structures to represent data in the database. The low-level physical view of data is too detailed for most users.

    Database Management System (DBMS) is a software system that is designed to manage and organize data in a structured manner. It allows users to create, modify, and query a database, as well as manage the security and access controls for that database. DBMS provides an environment to store and retrieve data in convenient and efficient manner.

    Types of DBMS

    1. Relational Database Management System (RDBMS): Data is organized into tables (relations) with rows and columns, and the relationships between the data are managed through primary and foreign keys. SQL (Structured Query Language) is used to query and manipulate the data. Examples are MySQL, Oracle, Microsoft SQL Server and Postgre SQL.
    2. NoSQL DBMS: Designed for high-performance scenarios and large-scale data, NoSQL databases store data in various non-relational formats such as key-value pairs, documents, graphs, or columns. Examples are NoSQL DBMS are MongoDB, Cassandra, DynamoDB and Redis.
    3. Object-Oriented DBMS (OODBMS): Stores data as objects, similar to those used in object-oriented programming, allowing for complex data representations and relationships

    Applications of DBMS

    DBMS are used almost in every software that we use. For example, Emails, WhatsApp, Social Media and in-fact this article that you are reading is being stored and accessed using DBMS. Almost all programming languages provide libraries from different popular database management systems like MySQL, Oracle, Microsoft SQL Server, MongoDB, etc.

    • Banking: Manages accounts, transactions, and financial records.
    • Airlines: Handles bookings, schedules, and availability.
    • E-commerce: Supports catalogs, orders, and secure transactions.
    • Healthcare: Stores patient records and billing.
    • Education: Manages student data and course enrollments.
    • Telecom: Tracks call records and billing.
    • Government: Maintains census and taxation data.
    • Social Media: Stores user profiles and posts efficiently.

    Key Features of DBMS

    • Data modeling: A DBMS provides tools for creating and modifying data models, which define the structure and relationships of the data in a database.
    • Data storage and retrieval: A DBMS is responsible for storing and retrieving data from the database, and can provide various methods for searching and querying the data.
    • Concurrency control: A DBMS provides mechanisms for controlling concurrent access to the database, to ensure that multiple users can access the data without conflicting with each other.
    • Data integrity and security: A DBMS provides tools for enforcing data integrity and security constraints, such as constraints on the values of data and access controls that restrict who can access the data.
    • Backup and recovery: A DBMS provides mechanisms for backing up and recovering the data in the event of a system failure.
    • DBMS can be classified into two types: Relational Database Management System (RDBMS) and Non-Relational Database Management System (NoSQL or Non-SQL)
    • RDBMS: Data is organized in the form of tables and each table has a set of rows and columns. The data are related to each other through primary and foreign keys.
    • NoSQL: Data is organized in the form of key-value pairs, documents, graphs, or column-based. These are designed to handle large-scale, high-performance scenarios.

    Database Languages

    • Data Definition Language
    • Data Manipulation Language
    • Data Control Language
    • Transactional Control Language

    Data Definition Language (DDL)

    DDL is the short name for Data Definition Language, which deals with database schemas and descriptions, of how the data should reside in the database.

    • CREATE: to create a database and its objects like (table, index, views, store procedure, function, and triggers)
    • ALTER: alters the structure of the existing database
    • DROP: delete objects from the database
    • TRUNCATE: remove all records from a table, including all spaces allocated for the records are removed
    • COMMENT: add comments to the data dictionary
    • RENAME: rename an object

    Data Manipulation Language (DML)

    DML is the short name for Data Manipulation Language which deals with data manipulation and includes most common SQL statements such SELECT, INSERT, UPDATE, DELETE, etc., and it is used to store, modify, retrieve, delete and update data in a database. Data query language(DQL) is the subset of “Data Manipulation Language”. The most common command of DQL is SELECT statement. SELECT statement help on retrieving the data from the table without changing anything in the table.

    • SELECT: retrieve data from a database
    • INSERT: insert data into a table
    • UPDATE: updates existing data within a table
    • DELETE: Delete all records from a database table
    • MERGE: UPSERT operation (insert or update)
    • CALL: call a PL/SQL or Java subprogram
    • EXPLAIN PLAN: interpretation of the data access path
    • LOCK TABLE: concurrency Control

    Data Control Language (DCL)

    DCL is short for Data Control Language which acts as an access specifier to the database.(basically to grant and revoke permissions to users in the database

    • GRANT: grant permissions to the user for running DML(SELECT, INSERT, DELETE,…) commands on the table
    • REVOKE: revoke permissions to the user for running DML(SELECT, INSERT, DELETE,…) command on the specified table

    Transactional Control Language (TCL)

    TCL is short for Transactional Control Language which acts as an manager for all types of transactional data and all transactions. Some of the command of TCL are

    • Roll Back: Used to cancel  or Undo changes made in the database
    • Commit: It is used to apply or save changes in the database
    • Save Point: It is used to save the data on the temporary basis in the database

    Data Query Language (DQL)

    Data query language(DQL) is the subset of “Data Manipulation Language”. The most common command of DQL is the SELECT statement. SELECT statement helps us in retrieving the data from the table without changing anything or modifying the table. DQL is very important for retrieval of essential data from a database.

    Paradigm Shift from File System to DBMS

    File System manages data using files on a hard disk. Users are allowed to create, delete, and update the files according to their requirements. Let us consider the example of file-based University Management System. Data of students is available to their respective Departments, Academics Section, Result Section, Accounts Section, Hostel Office, etc. Some of the data is common for all sections like Roll No, Name, Father Name, Address, and Phone number of students but some data is available to a particular section only like Hostel allotment number which is a part of the hostel office. Let us discuss the issues with this system:

    • Redundancy of data: Data is said to be redundant if the same data is copied at many places. If a student wants to change their Phone number, he or she has to get it updated in various sections. Similarly, old records must be deleted from all sections representing that student.
    • Inconsistency of Data: Data is said to be inconsistent if multiple copies of the same data do not match each other. If the Phone number is different in Accounts Section and Academics Section, it will be inconsistent. Inconsistency may be because of typing errors or not updating all copies of the same data.
    • Difficult Data Access: A user should know the exact location of the file to access data, so the process is very cumbersome and tedious. If the user wants to search the student hostel allotment number of a student from 10000 unsorted students’ records, how difficult it can be.
    • Unauthorized Access: File Systems may lead to unauthorized access to data. If a student gets access to a file having his marks, he can change it in an unauthorized way.
    • No Concurrent Access: The access of the same data by multiple users at the same time is known as concurrency. The file system does not allow concurrency as data can be accessed by only one user at a time.
    • No Backup and Recovery: The file system does not incorporate any backup and recovery of data if a file is lost or corrupted.

    These are the main reasons which made a shift from file system to DBMS. Also See, Advantages of DBMS over File System

    Advantages of DBMS

    • Data organization: A DBMS allows for the organization and storage of data in a structured manner, making it easy to retrieve and query the data as needed.
    • Data integrity: A DBMS provides mechanisms for enforcing data integrity constraints, such as constraints on the values of data and access controls that restrict who can access the data.
    • Concurrent access: A DBMS provides mechanisms for controlling concurrent access to the database, to ensure that multiple users can access the data without conflicting with each other.
    • Data security: A DBMS provides tools for managing the security of the data, such as controlling access to the data and encrypting sensitive data.
    • Backup and recovery: A DBMS provides mechanisms for backing up and recovering the data in the event of a system failure.
    • Data sharing: A DBMS allows multiple users to access and share the same data, which can be useful in a collaborative work environment.

    Disadvantages of DBMS

    • Complexity: DBMS can be complex to set up and maintain, requiring specialized knowledge and skills.
    • Performance overhead: The use of a DBMS can add overhead to the performance of an application, especially in cases where high levels of concurrency are required.
    • Scalability: The use of a DBMS can limit the scalability of an application, since it requires the use of locking and other synchronization mechanisms to ensure data consistency.
    • Cost: The cost of purchasing, maintaining and upgrading a DBMS can be high, especially for large or complex systems.
    • Limited Use Cases: Not all use cases are suitable for a DBMS, some solutions don’t need high reliability, consistency or security and may be better served by other types of data storage.

    Applications of DBMS

    • Enterprise Information: Sales, accounting, human resources, Manufacturing, online retailers.
    • Banking and Finance Sector: Banks maintaining the customer details, accounts, loans, banking transactions, credit card transactions. Finance: Storing the information about sales and holdings, purchasing of financial stocks and bonds.
    • University: Maintaining the information about student course enrolled information, student grades, staff roles.
    • Airlines: Reservations and schedules.
    • Telecommunications: Prepaid, postpaid bills maintance.