What is index and what are the uses?
Indexes are used to retrieve data from the database very fast. The users cannot see the indexes, they are just used to speed up searches/queries.
Without an index when we run a select query on a Customer database with three columns customername, customerage and customerphonenumber with 1000 records to look for customer name “John”, the database software would literally look at each and every row of the database. Even if it finds “John” it would still look at remaining rows because there may be other customers too with same name.
So, to make this kind of searches fast we make of indexes. Indexing is a way of sorting several records on multiple fields. When we create an index on a field in a table it will create another data structure which holds the field value, and pointer to the record it relates to. This index structure is then sorted, allowing Binary Searches to be performed on it.
So, to make this kind of searches fast we make of indexes. Indexing is a way of sorting several records on multiple fields. When we create an index on a field in a table it will create another data structure which holds the field value, and pointer to the record it relates to. This index structure is then sorted, allowing Binary Searches to be performed on it.
Explain about Triggers in SQL
A database trigger is procedural code that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for maintaining the integrity of the information on the database.
The database trigger are executed either before or after our required code. By default it is executed after.
Example:CREATE [OR REPLACE ] TRIGGER trigger_name
{BEFORE |AFTER |INSTEAD OF}
{INSERT [OR] | UPDATE [OR] |DELETE}
[OF col_name]
on table_name
What do you mean by endpoints in WCF?
-
Address: The address uniquely identifies the endpoint and tells potential consumers of the service where it is located. We mainly use URL as address.
-
Binding: The binding specifies how to communicate with the endpoint like transport protocol, encoding for messages and necessary security requirements. WCF uses by default wsHttp binding.
-
Contracts: The contract outlines what functionality the endpoint exposes to the client.There are many contracts like service, operation, data, fault and message contracts. A contract specifies:
-
What operations can be called by a client.
-
The form of the message.
-
The type of input parameters or data required to call the operation.
-
What type of processing or response message the client can expect.
-
Behaviors: We can use endpoint behaviors to customize the local behavior of the service endpoint. Endpoint behaviors achieve this by participating in the process of building a WCFruntime.
Explain Events
Events enable a class or object to notify other classes or objects when something of interest occurs. The class that sends (or raises) the event is called the publisher and the classes that receive (or handle) the event are called subscribers.
Events use delegates and limit communication to only one way. The subscribers only can listen and cannot modify the publisher.
Explain Delegates
A delegate is a type safe function pointer, it holds a reference to a function. The signature of the delegate must match the signature of the function, the delegate points to. A delegate is similar to a class and we can create an instance of it. Delegates are mainly used for communication and callbacks.
Delegates provide two way communication.
We can use multi cast delegates when we need to reference more than one function. When we invoke a multi-cast delegate, all the functions the delegate is pointing to, are invoked.
What is DataReader in ADO.NET?
DataReader is a connected, read-only and forward dataset. We cannot write to database using datareader. It helps to sort,search and filter dataset.
What is connection pooling in ADO.NET
When we create a connection to a database it is time consuming as it involves network-level handshaking and security credentialing for every new connection. In ADO.NET we use connection pooling, which reduces the cost of repeatedly opening and closing connections. In connection pooling the object we created for connection is sent to a pool rather than to a garbage collector and whenever we use the same connection string, it uses the object from pool instead of creating a new connection. There will be individual pools for each connection string and with same connection string we can have many connection objects.
By default pooling is enabled and we can turn off pooling for a specific connection by including the Pooling=false key-value pair in our connection string.
Explain about generics?
Generics are introduced in C# 2.0, they allow us to design classes and methods decoupled from data types. We can make use of generics and increase code reuse, type safety and performance.
What is a constructor and types of constructors?
When we create a class or struct, its constructor is called. Constructor will have same name as a class or struct and is usually used to initialize the data members of the new object. There are three types of constructors:
Instance constructors are used to create and initialize any instance member variables when we use new expression to create an object of a class.
Static constructors are used to initialize static data or to perform actions that need to be performed only once. It is called automatically before first instance is created or any of the static members are referenced.
Private constructors are only used when a class contains only static members.