Pages

Wednesday, April 30, 2008

SQL Server Versions 2005

i was bit confused on SQL Server 2005 versions and also i have couple of mails in my inbox about SQL Server 2005 versions and features.

There are SQL Server 2005 features....

Enterprise Edition
Standard Edition
Workgroup Edition
Developer Edition

Express Edition
Mobile Edition
Everywhere Edition (CTP)

Keep watching for more information

Tuesday, April 29, 2008

Designing and creating a database

SQL Server 2005 stores your database information in two types of files: one or more database files and one or more transaction log files. As a database administrator (DBA), it is your duty to design and create databases to store user data and other objects. As part of your role as a database creator, you must decide how large to make these database files and what type of growth characteristics they should have, as well as their physical placement on your system.

In this article, you will get to know where to create a database and then put the data and log files.

First, you must decide where to put the data and log files.

Guidelines to Use

Data and log files should be on separate physical drives so that, in case of a disaster, you have a better chance of recovering all data.
Transaction logs are best placed on a RAID-1 array because this has the fastest sequential write speed.
Data files are best placed on a RAID-5 array because they have faster read speed than other RAID-arrays.
If you have access to a RAID-10 array, you can place data and log files on it because it has all the advantages of RAID-1 and RAID-5.
Next, you must decide how big your files should be. Data files are broken down into 8KB pages and 64KB extents (eight contiguous pages). To figure out how big your database will need to be, you must figure out how big your tables will be.

You can do that using these steps

Calculate the space used by a single row of the table.

a. To do this, add the storage requirements for each datatype in the table.

b. Add the null bitmap using this formula: null_bitmap = 2 + ((number of columns + 7) /8).

c. Calculate the space required for variable length columns using this formula: variable_datasize = 2 + (num_variable_columns X 2) + max_varchar_size.

d. Calculate the total row size using this formula: Row_Size = Fixed_Data_Size + Variable_Data_Size + Null_Bitmap + Row_Header.
NOTE: The row header is always 4 bytes

Calculate the number of rows that will fit on one page. Each page is 8,192 bytes with a header, so each page holds 8,096 bytes of data. Therefore, calculate the number of rows using this formula: 8096 ÷ (RowSize + 2).

Estimate the number of rows the table will hold. No formula exists to calculate this; you just need to have a good understanding of your data and user community.

Calculate the total number of pages that will be required to hold these rows. Use this formula: Total Number of Pages = Number of Rows in Table / Number of Rows Per Page.
Once you have decided where to put your files and how big they should be, follow these steps to create a database named Sales (you will be creating the files on a single drive for simplicity)

Start SQL Server Management Studio by selecting Start Programs Microsoft SQL Server 2005 Management Studio.

Connect to your default instance of SQL Server.

Expand your Databases folder.

Right-click either the Databases folder in the console tree or the white space in the right pane, and choose New Database from the context menu.

You should now see the General tab of the Database properties sheet. Enter the database name Sales, and leave the owner as .

In the data files grid, in the Logical Name column, change the name of the primary data file to Sales_Data. Use the default location for the file, and make sure the initial size is 3.

Click the ellipsis button (the one with three periods) in the Autogrowth column for the Sales_Data file. In the dialog box that opens, check the Restricted File Growth radio button, and restrict the filegrowth to 20MB.

To add a secondary data file, click the Add button, and change the logical name of the new file to Sales_Data2. Here too use the default location for the file, and make sure the initial size is 3.

Restrict the filegrowth to a maximum of 20MB for Sales_Data2 by clicking the ellipsis button in the Autogrowth column.

Leave all of the defaults for the Sales_Log file.

Click OK when you are finished. You should now have a new Sales database.
You should see a database named Sales in SQL Server Management Studio.

Guidelines on Creating and Designing Database

Data and log files should be on separate physical drives so that, in case of a disaster, you have a better chance of recovering all data.
Transaction logs are best placed on a RAID-1 array because this has the fastest sequential write speed.
Data files are best placed on a RAID-5 array because they have faster read speed than other RAID-arrays.
If you have access to a RAID-10 array, you can place data and log files on it because it has all the advantages of RAID-1 and RAID-5.

Saturday, April 26, 2008

Validation control grouping

Validation control grouping has many advantages. First, it improves performance by instructing ASP.NET to perform validation on controls associated with a particular group. To accomplish this, ASP.NET 2.0 adds a ValidationGroup property to other controls that can cause postbacks such as buttons. This means that you can associate a Save button with a particular validation group. The Page class's Validate method is overloaded to accept a validation group name as an input parameter. When all of this is connected, the button instructs the page to perform server-side validation on only those controls in the specified group.

Another advantage of validation control is that it affords you the ability to restrict the information that is presented in a ValidationSummary control. Clearing the ValidationGroup property of the ValidationSummary control effectively associates the summary control with validation controls that also have a non-specified ValidationGroup property. Alternatively, specifying a value for the ValidationGroup property associates the ValidationSummary control with validation controls in the same group.

ValidationSummary Control

In addition to identifying specific fields with data entry problems, it is often useful to provide users with a summary of validation problems on a form. You can use the ValidationSummary control to provide that summary information to users. The ValidationSummary control is used to display the ErrorMessage property values from validation controls on the page when controls being validated are invalid.

Using the ValidationSummary control can improve usability by minimizing distracting and confusing text and by drawing the user's attention to a single location. Displaying specific data validation problems next to each field can consume a lot of screen real estate. In addition, it can cause shifts in screen layout, which leads to confusion. Using a ValidationSummary control concentrates more verbose information in a single location. Good examples of this include placing asterisks or exclamation points next to fields with validation problems.

CustomValidator Control

The controls described up to this point generally focuses on validating one or two fields based on specific, bounded parameters. Typical requirements, however, usually fall outside the capabilities of the intrinsic controls. In anticipation of this, the creators of ASP.NET made the CustomValidator control. The CustomValidator control provides you with an opportunity to create custom validation logic for situations requiring complex business rules validation.

Like other validation controls, the CustomValidator control exposes common properties such as ControlToValidate, Display, ErrorMessage, Text, and ValidationGroup. Also like other validation controls, the CustomValidator control supports both server-side and client-side validation. To associate custom server logic with the control, you must override the ServerValidate event. One of the parameters of the event handler for this event is an object of type ServerValidateEventArgs. Based on the results of the custom validation logic, you can set the IsValid property of the ServerValidateEventArgs object. For client-side validation, you must create a JavaScript function and reference that function using the ClientValidationFunction property of the CustomValidator control.