Saturday 21 July 2012

Structured Query Language : Database Language

SQL - 

             SQL is known as Structured Query Language (pronounced as S-Q-L) was developed by IBM in mid-1970's. It’s a non-procedural language (i.e. one does not have to specify all the steps required to perform a action).
It’s an international language used for querying and creating relational databases (database that stores data in the form of tables i.e. rows and columns) and the most common SQL standard is SQL-92 (standard is known as SQL-92 because the standard was approved in 1992).However the standards SQL-99 extensions are used by most vendors.

SQL CLASSIFICATION - 

              SQL command can be divided into 3 categories - 

  1. DDL 
  2. DML
  3. DCL
DDL is referred as Data Definition Language. It generally includes commands that are used for defining  a database i.e. creating, altering, dropping database, tables and establishing constraints such as primary-foreign key constraints. For Example - 
  • CREATE command is used to create a database or table. CREATE DATABASE db_admin.
  • DROP command can be used for various purposes such as deleting a database,  table or an index. DROP DATABASE db_admin.


DML is referred as Data Manipulation Language. It generally includes commands that are used for maintaining and querying a database i.e. inserting, deleting, searching or updating a record in a table. For Example - 


  • INSERT command is used to insert a new record in the table in database. INSERT INTO tbl_admin VALUES ('a','b').
  • SELECT command is used to select and view a record depending in the way query is used. SELECT * FROM tbl_admin.
DCL  is referred as Data Control Language. It generally includes commands that are used to control a database i.e. administering, privileges and committing data. For Example -
  • GRANT is used to allow specified users to perform specified tasks. GRANT SELECT ON TABLE tbl_admin TO PUBLIC.
  • REVOKE to cancel previously granted or denied permissions. REVOKE CREATE TABLE FROM testing. (testing is a role)

Thursday 19 July 2012

Decimal Number to hexadecimal number in C


Steps to convert Decimal number into Hexadecimal number - 


  1. Divide the decimal number by 16. Treat the division as an integer division.
  2. Write down the remainder (in hexadecimal, ie. if the remainder is 12, write down "C").
  3. Divide the result again by 16. Treat the division as an integer division.
  4. Repeat step 2 and 3 until result is less than 1.
  5. The hexadecimal value is the digit sequence of the remainders from the last to first. (So if you had 001, it's 100.)

Sample Output - 



Code - 


/* Program to convert Decimal number into Hexadecimal number */

#include<stdio.h>

#include<conio.h>

int main()
{
int decimal_number = 0, temp_number = 0, remainder = 0, counter = 0, i  = 0, value = 0;

char hexadecimal_number[10];

printf("\n\t __ Program to convert Decimal number into Hexadecimal number __");

printf("\n\n\n  Enter the Decimal Number - ");

scanf("%d",&decimal_number);

temp_number = decimal_number;

while(temp_number > 1)
{
remainder = temp_number % 16;

temp_number = temp_number / 16;

value = 0;

if (remainder >= 0 && remainder <= 9)
{
value = 48;

for ( i = 1; i <= remainder; i ++)
{
value = value + 1;
}
}
else if (remainder >= 10 && remainder <= 15)
{
value = 65;

for ( i = 11; i <= remainder; i ++)
{
value = value + 1;
}
}

hexadecimal_number[counter] = (char)value;

counter++;
}

printf("\n\n  Hexadecimal Conversion of %d (base 10) is ", decimal_number);

for( i =  counter - 1 ; i >= 0; i -- )
{
printf("%c", hexadecimal_number[i]);
}

printf(" (base 16)");

getch();

return 0;
}

Tuesday 17 July 2012

Deadlock


In a multiprogramming environment, several processes may compete for a finite number of resources. Generally a process may utilize the resource in the following fashion –

ð  Request for a resource
ð  Use the resource
ð  Release the resource

But in an Operating System sometimes a situation might occur when a process enters a waiting state because a resource requested by it is being held by another process, which in turn is waiting for another resource. The above situation is known as Deadlock.

Note - If a process is unable to change its state indefinitely because the resources requested by it are being used by other waiting process, then the system is said to be in a deadlock.

Question – What can be a resource?
Answer – A resource can be anything that can only be used by a process at any instant of time.

Deadlock is a common problem in –  Multiprocessing systems,  Parallel computing,  Distributed systems

Necessary conditions for Deadlock – A deadlock situation might arise if the following conditions are held simultaneously in the system –
  1. Mutual Exclusion
  2. Hold and Wait
  3. No - Preemption
  4. Circular Wait

Sunday 15 July 2012

Java Programming language



What is Java?
JAVA is an object oriented programming language (OOPS) which simulates the real world object in the Programming world. It is a computing platform first released by sun Microsystems in 1995. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices. 

Why should we study JAVA?
Java is a platform independent language. It is free to use. Millions of developers are there to help us when we need any help on this platform. It is safe and secure to use. We can develop our own application and sell it in the market that too without any licensing charges for the language. It has been developed very much since 1995 and many other frameworks have been added to Java ex. Spring, Hibernate etc. Today mobile based applications are being developed on Android whose base is Java. There are many reasons to choose Java apart from these.





Simple Hello World Program in Java

public class HelloWorld{
            public static void main(String args[]){
                        System.out.println("Hello World!!");
                        }
}
Instructions –
  1. Save the file with name HelloWorld.java
  2. Compile it with javac HelloWorld.java 
  3. And run it using java HelloWorld.