Database Management System – Introduction

Database Management System – Introduction


Database: Database is a collection of inter-related data which helps in efficient retrieval, insertion and deletion of data from database and organizes the data in the form of tables, views, schemas, reports etc. For Example, university database organizes the data about students, faculty, and admin staff etc. which helps in efficient retrieval, insertion and deletion of data from it.

what is data?
In a database, even a smallest piece of information becomes data. For example, Student is a data, course is a data, and Color is a data, height, weight, food everything is data. In short, all the living and non-living objects in this world is a data.

Database Management System: The software which is used to manage database is called Database Management System (DBMS). For Example, MySQL, Oracle etc. are popular commercial DBMS used in different applications.

DBMS allows users the following tasks:
Data Definition: It helps in creation, modification and removal of definitions that define the organization of data in database.
Data Updation: It helps in insertion, modification and deletion of the actual data in the database.
Data Retrieval: It helps in retrieval of data from the database which can be used by applications for various purposes.

User Administration: It helps in registering and monitoring users, enforcing data security, monitoring performance, maintaining data integrity, dealing with concurrency control and recovering information corrupted by unexpected failure.


linked list program

linked list is a way to store a collection of elements. Like an array these can be character or integers. Each element in a linked list is stored in the form of a node.
Node:
enter image description here
A node is a collection of two sub-elements or parts. A data part that stores the element and a next part that stores the link to the next node.
Linked List:
enter image description here
A linked list is formed when many such nodes are linked together to form a chain. Each node points to the next node present in the order. The first node is always used as a reference to traverse the list and is called HEAD. The last node points to NULL.
Declaring a Linked list :
In C language, a linked list can be implemented using structure and pointers .
struct LinkedList{
    int data;
    struct LinkedList *next;
 };

The above definition is used to create every node in the list. The data field stores the element and the next is a pointer to store the address of the next node.
Noticed something unusual with next?
In place of a data type, struct LinkedList is written before next. That's because its a self-referencing pointer. It means a pointer that points to whatever it is a part of. Here next is a part of a node and it will point to the next node.
Creating a Node:
Let's define a data type of struct LinkedListto make code cleaner.
typedef struct LinkedList *node; //Define node as pointer of data type struct LinkedList

node createNode(){
    node temp; // declare a node
    temp = (node)malloc(sizeof(struct LinkedList)); // allocate memory using malloc()
    temp->next = NULL;// make next point to NULL
    return temp;//return the new node
}
typedef is used to define a data type in C.
malloc() is used to dynamically allocate a single block of memory in C, it is available in the header file stdlib.h.
sizeof() is used to determine size in bytes of an element in C. Here it is used to determine size of each node and sent as a parameter to malloc.
The above code will create a node with data as value and next pointing to NULL.
Let's see how to add a node to the linked list:
node addNode(node head, int value){
    node temp,p;// declare two nodes temp and p
    temp = createNode();//createNode will return a new node with data = value and next pointing to NULL.
    temp->data = value; // add element's value to data part of node
    if(head == NULL){
        head = temp;     //when linked list is empty
    }
    else{
        p  = head;//assign head to p 
        while(p->next != NULL){
            p = p->next;//traverse the list until p is the last node.The last node always points to NULL.
        }
        p->next = temp;//Point the previous last node to the new node created.
    }
    return head;
}

Here the new node will always be added after the last node. This is known as inserting a node at the rear end.
Food for thought
This type of linked list is known as simple or singly linked list. A simple linked list can be traversed in only one direction from head to the last node.
The last node is checked by the condition :

p->next = NULL;

Here -> is used to access next sub element of node p. NULL denotes no node exists after the current node , i.e. its the end of the list.
Traversing the list:
The linked list can be traversed in a while loop by using the head node as a starting reference:
node p;
p = head;
while(p != NULL){
    p = p->next;
}

Why Linked List?
Arrays can be used to store linear data of similar types, but arrays have following limitations.
1) The size of the arrays is fixed: So we must know the upper limit on the number of elements in advance. Also, generally, the allocated memory is equal to the upper limit irrespective of the usage.
2) Inserting a new element in an array of elements is expensive, because room has to be created for the new elements and to create room existing elements have to shifted.
For example, in a system if we maintain a sorted list of IDs in an array id[].
id[] = [1000, 1010, 1050, 2000, 2040].
And if we want to insert a new ID 1005, then to maintain the sorted order, we have to move all the elements after 1000 (excluding 1000).
Deletion is also expensive with arrays until unless some special techniques are used. For example, to delete 1010 in id[], everything after 1010 has to be moved.
Advantages over arrays
1) Dynamic size
2) Ease of insertion/deletion
Drawbacks:
1) Random access is not allowed. We have to access elements sequentially starting from the first node. So we cannot do binary search with linked lists.
2) Extra memory space for a pointer is required with each element of the list.

types of linked list

  • Singly Linked List : Singly linked lists contain nodes which have a data part as well as an address part i.e. next, which points to the next node in sequence of nodes. The operations we can perform on singly linked lists are insertion, deletion and traversal.
    Linear Linked List
  • Doubly Linked List : In a doubly linked list, each node contains two links the first link points to the previous node and the next link points to the next node in the sequence.
    Double Linked List
  • Circular Linked List : In the circular linked list the last node of the list contains the address of the first node and forms a circular chain.
    Circular Linked List

linked list

Linked List is a linear data structure and it is very common data structure which consists of group of nodes in a sequence which is divided in two parts. Each node consists of its own data and the address of the next node and forms a chain. Linked Lists are used to create trees and graphs.

Linear Linked List

Advantages of Linked Lists

  • They are a dynamic in nature which allocates the memory when required.
  • Insertion and deletion operations can be easily implemented.
  • Stacks and queues can be easily executed.
  • Linked List reduces the access time.

Disadvantages of Linked Lists

  • The memory is wasted as pointers require extra memory for storage.
  • No element can be accessed randomly; it has to access each node sequentially.
  • Reverse Traversing is difficult in linked list.

Applications of Linked Lists

  • Linked lists are used to implement stacks, queues, graphs, etc.
  • Linked lists let you insert elements at the beginning and end of the list.
  • In Linked Lists we don't need to know the size in advance.

python vs java



python


python vs java


A KEY DIFFERENCE: DUCK TYPING

The biggest difference between the two languages is that Java is a statically typed and Python is a dynamically typed.
Python is strongly but dynamically typed. This means names in code are bound to strongly typed objects at runtime. The only condition on the type of object a name refers to is that it supports the operations required for the particular object instances in the program. For example, I might have two types Person and Car that both support operation "run", but Car also supports "refuel". So long as my program only calls "run" on objects, it doesn't matter if they are Person or Car. This is called "duck typing" after the expression "if it walks like a duck and talks like a duck, it's a duck".
This makes Python very easy to write and not too bad to read, but difficult to analyze. Static type inference in Python is a known hard problem. The lack of type information in function signatures combined with support for operator overloading and just-in-time loading of modules at runtime means that the most common type inference algorithms have nothing to work with until the point in the program's execution when the types are known anyway. The Hindley-Milner algorithm that is commonly used in functional languages like Haskell and ML depends on being able to know, for example, that certain operations are restricted to particular types. These languages also typically have function signatures that "seed" the algorithm with the type information for their arguments.
In Python, names have no strong binding to their type, and thanks to duck typing, function arguments can be used to pass in any object whose interface supports the operations required by the function. There is no reasonable way to determine the type of an argument in this case, which can be very powerful and convenient, and is a lot like how we use objects in the real world. In the real world I don't generally care if I have a rock or a hammer: both have "hit()" interfaces that result in similar consequences when called.
Classes in object-oriented languages are meant to model concepts, but concepts are purely mental constructs that are essentially attitudes toward the concrete stuff of reality. Duck typing reflects this fact nicely. An object doesn't have to "be" a particular type, it just has to be useable where a thing of that type might be useable. This can lead to surprises, but it's a more accurate reflection of the categorical fluidity of human thought than is the rigid hierarchy imposed by more restrictive type systems.
1. Python requires no "set up." A full python environment is already on every Linux machine, and on Macs. On Linux, the program yum, or the  yelow dog updater modified is written in python, so python is here to stay. Java requires a substantial amount of setup. So if you want to get started with python programming, just type python at the prompt. Now. That's it. To start with Java, call someone who knows it.
2. The systems written in Java that we have purchased all suffer from the need to have particular versions of Java installed, and thick clients of these systems also have that requirement. Support of Java appears to be expensive. We do not yet have a similar number of python systems, but no one is expecting configuration management to be an issue with them. From an educational standpoint, this sounds like a good way to become frustrated.
3. Python has its own idiosyncrasies. In Java, every object must be a representation of some class, but in python the "variables" are of a unique flavor. Variables do not represent objects [cf. object: something in memory that has an address] nor are they pointers, nor are they references. It is best to think of them as temporary "names" for an underlying reality, much like the allergy From a learning standpoint, this may be more difficult for those of us with 35 years of experience than it is for those first taking up programming.
4. A number of companies are stuck with a great deal of legacy code written in Python 2. Consequently, Python suffers from a misconception about how strict or loose the typing system may be, and how strictly it may be enforced. Keep in mind that because Python mainly works with "names" of objects, we are really not discussing the same thing when we discuss types of Python's objects that we are discussing in other languages. Python does offer some rather seamless type conversions that can make it seem that the concept of types is less strict than it is in fact. Learning Python 3 first makes sense, but most of the employment is still in Python 2.

c vs c++

C vs C++

c vs c++

There are actually quite a few areas where c and c++ different (in addition to the classes, template, exceptions, etc).

As far as major differences, here's a list which covers it well:

  • anonymous unions
  • classes
  • constructors and destructors
  • exceptions and try/catch blocks
  • external function linkages 
  • function overloading
  • member functions
  • namespaces
  • new and delete operators and functions
  • operator overloading
  • reference types
  • template classes
  • template functions
  • powerfull stl  library
                                                   C and C++ difference video:-




linear search

C/C++

int search(int arrayforsearch[], int n, int x)
{
    int i;
    for (i=0; i<n; i++)
        if (arrayforsearch[i] == x)
         return i;
    return -1;
}

python:-


def search(arrayforsearch, x):

    for i in range(len(arrayforsearch)):

        if arrayforsearch[i] == x:
            return i

    return -1
   
    
    JAVA:-
    
    class LinearSearch
   {
    
    static int search(int arrayforsearch[], int n, int x)
    {
        for (int i = 0; i < n; i++)
        {
            
            if (arrayforsearch[i] == x)
                return i;
        }
  
        
        return -1;
    }