Blue Theme Orange Theme Green Theme Red Theme
 
Click Here for 3 Month Free of ASP.NET Hosting!
Home | Forums | Videos | Photos | Downloads | Blogs | E-Books | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » SQL Server 2005/2008 » Designing and creating a database in SQL Server 2005

Designing and creating a database in SQL Server 2005

This articles gives a picture around creating a database in SQL Server 2005 and some guidelines to put the log and data files.

Author Rank:
Technologies: Database, SQL Server 2005,Visual C# .NET
Total downloads :
Total page views :  7756
Rating :
 4/5
This article has been rated :  2 times
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
 
Become a Sponsor


Related EbooksTop Videos


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

  1. 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.
  2. Transaction logs are best placed on a RAID-1 array because this has the fastest sequential write speed.
  3. Data files are best placed on a RAID-5 array because they have faster read speed than other RAID-arrays.
  4. 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)

  1. Start SQL Server Management Studio by selecting Start  Programs  Microsoft SQL Server 2005  Management Studio.
  2. Connect to your default instance of SQL Server.
  3. Expand your Databases folder.
  4. 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.
  5. You should now see the General tab of the Database properties sheet. Enter the database name Sales, and leave the owner as <default>.
  6. 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.
  7. 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.
  8. 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.
  9. Restrict the filegrowth to a maximum of 20MB for Sales_Data2 by clicking the ellipsis button in the Autogrowth column.
  10. Leave all of the defaults for the Sales_Log file.
  11. 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.


Login to add your contents and source code to this article
 [Top] Rate this article
 About the author
 
Vijaya Kadiyala
I have Quite a few years of experience in Microsoft & Oracle Technologies and i would like to share my knowledge to all. Give some and Get some.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Microsoft Visual Studio 2010 offers more to developers than any other Visual Studio release. Work more productively and collaboratively-with greater control over your work at every step. The Beta 2 can give you a head start on achieving efficiency.
 
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
Powerful ASP.NET Hosting w/ NO Setup Fees. Click Here!
Become a Sponsor
 Comments
Do you know how to create Database in Excel... by Romy On July 20, 2009
I am working on a project and my company uses only Excel, they have all their information in Excel and would like to create a database to make it more readable file.  Can you help.
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 1999 - 2009  Mindcracker LLC. All Rights Reserved