News Update :
Showing posts with label Education. Show all posts
Showing posts with label Education. Show all posts

Porn Today

Via  fightthenewdrug.org
comments | | Read More...

Physical Data Model

Physical data model represents how the model will be built in the database. A physical database model shows all table structures, including column name, column data type, column constraints, primary key, foreign key, and relationships between tables. Features of a physical data model include:
  • Specification all tables and columns.
  • Foreign keys are used to identify relationships between tables.
  • Denormalization may occur based on user requirements.
  • Physical considerations may cause the physical data model to be quite different from the logical data model.
  • Physical data model will be different for different RDBMS. For example, data type for a column may be different between MySQL and SQL Server.
The steps for physical data model design are as follows:
  1. Convert entities into tables.
  2. Convert relationships into foreign keys.
  3. Convert attributes into columns.
  4. Modify the physical data model based on physical constraints / requirements.
The figure below is an example of a physical data model.

Physical Data Model

Physical Data Model
Comparing the logical data model shown above with the logical data model diagram, we see the main differences between the two:
  • Entity names are now table names.
  • Attributes are now column names.
  • Data type for each column is specified. Data types can be different depending on the actual database being used.
comments | | Read More...

Logical Data Model

A logical data model describes the data in as much detail as possible, without regard to how they will be physical implemented in the database. Features of a logical data model include:
  • Includes all entities and relationships among them.
  • All attributes for each entity are specified.
  • The primary key for each entity is specified.
  • Foreign keys (keys identifying the relationship between different entities) are specified.
  • Normalization occurs at this level.
The steps for designing the logical data model are as follows:
  1. Specify primary keys for all entities.
  2. Find the relationships between different entities.
  3. Find all attributes for each entity.
  4. Resolve many-to-many relationships.
  5. Normalization.
The figure below is an example of a logical data model.

Logical Data Model

Logical Data Model
Comparing the logical data model shown above with the conceptual data model diagram, we see the main differences between the two:
  • In a logical data model, primary keys are present, whereas in a conceptual data model, no primary key is present.
  • In a logical data model, all attributes are specified within an entity. No attributes are specified in a conceptual data model.
  • Relationships between entities are specified using primary keys and foreign keys in a logical data model. In a conceptual data model, the relationships are simply stated, not specified, so we simply know that two entities are related, but we do not specify what attributes are used for this relationship.
comments | | Read More...

Conceptual Data Model

A conceptual data model identifies the highest-level relationships between the different entities. Features of conceptual data model include:
  • Includes the important entities and the relationships among them.
  • No attribute is specified.
  • No primary key is specified.
The figure below is an example of a conceptual data model.

Conceptual Data Model

Conceptual Data Model
From the figure above, we can see that the only information shown via the conceptual data model is the entities that describe the data and the relationships between those entities. No other information is shown through the conceptual data model.
comments | | Read More...

Data Modelling Concept

Data Modelling:


The three levels of data modeling, conceptual data modellogical data model, and physical data model, were discussed in prior sections. Here we compare these three types of data models. The table below compares the different features:
FeatureConceptualLogicalPhysical
Entity Names
 
Entity Relationships
 
Attributes 
 
Primary Keys 
Foreign Keys 
Table Names  
Column Names  
Column Data Types  
Below we show the conceptual, logical, and physical versions of a single data model.

Conceptual Model Design



Conceptual Model Design

Logical Model Design



Logical Model Design

Physical Model Design



Physical Model Design
We can see that the complexity increases from conceptual to logical to physical. This is why we always first start with the conceptual data model (so we understand at high level what are the different entities in our data and how they relate to one another), then move on to the logical data model (so we understand the details of our data without worrying about how they will actually implemented), and finally the physical data model (so we know exactly how to implement our data model in the database of choice). In a data warehousing project, sometimes the conceptual data model and the logical data model are considered as a single deliverable.

Provided:
http://www.1keydata.com/datawarehousing/data-modeling-levels.html
comments | | Read More...

Data Modelling

comments | | Read More...

If In C#

C# If

If-statement
Often a value is not known. With an if-statement, we make a logical decision based on it. In an if-statement, we test expressions. These evaluate to true or false. And logical operators chain expressions.
A value can be tested by either an if-statement or a switch statement.Stroustrup, p. 133

Example

This program computes the value of an expression. It then tests it in an if-statement. The condition inside the if-statement is evaluated to a boolean value. If the value is true, the inner block is executed.
True:The value equals 5 and thus the expression evaluates to true. The Console.WriteLine method is called.
True, False
Info:In a compiled language, an optimizer can evaluate constants like these even before they are run.
Program that uses if-statement: C#

using System;

class Program
{
    static void Main()
    {
 int value = 10 / 2;
 if (value == 5)
 {
     Console.WriteLine(true);
 }
    }
}

Output

True

Else if

Else keyword
Next, we introduce the "else" statements. The Test method uses the if-statement with two else-if blocks and one else. It returns a value based on the formal parameter. The order of the if-statement tests is important.
So:We must test the more restrictive conditions first, or the less restrictive ones will match both cases.
Program that uses if, else: C#

using System;

class Program
{
    static void Main()
    {
 // Call method with embedded if-statement three times.
 int result1 = Test(0);
 int result2 = Test(50);
 int result3 = Test(-1);

 // Print results.
 Console.WriteLine(result1);
 Console.WriteLine(result2);
 Console.WriteLine(result3);
    }

    static int Test(int value)
    {
 if (value == 0)
 {
     return -1;
 }
 else if (value <= 10)
 {
     return 0;
 }
 else if (value <= 100)
 {
     return 1;
 }
 else // See note on "else after return"
 {
     return 2;
 }
    }
}

Output

-1
1
0
Equals sign
In this program, the Test method uses several branching instructions expressed in high-level if-statements. The formal parameter is tested against zero. We then see if it is less than or equal to ten, and next, 100.
Static Method
Else return. Test() uses a four-part if-statement. It has an else-clause that returns a value. All of the blocks in the if-statement return a value. This means there is no reachable point in the method after the else-statement.
ReturnReturn keyword
Tip:You could delete the else-statement and put the "return 2" code on a separate line.
Else
Note:This reduces the symmetry of the code.
But it also makes it shorter.
It has less syntax noise.

Expressions

And operator
The expression in an if-statement must evaluate to true or false. A number result, or a reference type, is not accepted—a compiler error will occur. Expressions can be complex. Here we see how an expression can be written in two ways.
Tip:In this program, try changing the values of A and B to 1 and 2. With those values, the if-expressions both evaluate to false.
Program that uses if, expressions: C#

using System;

class Program
{
    static void Main()
    {
 int a = 1;
 int b = 3;

 // Use negated expression.
 if (!(a == 1 && b == 2))
 {
     Console.WriteLine(true);
 }

 // Use binary or version.
 if (a != 1 || b != 2)
 {
     Console.WriteLine(true);
 }
    }
}

Output

True
True

Brackets

Brackets are not always required in C# programs. In this example, we use no curly brackets. The bodies of the if-statements are simply the following statements in the source. And if-statements can be nested this way.
Caution:This style is often a bad idea. You cannot add a second line to the body of one of these if-statements.
And:Visual Studio will now insert brackets automatically, so this style of code is not even faster to develop.
The final part of this example, which is a single-line if-statement, may be most useful. If you use a single-line if-statement, the chances a further change will cause problems are less. The code may seem more logical when read.
Program that uses no brackets: C#

using System;

class Program
{
    static void Main()
    {
 int value = 1;
 int size = 2;

 if (value == 1)
     if (size == 2)
  Console.WriteLine("1, 2");

 if (value == 0)
     Console.WriteLine("0"); // Not reached.
 else
     Console.WriteLine("Not 0"); // Reached.

 if (value == 2) Console.WriteLine("2"); // Not reached.
    }
}

Output

1, 2
Not 0

Nested ifs

Note
Nesting if-statements will create a similar flow of control to using the boolean && operator. The arrangement of your if-statements will impact performance in some situations. We explore nested ifs.
Nested If

Switch

Switch
The C# language provides a switch construct that in many cases will provide better performance than if-statements. The compiler turns integer or enum switch statements into jump tables and string switches into Dictionary instances.
Caution:Switch statements can only test an expression against constant values. This is their main limitation.
Switch

Ternary

Question and answer
What is the ternary operator? It is like a question with two answers. It allows us to express a predicate and two consequent statements inside one statement. The ternary statement is compiled into the same code as if-statements use.
Ternary Operator
Null coalescing:This operator uses two question marks. Similar to ternary, it can only be used on a reference variable.
Null Coalescing Operator

Performance

Squares: abstract
In a complex program, having many if-statements for rare paths will reduce performance for common paths. This problem can be solved by using a lookup table or Dictionary. We can encode the branches in data objects.
1. Change expression order.It is possible to improve the performance of if-statements by changing the order you test conditions.
Short-Circuit
2. Use switch.In some program contexts a switch statement is faster than an if-statement. But this is a complex issue.
If Versus Switch Performance
3. Reorder statements.Another way to optimize if-statements is to simply test some conditions before others.
Reorder If-Statements
4. Use Dictionary.A Dictionary can be used as a lookup table. This transforms complex if-statements into a single lookup.
Dictionary
5. Virtual dispatch:Use the type system to add behavior to objects. Place objects in a Dictionary and call their virtual methods.
Virtual

IL

Framework: NET
We consider how if-statements are translated into machine code, which is preceded by intermediate language in the .NET Framework. High-level languages provide structured models. Blocks of code are separated with parentheses.
Chaos
However, these blocks are meaningless to the execution engine. They are instead translated into single instructions that are part of the intermediate language. The IL is flat. It is without scope.
Thus:If-statements are translated to branch instructions. If the condition matches, these "jump" forward.
bne InstructionIntermediate Language

Paths

Concept: a discussion topic
If-statements can be used poorly. If your code has a normal, expected path, try not to obscure that path with excessive if-statements. Instead, use ifs for branches from that path. Next we see what Code Complete has to say.
Write your code so that the normal path through the code is clear. Make sure that the rare cases don't obscure the normal path of execution. This is important for both readability and performance.McConnell, p. 355
Division
If two paths are possible, it is often better to put the common one in the if, and the uncommon one in the else. When reading the code, the more important (common) paths should come first. Earlier things are perceived as more important.
Tip:Some understanding of psychology helps when coding. Clear if-statements make code easier to understand.

Summary

Control flow is like a river. As it proceeds, if-statements cause branches in its path. We find branch opcodes are used in the low-level representation of code. With these, the river forks into separate streams.

Provided :
http://www.tutorialspoint.com/csharp/if_else_statement_in_csharp.htm
comments | | Read More...

Lesson 1: Getting Started with C#

Lesson 1: Getting Started with C#

This lesson will get you started with C# by introducing a few very simple programs. Here are the objectives of this lesson:
  • Understand the basic structure of a C# program.
  • Obtain a basic familiarization of what a "Namespace" is.
  • Obtain a basic understanding of what a Class is.
  • Learn what a Main method does.
  • Learn how to obtain command-line input.
  • Learn about console input/output (I/O).

A Simple C# Program

There are basic elements that all C# executable programs have and that's what we'll concentrate on for this first lesson, starting off with a simple C# program. After reviewing the code in Listing 1-1, I'll explain the basic concepts that will follow for all C# programs we will write throughout this tutorial. Please see Listing 1-1 to view this first program.
Warning: C# is case-sensitive.
Listing 1-1. A Simple Welcome Program: Welcome.cs
// Namespace Declaration
using
 System;

// Program start class
class WelcomeCSS
{
    // Main begins program execution.    static void Main()
    {
        // Write to console        Console.WriteLine("Welcome to the C# Station Tutorial!");
    }
}
The program in Listing 1-1 has 4 primary elements, a namespace declaration, a class, a Main method, and a program statement. It can be compiled with the following command line:
 csc.exe Welcome.cs
This produces a file named Welcome.exe, which can then be executed. Other programs can be compiled similarly by substituting their file name instead of Welcome.cs. For more help about command line options, type "csc -help" on the command line. The file name and the class name can be totally different.
Note for VS.NET Users: The screen will run and close quickly when launching this program from Visual Studio .NET. To prevent this, add the following code as the last line in the Main method:
// keep screen from going away
// when run from VS.NET

Console.ReadLine();
Note: The command-line is a window that allows you to run commands and programs by typing the text in manually. It is often refered to as the DOS prompt, which was the operating system people used years ago, before Windows. The .NET Framework SDK, which is free, uses mostly command line tools. Therefore, I wrote this tutorial so that anyone would be able to use it. Do a search through Windows Explorer for "csc.exe", which is the C# compiler. When you know its location, add that location to your Windows path. Then open the command window by going to the Windows Start menu, selecting Run, and typing cmd.exe. This blog post might be helpful: How to set the path in Windows 7.
The first thing you should be aware of is that C# is case-sensitive. The word "Main" is not the same as its lower case spelling, "main". They are different identifiers. If you are coming from a language that is not case sensitive, this will trip you up several times until you become accustomed to it.
The namespace declaration, using System;, indicates that you are referencing the System namespace. Namespaces contain groups of code that can be called upon by C# programs. With the using System; declaration, you are telling your program that it can reference the code in the Systemnamespace without pre-pending the word System to every reference. I'll discuss this in more detail in Lesson 06: Namespaces, which is dedicated specifically to namespaces.
The class declaration, class WelcomeCSS, contains the data and method definitions that your program uses to execute. A class is one of a few different types of elements your program can use to describe objects, such as structs, interfaces , delegates, and enums, which will be discussed in more detail in Lesson 12: Structs, Lesson 13: Interfaces, Lesson 14: Delegates, and Lesson 17: Enums, respectively. This particular class has no data, but it does have one method. This method defines the behavior of this class (or what it is capable of doing). I'll discuss classes more in Lesson 07: Introduction to Classes. We'll be covering a lot of information about classes throughout this tutorial.
The one method within the WelcomeCSS class tells what this class will do when executed. The method name, Main, is reserved for the starting point of a program. Main is often called the "entry point" and if you ever receive a compiler error message saying that it can't find the entry point, it means that you tried to compile an executable program without a Main method.
A static modifier precedes the word Main, meaning that this method works in this specific class only, rather than an instance of the class. This is necessary, because when a program begins, no object instances exist. I'll tell you more about classes, objects, and instances in Lesson 07: Introduction to Classes.
Every method must have a return type. In this case it is void, which means that Main does not return a value. Every method also has a parameter list following its name with zero or more parameters between parenthesis. For simplicity, we did not add parameters to Main. Later in this lesson you'll see what type of parameter the Main method can have. You'll learn more about methods in Lesson 05: Methods.
The Main method specifies its behavior with the Console.WriteLine(...) statement. Console is a class in the System namespace. WriteLine(...) is a method in the Console class. We use the ".", dot, operator to separate subordinate program elements. Note that we could also write this statement asSystem.Console.WriteLine(...). This follows the pattern "namespace.class.method" as a fully qualified statement. Had we left out the using Systemdeclaration at the top of the program, it would have been mandatory for us to use the fully qualified form System.Console.WriteLine(...). This statement is what causes the string, "Welcome to the C# Station Tutorial!" to print on the console screen.
Observe that comments are marked with "//". These are single line comments, meaning that they are valid until the end-of-line. If you wish to span multiple lines with a comment, begin with "/*" and end with "*/". Everything in between is part of the comment. Comments are ignored when your program compiles. They are there to document what your program does in plain English (or the native language you speak with every day).
All statements end with a ";", semi-colon. Classes and methods begin with "{", left curly brace, and end with a "}", right curly brace. Any statements within and including "{" and "}" define a block. Blocks define scope (or lifetime and visibility) of program elements.

Accepting Command-Line Input

In the previous example, you simply ran the program and it produced output. However, many programs are written to accept command-line input. This makes it easier to write automated scripts that can invoke your program and pass information to it. If you look at many of the programs, including Windows OS utilities, that you use everyday; most of them have some type of command-line interface. For example, if you type Notepad.exe MyFile.txt (assuming the file exists), then the Notepad program will open your MyFile.txt file so you can begin editing it. You can make your programs accept command-line input also, as shown in Listing 1-2, which shows a program that accepts a name from the command line and writes it to the console.
Danger! Regardless of the fact that I documented the proper use of command-line arguments before and after Listing 1-2, some people still send me email to complain that they get an error or tell me there's a bug in my program. In fact, I get more email on this one subject than any other in the whole tutorial. Please read the instructions to include the command-line argument. <Smile />
Note: When running the NamedWelcome.exe application in Listing 1-2, you must supply a command-line argument. For example, type the name of the program, followed by your name: NamedWelcome YourName. This is the purpose of Listing 1-2 - to show you how to handle command-line input. Therefore, you must provide an argument on the command-line for the program to work. If you are running Visual Studio, right-click on the project in Solution Explorer, select Properties, click the Debug tab, locate Start Options, and type YourName into Command line arguments. If you forget to to enter YourName on the command-line or enter it into the project properties, as I just explained, you will receive an exception that says "Index was outside the bounds of the array." To keep the program simple and concentrate only on the subject of handling command-line input, I didn't add exception handling. Besides, I haven't taught you how to add exception handling to your program yet - but I will. In Lesson 15: Introduction to Exception Handling, you'll learn more about exceptions and how to handle them properly.
Listing 1-2. Getting Command-Line Input: NamedWelcome.cs
// Namespace Declaration
using
 System;
// Program start classclass NamedWelcome
{
    // Main begins program execution.    static void Main(string[] args)
    {
        // Write to console        Console.WriteLine("Hello, {0}!", args[0]);
        Console.WriteLine("Welcome to the C# Station Tutorial!");
    }
}
Tip: Remember to add your name to the command-line, i.e. "NamedWelcome Joe". If you don't, your program will crash. I'll show you in Lesson 15: Introduction to Exception Handling how to detect and avoid such error conditions.
If you are using an IDE, like Visual Studio, see your IDE's help documentation on how to set the command-line option via project properties. i.e. in Visual Studio 2010, double-click the Properties folder in your solution project, click the Debug tab, and add your name to Command Line Arguments. The actual step can/will differ between IDE's and versions, so please consult your IDE documentation for more information.
In Listing 1-2, you'll notice an entry in the Main method's parameter list. The parameter name is args, which you'll use to refer to the parameter later in your program. The string[] expression defines the type of parameter that args is. The string type holds characters. These characters could form a single word, or multiple words. The "[]", square brackets denote an Array, which is like a list. Therefore, the type of the args parameter, is a list of words from the command-line. Anytime you add string[] args to the parameter list of the Main method, the C# compiler emits code that parses command-line arguments and loads the command-line arguments into args. By reading args, you have access to all arguments, minus the application name, that were typed on the command-line.
You'll also notice an additional Console.WriteLine(...) statement within the Main method. The argument list within this statement is different than before. It has a formatted string with a "{0}" parameter embedded in it. The first parameter in a formatted string begins at number 0, the second is 1, and so on. The "{0}" parameter means that the next argument following the end quote will determine what goes in that position. Hold that thought, and now we'll look at the next argument following the end quote.
The args[0] argument refers to the first string in the args array. The first element of an Array is number 0, the second is number 1, and so on. For example, if I typed NamedWelcome Joe on the command-line, the value of args[0] would be "Joe". This is a little tricky because you know that you typed NamedWelcome.exe on the command-line, but C# doesn't include the executable application name in the args list - only the first parameter after the executable application.
Returning to the embedded "{0}" parameter in the formatted string: Since args[0] is the first argument, after the formatted string, of theConsole.WriteLine() statement, its value will be placed into the first embedded parameter of the formatted string. When this command is executed, the value of args[0], which is "Joe" will replace "{0}" in the formatted string. Upon execution of the command-line with "NamedWelcome Joe", the output will be as follows:
Hello, Joe!
Welcome to the C# Station Tutorial!

Interacting via the Command-Line

Besides command-line input, another way to provide input to a program is via the Console. Typically, it works like this: You prompt the user for some input, they type something in and press the Enter key, and you read their input and take some action. Listing 1-3 shows how to obtain interactive input from the user.
Listing 1-3. Getting Interactive Input: InteractiveWelcome.cs
// Namespace Declarationusing System;
// Program start class
class InteractiveWelcome
{
    // Main begins program execution.    public static void Main()
    {
        // Write to console/get input        Console.Write("What is your name?: ");
        Console.Write("Hello, {0}! ", Console.ReadLine());
        Console.WriteLine("Welcome to the C# Station Tutorial!");
    }
}
In Listing 1-3, the Main method doesn't have any parameters -- mostly because it isn't necessary this time. Notice also that I prefixed the Main method declaration with the public keyword. The public keyword means that any class outside of this one can access that class member. For Main, it doesn't matter because your code would never call Main, but as you go through this tutorial, you'll see how you can create classes with members that must be public so they can be used. The default access is private, which means that only members inside of the same class can access it. Keywords such aspublic and private are referred to as access modifiers. Lesson 19: Encapsulation discusses access modifiers in more depth.
There are three statements inside of Main and the first two are different from the third. They are Console.Write(...) instead of Console.WriteLine(...). The difference is that the Console.Write(...) statement writes to the console and stops on the same line, but the Console.WriteLine(...) goes to the next line after writing to the console.
The first statement simply writes "What is your name?: " to the console.
The second statement doesn't write anything until its arguments are properly evaluated. The first argument after the formatted string isConsole.ReadLine(). This causes the program to wait for user input at the console. After the user types input, their name in this case, they must press the Enter key. The return value from this method replaces the "{0}" parameter of the formatted string and is written to the console. This line could have also been written like this:
string name = Console.ReadLine(); 
Console.Write("Hello, {0}! ", name);
The last statement writes to the console as described earlier. Upon execution of the command-line with "InteractiveWelcome", the output will be as follows:
>What is your Name?  <type your name here> [Enter Key]
>Hello, <your name here>!  Welcome to the C# Station Tutorial!

Summary

Now you know the basic structure of a C# program. using statements let you reference a namespace and allow code to have shorter and more readable notation. The Main method is the entry point to start a C# program. You can capture command-line input when an application is run by reading items from a string[] (string array) parameter to your Main method. Interactive I/O can be performed with the ReadLine, Write and WriteLinemethods of the Console class.
This is just the beginning, the first of many lessons. I invite you back to take Lesson 2: Operators, Types, and Variables.
Follow Joe Mayo on Twitter.

Provided By :

http://www.csharp-station.com/Tutorial/CSharp/Lesson01

comments | | Read More...

Links

Books

Our Celebrities

My Education Tube

Here on My Education Tube you can find every kind of stuff so keep enjoying and visiting

 
Company Info | Contact Us | Privacy policy | Term of use | Widget | Advertise with Us | Site map
Copyright © 2017. All Next . All Rights Reserved.
Design Template by My Education Tube |