Sunday, June 22, 2014

Json with ajax

Json with ajax
Is a web development technique for creating interactive web applications.
It is way to store information in an organized ,easy to access manner, it gives us human readable collection of data that we can access in a really logical manner.
Serialization
Is the process of taking an object and converting it to a format in which it can transported across a network.

Deserialization:
Is the process of using the serialized state information to reconstruct the object from the serialized state to its original state.


The json format is often used for serializing and transmitting structured data.

Ajax is a new technique for creating better, fast and more interactive web app, with the help of XML, html, css and JavaScript
                 
Ajax is used to increase the web page interactively speed and usability
Ajax is the technique of exchanging data with a server and updating the parts of web page without reloading the whole page

Ajax uses XHTML for content and css for presentation as well as the document object model (and javascript for dynamic content display)
Ajax is a web browser technology independent of web server software

Technologies used in Ajax

JavaScript:
It loads typed scripting language JavaScript function is called when an event in the page occurs for the whole Ajax operation


DOM:
API for accessing and manipulating structured documents
Represents the structure of XML and HTML documents

CSS:
Allows for a clear separation of the presentation style from the content and may be changed programmatically by JavaScript.

XMLHttpRequest
JavaScript function that performs asynchronous interaction with the server.

Jquery Ajax
Is a great tool or library which provides a rich set of Ajax Methods to develop interactive web applications
With the Jquery Ajax Methods we can request text, Html, XML or JSON from a remote Server using both HTTP Post or HTTP Get and we can load the external data directly into the selected Html element of our web page

Loading Data using Jquery Ajax
This is very easy to load any static or dynamic data using Jquery Ajax. In order to do this Jquery provides load() method.

Load method: load data from a server and puts the returned data into the selected html element.
Syntax:
[selected].load(url,[data],[callback]);
Data-optional
Callback-success

The required URL parameters specifies the URL that you wish to Load.
The optional data parameter specifies a set of query string key/value pairs to send along with the request.

The optional call back parameter is the name of the function to be executed after the load () method is completed.

Example:
Loading the data from the html page  or we can say loading html content dynamically using Ajax loads()

Page1.html



Page2.html
           




output



  
Loading the content of text file in jQuery ajax load method
TextFile.txt
Write any data
$(“divMain”).load (‘TextFile.txt’);

Passing Data to the Server
Many times we collect input from the user and then we pass that input to the server for further processing.
JQuery Ajax made it easy enough to pass collected data to the server using the Parameter of any available AJAX method

Ex Load ()

Example


Example:

Create two pages with the following names: HtmlPage1.htm and Default.aspx


HtmlPage1.htm



Default.aspx.cs



And run the page HtmlPage1.htm

And then click on Calculate Button the result should be displayed in Default Page



Loading the Data from the Database


LoadData.html




Default2.aspx.cs



Output:



GetMethod()

Jquery.get()
Loads the data from the server using a Http GetRequest

Jquery.Post()
Loads the data from the server


Example

htmlPage





GetServerDateTime.aspx



Output:



$(document).ready(function () {
        $("#btnDt").click(function() {
            $.post("GetServerDateTime.aspx",function(response) {
                alert(response);
            });
        });


        });




var employees = [
    {"firstName":"John", "lastName":"Doe"}, 
    {"firstName":"Anna", "lastName":"Smith"}, 
    {"firstName":"Peter", "lastName": "Jones"}
]


xml
json

more in size
less in size
developed by world wide consortoin
developed by douglos crockford
it has end tags
it does not has end tags




value type and reference type

What are Value types and Reference types?

Memory allocates within a compile time and it will use a stack memory. Stack is faster in access. Stack is under the control of os, so garbage collector can’t interact with this.
Stack is used to store small amount of data.

Reference type: memory allocates in run time and it will uses heap memory. DE allocation of the memory will be take care by garbage collector.
Garbage collector will destroy unused object in memory.
String & Object types comes under Reference Type.

========================================================
What is Implicitly Typed Variable?
This is a new feature, which allows you to declare a variable using the keyword var.
Ex: var x=100-> x is integer
Var s=”Hello”->s is string.


What are Null able Value Types?
To store Null Values we can store null values in value types also
Example:
String str =null ->valid
In value type:
int x=null   à invalid

int? x=null->valid










Saturday, June 21, 2014

Normalization in database

Normalization

The process of minimizing data redundancy with a process of steps is called Normal Forms


 The total normalization process include 9 NF

First Normal Form
Second Normal Form
Third Normal Form
Boycee-Code Normal Form
Fourth Normal Form
Fifth Normal Form
Restrict Union Normal Form
Project Join Normal Form
Sixth Normal Form

First Normal Form
A table is said to be in first Normal Form, only when it has a primary key and it does not contain multiple valued columns

Example
The following table is created for storing the details of the customer of the company

Cust id
Name
Surname
Phone no
1001
Venkat
B
111111
1002
Sai
S
222222
1002
Sai
S
333333
1003
Rakesh
K
444444
1003
Rakesh
K
555555

The above table customer id  is the primary key, but the table is not in first normal form because it has a multi value column phone no

A customer may have multiple contact number hence, phone no column is a multi valued column to convert this table to first normal form divide it into two tables as follows



Cust id
Name
Surname
1001
Venkat
B
1002
Sai
S
1003
Rakesh
K


Cust id
Phone no
1001
111111
1002
222222
1002
333333
1003
444444
1003
555555

In, this table customer id, will be foreign key the above two table , the first table customer id is the primary key and in the second table customer id is the foreign key referring the customer id of the first table.


Second Normal Form
A table is said to be in second normal form, if and only if the table is in first normal form and second normal form and no partial dependencies exists in the table

When, a primary key is on combination  of multiple columns but if the non primary key column depends on part of the primary key and not on entire primary key, then the dependencies is called as partial dependencies

Example
To store the orders placed by the customers to a company the following table is created

order id
item
custname
order date
1
ram
c1
10/1/2007
1
hd
c1
10/1/2007
2
ram
c2
12/10/2007
2
motherboard
c2
12/10/2007



In, the above table primary key is on the combination of order id , item but now primary key columns customer name, order date depends only on order id and not on item, which is called as partial dependencies
Hence, the table is not in second normal form to convert the table to second normal form divide it into a tables as follows
order id
custname
orderdate
1
c1
10/10/2007
2
c2
12/102007


order id
item
1
I1
1
I2
2
I1
2
I5


The above two tables in the first table order id is the primary key, and in the second table order id is the foreign key



Third Normal Form
A table is said to be in the third normal form if and only the table is in second normal form and table does not contains transient dependencies when a non primary key column depends

Example
For storing the details of php students along with details of the professor guiding them a table is created as follows
studentid
s name
professor
prof phone
s1001
ravi
sunil
99999
s1002
srinivas
naresh
88888
s1003
kiran
chandu
343434343
s1004
fsas
dfsa
34343

               

The above table student id is primary key, but the non primary key column professor phone  depends on another non primary key column  professor, than  it is called as transient dependencies

Hence, the table is not in third normal form







To convert this table to third normal form divide it into two tables as follows

prof id
professor
prof phone
prof1
sunil
9999
prof2
naresh
9999
prof3
dsfs
3434343


student id
student name
prof id
s1001
ravi
prof1
s1002
srinivas
prof2
s1003
kiran
prof3
s1004
sfsf
prof2














Tuesday, June 17, 2014

CLR Integration

CLR integration

Up to sql server 2000, there is concept called External Stored sub programs, that allows you to create stored sub program in c,c++ and then integrate to sql server. This feature is replaced with CLR integration in sql server 2005.

CLR Integration allows you to create stored sub programs in Dot Net languages like C#.NET, or VB.Net and then integrate to sql server. Main purpose of either external stored sub programs or CLR Integration is to allow the users to use the features like accessing files in operating system.

Using stored sub programs which are not possible with TSQL programming

CLR Integration feature is by default disable in sql server and you must enable it and for this purpose use
sp_configure stored procedure as follows

sp_configure ‘clr enabled’, reconfigure

Within visual studio.net create a project of type sqlserver database project.
Create required stored procedures, user defined functions and trigger within that project using C#.NET syntax and compile the project to generate a dll file.
While creating stored procedure , user defined function, and triggers within the sql server database project you have to follow the following rules

The method that are to be integrated as stored procedures must be specified with [Sql Procedure] attribute method to be integrated as user defined functions  must be specified with [sql function] attribute and methods to be integrated as triggers  must be specified with [sql trigger]

Methods to be integrated  into sql server must be declare with public and static

Methods to be integrated to sql server as stored procedures or triggers must have the return type void.

Methods to be integrated to sql server as triggers must  not have any parameters

Create an assembly  in sql server from ddl generated for sql server DB project using create assembly command that has the following syntax
Create assembly <assemblyname>
From <dllpath>
[with permission_set=safe| unsafe| external_access]

Create stored procedures, user defined functions and triggers with in sql server from the methods created in sql server database project by using “external name” option within create procedure , create function, and create  trigger command

Example

The following example creates one stored procedure and one user defined functions with in c#.net and integrate them with sql server


File->New Project



Add new item




And write the following code




build the solution, then .dll file is created.


Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...