What is the use of indexes and what are the types of indexes available in SQL Server?
Indexes are used to find data quickly when a query is processed in any relational database. Indexes improve performance by 10 to 500 times.
Index can improve the performance in following operations:
Find the records matching with WHERE clause
UPDATE Books SET Availability = 1 WHERE SubjectId =12
DELETE FROM Books WHERE Price <10
SELECT * FROM Books WHERE Price BETWEEN 50 AND 80
Sorting the result with ORDER BY
SELECT * FROM Books ORDER BY Price DESC
Grouping records and aggregate values
SELECT Count(*) as Units, Price FROM Books GROUP BY Price
There are two types of indexes available in SQL Server: clustered and non-clustered
Clustered index
Clustered index physically reorders the records of a table. Therefore a table can have only one clustered index. Usually a clustered index will be created on the primary key of a table.
Non – Clustered Index
Non – Clustered index are stored in the order of the index key values, but the information in the table is stored in a different order. Means logical sorting of data not Physical. In SQl Server 2005 a table can have 249 non-clustered indexes.
Composite Indexes
A composite index is an index on two or more columns. Both clustered and non-clustered indexes can be composite indexes. If you have composite index on Price and BookName then take can take advantage of it like this:
SELECT BookName, Price FROM Products ORDER BY UnitPrice BookName, Price DESC
What is the difference between abstract class and interface?
We use abstract class and interface where two or more entities do same type of work but in different ways. Means the way of functioning is not clear while defining abstract class or interface. When functionality of each task is not clear then we define interface. If functionality of some task is clear to us but there exist some functions whose functionality differs object by object then we declare abstract class.
We can not make instance of Abstract Class as well as Interface. They only allow other classes to inherit from them. And abstract functions must be overridden by the implemented classes. Here are some differences in abstract class and interface.
An interface cannot provide code of any method or property, just the signature. we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract. An abstract class can provide complete code of methods but there must exist a method or property without body.
A class can implement several interfaces but can inherit only one abstract class. Means multiple inheritance is possible in .Net through Interfaces.
If we add a new method to an Interface then we have to define implementation for the new method in every implemented class. But If we add a new method to an abstract class then we can provide default implementation and therefore all the existing code might work properly.
What is the use of Master Pages in Asp.Net?
A master page in ASP.Net provides shared HTML, controls, and code that can be used as a template for all of the pages of a website.
Every master page has asp:contentplaceholder control that will be filled by the content of the pages that use this master page.
You can create a master page that has header and footer i.e. a logo, an image, left navigation bar etc and share this content on multiple pages. You need not to put these things on every aspx page.
No comments:
Post a Comment