Saturday, February 23, 2013

Normalization of Database.


Description of Normalization

Normalization is the process of organizing data in a database. This includes creating tables and establishing relationships between those tables according to rules designed both to protect the data and to make the database more flexible by eliminating redundancy and inconsistent dependency. 

Redundant data wastes disk space and creates maintenance problems. If data that exists in more than one place must be changed, the data must be changed in exactly the same way in all locations. A customer address change is much easier to implement if that data is stored only in the Customers table and nowhere else in the database. 

What is an "inconsistent dependency"? While it is intuitive for a user to look in the Customers table for the address of a particular customer, it may not make sense to look there for the salary of the employee who calls on that customer. The employee's salary is related to, or dependent on, the employee and thus should be moved to the Employees table. Inconsistent dependencies can make data difficult to access because the path to find the data may be missing or broken. 

There are a few rules for database normalization. Each rule is called a "normal form." If the first rule is observed, the database is said to be in "first normal form." If the first three rules are observed, the database is considered to be in "third normal form." Although other levels of normalization are possible, third normal form is considered the highest level necessary for most applications. 

As with many formal rules and specifications, real world scenarios do not always allow for perfect compliance. In general, normalization requires additional tables and some customers find this cumbersome. If you decide to violate one of the first three rules of normalization, make sure that your application anticipates any problems that could occur, such as redundant data and inconsistent dependencies. 

Thursday, February 21, 2013

Program to Convert timing from 12 - 24 hours and vice versa in CPP


#include<iostream.h>
#include<conio.h>
int flag=0;

class tw4;
class tw2
{
private:
int hrs,secs,mins;
public:
tw2(int hr,int min,int sec)
{
hrs=hr;
mins=min;
secs=sec;
}
friend void conv(tw2 t1,tw4 t2);

};
class tw4
{
private:
int hrs,secs,mins;
public:
tw4(int hr,int min,int sec)
{
hrs=hr;
mins=min;
secs=sec;
}
friend void conv(tw2 t1,tw4 t2);

};
void conv(tw2 t1,tw4 t2)
{
if(t1.hrs<12)
{
if(flag==1)
{
goto print;
}
t1.hrs=t1.hrs+12;

print:
cout<<"Convertes time is > "<<t1.hrs<<":"<<t1.mins<<":"<<t1.secs;
}
else
{
t2.hrs=t2.hrs-12;
cout<<"Convertes time is > "<<t2.hrs<<":"<<t2.mins<<":"<<t2.secs;
}
}

void main()
{

int sec=0,min=0,hr=0;
clrscr();
cout<<"Enter the Time in format (hrs:mins:sec)";
cin>>hr>>min>>sec;
cout<<"1.am\n2.pm";
cin>>flag;

tw2 t1(hr,min,sec);
tw4 t2(hr,min,sec);
conv(t1,t2);
getch();

}

//OUTPUT



Wednesday, February 13, 2013

Project on ATM machine working in CPP

/*program of ATM machine working....*/

#include<string.h>
#include<iostream.h>
#include<conio.h>
class Atm               //classname......//
{
int choice,i;
float b,c;
char str[7];
public:
void get();              //function declaration.....//
};
void Atm::get()
{
cout<<"\tEnter Your Password: ";         //ATM  password(ABCDE)...//
for(i=0;i<=4;i++)
{
str[i]=getch();
cout<<"*";
}
str[i]='\0';
if(strcmp(str,"ABCDE")==0)
{
float a=30000;                         //ATM's front page....//
cout<<endl<<endl<<"\t** WELCOME TO SBI **"<<endl<<endl;
cout<<" \tHello Mr.Chinmay Mahajan\t"<<endl<<endl<<endl;
cout<<"\t1.Information.\t2.Balance enquiry.";
cout<<endl<<endl<<"\t3.Withdrawal\t4.Quit";
cout<<endl<<endl<<endl<<"\t-->please select your choice:";
cin>>choice;
switch(choice)
{
case 1:
cout<<endl<<endl<<"\tName-Chinmay Mahajan"<<endl<<endl;
cout<<"\t Account no.-0181cs081059"<<endl<<endl<<"\tBranch name-Bhopal";
cout<<endl<<endl<<"\tYour main balance is:"<<a<<endl<<endl<<endl<<"\t\tThank U";
break;
case 2:
cout<<endl<<"\tYour balance is: "<<a<<endl<<endl<<endl<<"\t  Thank U  ";
break;
case 3:
cout<<endl<<"\t your balance is: "<<a<<endl;
cout<<endl<<"\t Please enter your amount:";
cin>>b;
if(b>a)
{
cout<<endl<<endl<<"\tyou have not sufficient balance";
goto out;
}
else
{
c=a-b;
cout<<endl<<endl<<"\tyou have withdrawn Rs. "<<b;
cout<<endl<<endl<<"\tYour balance now:"<<c<<endl<<endl<<"\tThank U";
break;
}
out:
default:
cout<<endl<<endl<<"\tThank U";
}
}
else
{
cout<<endl<<endl<<"\tPassword incorrect";
cout<<endl<<endl<<"\tThank U";
 }
}
void main()
{
clrscr();
Atm A;
A.get();
getch();
}

Thursday, January 31, 2013

ADDITION OF TWO NUMBERS IN C++ USING FRIEND FUNCTION

/* FRIEND FUNCTION DEMO */


#include<iostream.h>
#include<conio.h>

class two;
class one
{
private:int data1;
public: void setdata(int init)
{
data1=init;
}
friend int add_both(one a,two b);

};//class

class two
{
private: int data2;
public:
void setdata(int init)
{
data2=init;
}
friend int add_both(one a,two b);
};
int add_both(one a,two b)
{
return a.data1+b.data2;
}
void main()
{
one a;
two b;

int i,j;
clrscr();
cout<<"Enter the value of a & b";
cin>>i>>j;

a.setdata(i);
b.setdata(j);
cout<<"sum of one & two :"<<add_both(a,b);
getch();
}

Monday, October 1, 2012

Star Pattern in C language


#include<stdio.h>
#include<conio.h>
void main()
{
int b=2,c=1,i,p,a;
clrscr();
for(i=0;i<3;i++)
{
for(a=0;a<b;a++)
{
printf(" ");
}//for spacing
for(p=0;p<c;p++)
{
printf(" *");
}//for printing
for(a=0;a<b;a++)
{
printf(" ");
}//for spacing
for(p=0;p<c;p++)
{
printf(" *");
}//for printing
for(a=0;a<b;a++)
{
printf(" ");
}//for spacing
printf("\n");
b--;
c++;

}//outer for loop
getch();
}//eofm

Wednesday, August 29, 2012

c program to reverse a number

#include <stdio.h>
 
main()
{
   int n, reverse = 0;
 
   printf("Enter a number to reverse\n");
   scanf("%d",&n);
 
   while (n != 0)
   {
      reverse = reverse * 10;
      reverse = reverse + n%10;
      n = n/10;
   }
 
   printf("Reverse of entered number is = %d\n", reverse);
 
   return 0;
}