Selasa, 03 Desember 2013

Database Architectures used by Database Developer: Introduction to SQL

According to earlier discussion about employee’s details storage in database, any business application can have some major elements as Single-tier Architecture, Two-tier architecture, Three-tier Architecture and at the last N-tier Architecture in context of SQL server. A database developer can easily use this concepts in sql by following below description.

Single-Tier Architecture

In single-tier architecture, all elements of a business application are combined as a single executable unit. This unit is installed on all the computers that the users need to work on. It is required to recompile and redistribute the entire application to all the computers, after any modification. That’s why it becomes complicated to modify the application or to fix any bugs.

Two-Tier Architecture

This architecture makes entry to address the problems in modifying an application faced in a first scenario. In two-tier architecture, the application is divided into two manageable parts; one part handles the data, while the other provides the user interface. The two parts can be located on a single computer or on separate computers over a network.

The part that handles the user interface (UI) is called the client tier. The part that Implements the application logic and manages the input data based on the business rules is called the server tier, as shown in the following connection.

Client Computers<---------------------------------->Database Server

Two-tier architecture is also called client-server architecture. Most RDBMSs, such as Microsoft Access, SQL Server, and Oracle adhere to the client-server architecture. RDBMS provides centralized functionality required while supporting many users.

Three-Tier Architecture

When implementing complex business solutions in case of a two-tier architecture, the tier on which the business logic is implemented becomes over loaded. As a result, it takes more time to execute. Therefore, to provide further flexibility, the two-tier architecture can be split into three tiers. In three-tier architecture, the first tier is the client tier, the second or middle tier is called the business tier and the third tier is called the server tier. The server tier contains a database server that manages the data.

Client Computers<-------->Business Tier <-------->Database Server

The business tier consists of all the business rules. It consists of the application logic that Implements rules and checks the data. The advantage of a three-tier application is that it allows you to change the business rules without affecting the other two tiers.

For instance in a banking application for loans, the user tier is the front-end, used by the customer to specify the loan details. The server tier can consist of an RDBMS in which the data is stored. The business tier lies between the other two tiers and consists of business rules, such as the loan limit and the interest rate charged to a customer. If there is a change in the rate of interest, only the middle tier component needs to be modified.

N-Tier Architecture

Webpage design using master page and css in asp.net

Webpage design is term to represent proper arrangement of the objects. If you want to design webpages in asp.net using master page, you should use visual studio IDE (Integrated Development Environment).
Lets take a simple steps for webpage design using master page and CSS.
Step-1 : Open visual studio , i have visual studio 2010 IDE
Step-2 :  Select new website under file menu.
Step-3 :  In the left pane select visual c# also select ASP.NET Empty website in the middle pane in New website window.
Step-4 : Open Add new item window using Ctrl+Shift+A and select master page. Also select "place code in separate file" check box
Step-5 : Here, simple demonstration of master page.

webpage design : master page source code

Step-6: Before further designing take a rough diagram of your webpage, suppose your page look like.
Rough diagram of webpage design


Step-7 : Now, we will start designing in master page. First we take HTML table just after <form> tag, Bydefault table contains three rows and three columns.
Step-8 : Select all cell of the first row for designing Header part, merge all of them by selecting "MergeCells" in modify menu.
modify cell of the html table in webpage design


Step-9 : Similarly again Merge cell for designing sidebar,content, and footer part.
Step-10 : Place ContentPlaceHolder in content part. Now your master page look like.

webpage design of master page in asp.net


Step-11 : Add new Item using Ctrl+Shift+A , select webform which extension as .aspx. Also this page inherits from master page so select master page check Box and press add button.
Step-12 : Now you can see your default.aspx page inherits layout of the master page.

Senin, 02 Desember 2013

Data Engine for Database Developer: Introduction to SQL

SQL Server, a data engine introduced by Microsoft, lies at the core of data Management solution of an organization. It allows secure, efficient storage and Management of data. SQL database Server also provides other components and Services that support the business intelligence platform to generate reports and facilitate Data analysis used by database developer.

Every organization needs to maintain information related to employees, Customers or Business partners. Organizations build business applications either to store and manipulate the information or to generate reports. In addition, they need a platform that can be used to store and maintain these information in an efficient way. Various database management systems (DBMS) and relational database Management system (RDBMS) such as SQL Server 2005, Oracle and Sybase can be used to maintain this information.

It is important for a database developer to identify the role of a database server in an organization, to effectively design and implement database solutions by using SQL Server, to identify its components and services. In Addition, you need to understand the basics of SQL, a language that is used to query and manage data.

Role of a Database Server

Earlier, organizations used to store the data on paper. With an increase in the usage of computers, they began building and using business applications to support the business operations.

The business applications accept data/information as input, process the data based on business requirements and provide data/information as output. For example, an application that maintains the sales details for an organization, accepts the details of the sales transaction from the users. The data is saved and an output message will display confirming that the data has been saved.

For example, the Human Resource department of an organization uses an application to manage employee’s data. The users need to add the details of new employees. The application provides an interface to enter the employee details. These details are validated for accuracy based on business rules. A business rule is defined to check that the date of joining of the new employee is less than or equal to the current date. If the data meets the requirements, it is saved in the data store.

Architectures used in Business application

Looping Statements in Computer Programming, C Language

Introduction

We have learnt about branching statements that transfer the control from one point to another point in the computer programming. In this article, we concentrate on another important constructs like loop statements, which executes a set of statements repeatedly. Sometimes, it is required to execute a set of statements repeatedly in c programming. In such cases, the looping statements are used.

The statements that enables the programmer to execute a set of statements repeatedly till the required activity is completed, called looping statements or simply loop statements. These statements are also called repetitive or iterative statements. The statements within a loop may be executed for a fixed number of times or until a certain condition is reached. The various types of loop statements that are supported by the C language are as follows:

For Loop

A set of statements may have to be repeatedly executed for a specified number of times. In such situations, we use for loop statement. This type of loop is defined as an iterative statement that causes a set of statements to be executed repeatedly for a fixed number of times. If we know well in advance as how many times a set of statements have to be executed repeatedly, then for loop is the best choice.

The syntax of for loop as follows:
for (initialization; condition; increment/decrement)
{
    statement1;
    statement2;
    statement3;
}

Where

  • for: is the reserve word or keyword
  • Initialization: used to provide starting value to the variable. It should end with semicolon (;).
  • Condition: used to determine whether value of variable has reached the number of repetitions desired. It should end with semicolon (;).
  • Increment/Decrements: It is used to update the variable value by increment or decrements.

Note: Initialization, condition and updating statement can be multiple statements separated by comma (,).

In for loop some points have to keep in mind by c programmer, which are:

  • The initialization statement executes first and only once when the execution begins.
  • After this, condition is executed. If the condition is evaluated as the True then the body of for loop is executed. After executing the body of the loop the increment/decrements statement is executed. It is normally update the variable value by the specified step size. Then termination condition statement is executed and the process is repeated.
  • If the condition is evaluated to False, then the control comes out of the loop without executing the body of the loop. Later, the rest of the code is executed.

As long as condition is evaluated to True, the body of for loop and the updating statement are executed.
For example

for(i=1; i<=5;i++)
{
  printf(“%d”,i);
}
printf(“\nOut of the loop”);

In the above example,

  • For loop is executed for the first time and initialize the value of i =1.
  • Then, condition is checked and it is true since i = 1.
  • So, control enters into body of the loop and displays 1 on the screen using printf statement.
  • Then i is incremented by 1 and condition is checked again. The loop is repeatedly executed for i=1, 2, 3, 4 and 5, all these values are displayed one after other.
  • Finally, when i will be 6, the condition fails and control comes out of the loop and the message "Out of the loop" is displayed on the screen.

Here's an example to find sum of N natural numbers using For loop.

Algorithm:
Step1:    [Read the number of terms]
Read: N
Step2:    [Initialization]
    Sum = 0
Step3:    for i = 1 to N in steps of 1 do
    Sum = Sum + i
    [End of for]
Step4:    Write: Sum
Step5:    Exit

Looping Statements in Computer Programming, C Language


C program to find sum of natural number

main()
{
  int i,n,sum=0;
  printf("Enter the number of terms here:\n");
  scanf("%d",&n);
  for(i=1; i<=n; i++)
   {
     sum=sum+i;
   }
printf("The sun of n %d term = %d",n,sum);
getch();
}

Looping Statements in Computer Programming, C Language

Branching Statements in C

Switch Statement in Computer Programming, C Language

There is another important branching statement known as the switch statement in computer programming. We know that (discussed earlier), in situations involving series of decisions one after the other, the if-else-if ladder can be used. Each and every condition may involve expressions which results in various data types such as float, double, char, integer etc.

Here, if-else-if ladder or nested if can be used. But, in situations involving series of decisions one after the other, each decision condition may involve expressions which result in integer value. This integer value may be used for comparison using equality operator "==". In these situations, where the result is of integer data type and series of integer values are used in equality decisions, the usage of switch statement is recommended, because it improves readability of the program.

The switch statement provides a way to select a choice out of several choices based on the selection of choice. The choice can either be an integer value or a character value. The choice can also be an expression which results in an integer value. Based on this integer value, the control is transferred to a particular case value.

The syntax of the switch statement is as follows:
switch (expression/choice)
{
  case value1:
      statement(s);
    break;
case value2:
    statement(s);
    break;
case value3:
    statement(s);
    break;
    .
    .
    .
default:
    statement(s);
}
The expression or choice in switch statement is evaluated to an integer value. The integer value thus obtained if matches with any of the values value1, value2, value3……, value n, then the control is transferred to the appropriate case statement(s). During execution of a particular case, if break is not encountered, then control goes to the subsequent case and the statement(s) under that case will be executed till the break statement is encountered.
If the value of the expression does not match with any of the cases values value1, value2,… value n then, control comes out of the switch statement in the absence of default. If default case is part of the switch then the statement(s) in default block will be executed.

Here, we are writing a program to simulate the calculator using switch statement. The input is an expression of the form P op Q Where P and Q are the operands and the op is an operator. For example, a + b, 10 * 20 etc. Based on the operator, the operations is performed and the result is displayed.

Algorithm:
Step1:    Read p, op, q;
Step2:    switch(op)
    case ‘+’:    result = p + q;
    case ‘-’:    result = p - q;
    case ‘*’:    result = p * q;
    case ‘/’:    result = p / q;
    default:    Write: ‘Invalid operator’
    [End of switch]
Step3:    Write: result
Step4:    Exit
   
C program of the above problem in C language:
main()
{
int p,q,result;
char op;
clrscr();
printf(“Enter an expression here:\n”);
scanf(“%d %c %d”,&p,&op,&q);
switch(op)
{
 case ‘+’:
 result = p + q;
break;
case ‘-’:
 result = p - q;
break;
case ‘*’:
 result = p * q;
break;
case ‘/’:
 result = p / q;
break;
default:
printf(“Invalid expression.\n”);
}
printf(“The result of the expression %d %c %d = %d”,p,op,q,result);
getch();
}
Switch Statement in Computer Programming, C Language

Advantages:

  • Improves readability of the program
  • More structure way of writing  the program

Disadvantage:

It can be used only if the expression used for checking the conditions result in integer value or character value. If the result of expression is not integer value, switch statement cannot be used.


If-Else-If Ladder
For loop in C

Minggu, 01 Desember 2013

If-Else-If Ladder Statement in Computer Programming: C Language

When series of actions have to be performed based on decisions one–by-one, then the statement used is called if-else-if ladder. In computer programming it is called multi-way decision statement. The if-else-if ladder is a form of nested if-statement. Here, nesting is allowed only in the else part. The orderly nesting of if statement only in the else part is called if-else-if ladder. The syntax of if-else-if ladder is shown below:
Syntax:

if(condition1)
    statement(s);
      else if(condition2)
    statement(s);
else if(condition3)
    statement(s);
-
-
-
    else if(conditionn)
    statement(s);
                               else
                                  statement(S);

In this statement the conditions condition1, condition2 etc. of if-else-if ladder are evaluated to true, the corresponding statement is executed and control comes out of the entire if-else-if ladder executing the rest statements that come after the if-else-if ladder.

If all the conditions are evaluated to false, then the last statement is executed, and the control comes out of if-else-if ladder and the rest statements that come after the if-else-if ladder are executed.

Problem:

Let consider a problem to display the grade obtained by a student based on the marks. The criteria to find the grade based on marks as follows:
    Marks        Grade
    0 to 34        F
    35 to 44      E
    45 to 59      D
    60 to 69      C
    70 to 79      B
    80 to 89      A
    90 to 100    A+

Algorithm:
Step1:    Read: Marks
Step2:    if(Marks<=34)
        Write: ‘Grade F’
    else if(Marks<=45)
        Write: ‘Grade E’
    else if(Marks<=59)
        Write: ‘Grade D’
else if(Marks<=69)
        Write: ‘Grade C’
else if(Marks<=79)
        Write: ‘Grade B’
else if(Marks<=89)
        Write: ‘Grade A’
else
Write: ‘Grade A+’
[End of if-else-if]
Step3:    Exit

Here's the C program to solve the above problem.

main()
{
  int marks;
  clrscr();
  printf(“Enter the student’s obtained marks here:\n”);
  scanf(“%d”,&marks);
  if(marks<=34)
     printf(“Grade F”);
  else if(marks<=45)
     printf(“Grade E”);
else if(marks<=59)
     printf(“Grade D”);
else if(marks<=69)
     printf(“Grade C”);
else if(marks<=79)
     printf(“Grade B”);
else if(marks<=89)
     printf(“Grade A”);
else
     printf(“Grade A+”);
getch();
}

Output
If-Else-If Ladder Statement in Computer Programming: C Language

Advantages:

In computer programming, situations involving series of decisions one after the other, each decision or condition may involve expression of various data types such as float, integer, char and double. In these situations the if-else-if ladder is used.

Disadvantages:

  • The nested ifs are hard to understand and modify.
  • As the depth of nesting increases, the readability of the program decreases.
  • In situations involving series of decisions one after the other, each decision or condition may involve expressions which result in integer value. In these situations the usage of if-else-if ladder is not recommended. Instead of this statement, we go for switch statement.

Nested If or If-Else Statement in Computer Programming: C Language

In any computer programming, a variation of if or if-else statement is known as nested if statement. When an if or if-else statement is used within another if or if-else statement then this statement is called nested if statement. When an action has to be performed based on many decisions, then this statement is used. So, it is called multi-way decision statement. There can be many variations of nested if statement. A sample is given below:

if(condition)
{
    if or if-else statement
}
else                           
{
    if or if-else statement
}

The syntax of nested if shown below:
if(condition1)
{
if(condition2)
    {
      Statement(s);
     }
else
     {
       Statement(s);
     }
}
else
{
  Statement(s);
}

In this statement the conditions are evaluated from the top to bottom. If the outermost condition i.e., condition1 is true the statement(s) associated with this condition are executed as the inner if part is executed here. If condition2 is true the statement associated with this condition are executed otherwise the else (condition2’s false part) part’s statement(s) are executed. If the condition1 of outermost if statement is false then, else part of this if statements are executed, as shown in the above syntax.

For example, consider the following statements:
if(salary>=25000)
  {
If(age<=65)
    Write: ‘Increment in salary 25%’
else
    Write: ‘Increment in salary 24%’
  }   

In the above example the if-else statement is inside if statement, hence the above statement is called the nested if statement. Here, if salary >= 25000 and age is less than or equal to 65, then the output is "Increment in salary 25%". If salary is >= 25000 and age is above 65 then the output will be "Increment in salary 24%".

Algorithm:
Step1:    Read:A, B, C
Step2:    if(A>B)
if(A>C)
Write: “A is largest”
else
Write: “C is largest”
          [End of if]
else
if(B>C)
Write: “B is largest”
    else
Write: “C is largest”
         [End of if]
    [End of if]
Step3:    Exit

Nested If statement in computer programming, c language

I am writing a C program to find largest number among the three given number.

main()
 {
intA,B,C;
clrscr();
printf(“Enter any three integer number here:\n”);
scanf(“%d%d%d”,&A,&B,&C);
if(A>B)
     {
if(A>C)
    printf(“Number %d is largest”,A);
else
    printf(“Number %d is largest”,C);
      }
else
     {
if(B>C)
    printf(“Number %d is largest”,B);
else
    printf(“Number %d is largest”,C);
     }
getch();
}

Nested If statement in computer programming, c language

Advantages:


  • There are situations involving series of decisions where we have to use if or if-else statement in another if or if-else statement. In such situations, nested if statements are used.
  • Each and every condition may be evaluated to true or false and may involve expressions of various data types.

Disadvantages:


  • The nested if-statements are difficult to understand and modify.
  • As the depth of nesting increases, the readability of the program decreases.