Sunday, September 9, 2012

Difference between Web Site and Web application in ASP.NET

• Development Wise Difference

Web Site
1. We can code one page in C# and one page in vb.net .
2. We cannot call (access) public functions from one page to other page.
3. Utility classes / functions must be placed in a special ASP.NET solder(the App_Code folder) 
4. Web Sites do not have a .csproj/.vbproj file that manages the project (the folder that contains the site becomes the project root). 
5. In the Web Site project, each file that you exclude is renamed with an exclude
keyword in the filename.
6. Explicit namespaces are not added to pages, controls, and classes by default, but you can add them manually.

Web Applications
1. Only one programming language allowed per project (Need to decide on programming language when starting project). 
2. We can access public functions from one page to other page.
3. Utility classes / function can be placed anywhere in the  Applications  folder structure. 
4. Web Applications are treated like other .NET Projects and are managed by a project file (.csproj or .vbproj) . 
5. One nice feature of the Web Application Project is it's much easier to exclude files from the project view.
6. Explicit namespaces are added to pages, controls, and classes by default.

• Deployment wise difference

Web Site
1. It has its code in a special App_Code directory and it's compiled into several DLLs (assemblies) at runtime.
2. No need to recompile the site before deployment. 
3. We need to deploy both .aspx file and code behind file. 
4. Small changes to the site do not require a full re-deployment. (We can upload the code file that was changed) 

Web Application
1. web application is precompiled into one single DLL.
2. Site has to be pre-compiled before deployment .
3. Deploy only .aspx page, but not associated code file (the pre-compiled dll will be uploaded) .
4. Even small changes require a full re-compile of the entire site(i.e. if the code for a single page changes the whole site must be compiled) (It requires careful planning to ensure new bugs aren't introduced to the production site when uploading bug fixes or other changes.) 

Thursday, September 6, 2012

Difference between Primary Key and Foreign Key

primary key is a column which uniquely identifies the records in a table. In a broad sense, a primary key is the mixture of a unique key and an index: A collumn with a primary key is indexed to deliver a faster query, and doesn't allow duplicate values to ensure specific data.
Most programmers recommend all tables having a primary key (and only one) to enhance the speed of queries and overall database performance.
An example of a primary key may be found in a table named "departments," which might have a collumn named "department_number" that uniquely identifies each department in the table with a number.
foreign key is a column (the child column) in a table which has a corresponding relationship and a dependency on another column (the parent collumn) that is usually in a different table. Parent columns can have multiple child collumns, but a child collumn can only have one parent column.
The child collumn is the collumn with the foreign key; the parent collumn does not have the foreign key "set" on it, but most databases require the parent collumn to be indexed.
Foreign keys are made to link data across multiple tables. A child collumn cannot have a record that its parent collumn does not have.
Say a table named "employees" has 20 employees (rows) in it. There are 4 departments in the "departments" table. All 20 employees must belong to a department, so a collumn in the "employees" table named "department" would point to the primary key in the "departments" table using a foreign key. Now all employees must belong to a department as specified by the "departments" table. If a department isn't specified in the "departments" table, the employee cannot be assigned to it.

Difference between DDL, DML and DCL commands


DDL – Data Definition Language: statements used to define the database structure or schema. Some examples:
  • CREATE – to create objects in the database
  • ALTER – alters the structure of the database
  • DROP – delete objects from the database
  • TRUNCATE – remove all records from a table, including all spaces allocated for the records are removed
  • COMMENT – add comments to the data dictionary
  • RENAME – rename an object
They are called Data Definition since they are used for defining the data. That is the structure of the data is known through these DDL commands.
DML – Data Manipulation Language: statements used for managing data within schema objects. Some examples:
  • SELECT – retrieve data from the a database
  • INSERT – insert data into a table
  • UPDATE – updates existing data within a table
  • DELETE – deletes all records from a table, the space for the records remain
  • MERGE – UPSERT operation (insert or update)
  • CALL – call a PL/SQL or Java subprogram
  • EXPLAIN PLAN – explain access path to data
  • LOCK TABLE – control concurrency
DML commands are used for data manipulation. Some of the DML commands
insert,select,update,delete etc. Even though select is not exactly a DML language command oracle still recommends you to consider SELECT as an DML command.
DML are not auto-commit. i.e. you can roll-back the operations, but DDL are auto-commit
DCL – Data Control Language. Some examples:
  • GRANT – gives user’s access privileges to database
  • REVOKE – withdraw access privileges given with the GRANT command
Data Control Language is used for the control of data. That is a user can access any data based on the priveleges given to him. This is done through DATA CONTROL
It is used to create roles, permissions, and referential integrity as well it is used to control access to database by securing it.
TCL – Transaction Control: statements used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions.
  • COMMIT – save work done
  • SAVEPOINT – identify a point in a transaction to which you can later roll back
  • ROLLBACK – restore database to original since the last COMMIT
  • SET TRANSACTION – Change transaction options like isolation level and what rollback segment to use
For revoking the transactions and to make the data commit to the database we use TCL. 

Once we commit we cannot rollback. Once we rollback we cannot commit.
Commit and Rollback are generally used to commit or revoke the transactions that are with regard to DML commands.

Difference between Boxing And Unboxing


Tuesday, September 4, 2012

Difference between Public, Private, Protected .....


Public : Allows access to the class member from any other class.
Private : Allows access to the class member only in the same class.
Protected : Allows access to the class member only within the same class and from inherited classes.
Internal : Allows access to the class member only in the same assembly.
Protected internal : Allows access to the class member only within the same class, from inherited classes, and other classes in the same assembly.
Static : Indicates that the member can be called without first instantiating the class.

Difference between an Interface and an Abstract class


There are quite a big difference between an interface and an abstract class, even though both look similar.
    • Interface definition begins with a keyword interface so it is of type interface
    • Abstract classes are declared with the abstract keyword so it is of type class
    • Interface has no implementation, but they have to be implemented.
    • Abstract class’s methods can have implementations and they have to be extended.
    • Interfaces can only have method declaration (implicitly public and abstract) and fields (implicitly public static)
    • Abstract class’s methods can’t have implementation only when declared abstract.
    • Interface can inherit more than one interfaces
    • Abstract class can implement more than one interfaces, but can inherit only one class
    • Abstract class must override all abstract method and may override virtual methods
    • Interface can be used when the implementation is changing
    • Abstract class can be used to provide some default behavior for a base class.
    • Interface makes implementation interchangeable
    • Interface increase security by hiding the implementation
    • Abstract class can be used when implementing framework
    • Abstract classes are an excellent way to create planned inheritance hierarchies and also to use as non-leaf classes in class hierarchies. 

Difference between .EXE and .DLL files


EXE
  1. It is an executable file, which can be run independently.
  2. EXE is an out-process component, which means that it runs in a separate process.
  3. It cannot be reused in an application.
  4. It has a main function.

DLL
  1. It is Dynamic Link Library that is used as a part of EXE or other DLLs. It cannot be run independently.
  2. It runs in the application process memory, so it is called as in-process component.
  3. It can be reused in an application.
  4. It does not have a main function. 

Difference between Web.config and Machine.config


  • The settings made in the Web.config file are applied to that particular web application only whereas the settings of Machine.config file are applied to the whole asp.net application.
  • Web.config file Setting of asp.net all project Machine.config are setting of server setting and when the web side are implemented time it work all project but Web.config file set all projects
  • Web config will be for that particular aplln whereas the Machine .config will for the whole machine
  • Every ASP.NET application that you has a Web.config file . The settings specified in this will imply only to that application.Whereas Your System will have a Machine.config file in Microsoft.NET\Framework\v1.1.4322\CONFIG Folder which contains specifications and settings at a system level.
  • Web.config file is to override the settings from the Machine.config file. Machine.config file settings are applied to all the webapplications residing on the server while Web.config settings are application specific.
  • Machine. config is configuration file for all the application in the IIS. but Web.config is a configuration file for a application or folder.
  • Machine.config for machine level configuration. but Web.config for a application/folder level configuration