Microsoft sql server 2008 all-in-one desk reference for dummies ebook




















Click Download or Read Online button to get windows-serverfor-dummies book now. This friendly referenceshows you everything you need to know — from installation anddeployment to building and running a Windows Server … windows server all in one desk reference for dummies Download windows server all in one desk reference for dummies or read online books in PDF, EPUB, Tuebl, and Mobi Format.

Following is an overview of a typical installation of the network operating system NOS Windows Server and configuration of your server. Although the details vary, the overall process for other NOS is similar.

In most cases, the best way to install Windows Server is to perform a new Picktorrent: windows server for dummies — Free Search and Download Torrents at search engine. Windows Server For Dummies Amazon.

This site is like a library, Use search box in the widget to get ebook that you want. Click Download or Read Online button to get windows server for dummies book now. In a wired world, networks provide the links that tie all users together. If you want to change the start mode for a service, follow this process:. Click the Service tab. The service properties appear, as shown in Figure Choose the appropriate start mode from the drop-down menu.

Figure The Service Properties tab. Modifying networking settings SQL Server includes support for three major access protocols. These proto- cols dictate the way that users and other systems may connect to your SQL Server databases. Following are the most common protocols. You may use shared memory connections for access to a database instance on the local server only.

There are no con- figuration options for this protocol. It is most appropriate for use on a high-speed LAN, where it may offer enhanced performance. Enabling and disabling protocols SQL Server Configuration Manager allows you to change the protocols used by SQL Server by either enabling or disabling them, which you can do by following these steps:. Click the Protocols folder corresponding to the instance you want to modify.

Choose the appropriate action Enable or Disable from the pop-up menu. SQL Server Configuration Manager warns you that the changes will not take effect until you restart the service. Figure SQL Server network configura- tion. Restart the SQL Server service. To change network protocol settings, follow these steps:. SQL Server displays the properties for the network protocol you selected. Make any desired changes to the properties sheet and click OK to continue.

Network configura- tion errors are one of the most common sources of server problems. When configuring Named Pipes, the only option available to you is changing the name of the Named Pipe. The Shared Memory protocol offers no configu- ration options.

If the authentication and server details are not correct, you may make any changes needed. After making any necessary changes to the connection data, click the Connect button. SSMS displays the server options, as shown in Figure Notice that it uses five folders to organize SSMS options by the fol- lowing categories:.

The folders each contain subfold- ers that you can expand the same way. When you click a root node, the main pane of the SSMS window displays detailed information about that item. The following two Transact-SQL commands change the current database to the sales database and retrieve all information from the stock table in that database. After a moment, SSMS divides the main pane into two sections. The top half shows the query you executed, and the bottom half shows the results of that query.

In the following bullets, I discuss each one of these command line options. If you do not use this option, SQL Server will attempt to connect to a default instance on the local computer.

Suppose that you want to execute the same Transact-SQL query used in the previous section against the sales database:. You may type as many Transact-SQL statements as you want at this prompt and you may use as many lines as necessary to complete each statement. The key is to end each distinct Transact-SQL statement with a semicolon.

Review the results on the screen. If you used the —o option to specify an output file, the query results are stored in that file. Figure shows this entire sequence in a Windows command prompt session. T his part shows you how to create your first database in a SQL Server environment. You need to know how to build your database according to accepted design principles, and a great way to plan your database is to first diagram it on paper before implementing it for real.

If you take the time to map out your database on paper, the odds are on your side that you can build a scalable database that meets your business needs far into the future. You can enjoy a second benefit also: Well-designed data- bases simply perform better. They store and process data efficiently, helping you to minimize the demands on your computer systems and reduce the amount of time clients spend waiting for database transactions to complete. In this chapter, I walk you through the process of properly designing a data- base.

The techniques I discuss apply to any relational database system and work equally well in Microsoft SQL Server, Microsoft Access, Oracle, or any other database you encounter in the future.

I also discuss diagramming tech- niques that can help you easily document your design decisions in a format understood by database professionals around the world. Finally, database designers follow some basic principles intended to improve database efficiency and reduce redundant data.

I conclude the chapter with a look at these techniques, showing you how to normalize your database design and how to choose appropriate data types for your database. Introducing Database Design Concepts Databases store data. You probably already knew that, but you should take a moment to reflect on that simple statement before you read on about data- base design. Everything I mention in this chapter is intended to help you store data efficiently and effectively in your SQL Server databases.

Databases store data efficiently when they minimize the amount of storage space they require to maintain your data. In addition to minimizing space require- ments, efficient databases minimize the amount of time it takes the client to insert and retrieve data. These two requirements may sometimes conflict.

For example, if you normally execute complex database queries that require quite a bit of computation, you can sometimes speed up those queries dramatically by storing precomputed results in your database. However, that storage requires additional space. No single answer exists for all such design decisions.

You need to look at your storage and performance requirements and weigh them against each other to determine an appropriate balance for your organization. Databases store data effectively when they provide you with the means to easily insert, retrieve, and modify data. For example, a user of a retail store database might find information about employees in one table, customers in another table, and products in yet another table.

You can improve the effectiveness of your database by consulting with end users and other stakeholders early in the database design process. An assumption you make early in the design process may come back to haunt you down the road.

Now you need to understand a little more terminology before diving in to database design. Database servers Database software runs on specialized computer systems known as servers. Businesses often mount servers in racks and. Administrators normally interact with them using remote access techniques from their regular desktop systems. The database interacts with the operating system to gain access to server resources, such as hard drive storage, the processor s , and network communications.

A database server may contain one or more separate databases. For example, you might use the same database server to store a database containing cus- tomer information and a completely separate database containing project management information. SQL Server ensures that the databases are isolated from each other. Relational databases Most databases in use today are relational databases. They store data in a fashion that follows the relational model proposed by database pioneer Edgar F.

Codd in The relational model organizes data into a series of related tables. Each table contains rows and columns, as shown in Figure Each column corre- sponds to an attribute: one type of information that you want to store. Each row corresponds to a record: one instance of each column. Each table may be related to one or more other tables. Figure A basic database table. You may find it easier to understand these principles in the context of an example.

Suppose you wanted to create a database table containing address information for your relatives. You might create a table similar to that shown in Table This table contains columns for each piece of information to store about each of your relatives: their first name, last name, address, city, state, and ZIP code. The table also contains rows for each relative. The row for each relative stores the information you know about that person.

The relatives table may also be related to other tables in the database. For example, your database might also contain a cities table such as the one shown in Table that contains information about each ZIP code in the country. The relatives table which contains the ZIP code for each relative is related to the cities table by the common key of the ZIP code. I discuss table relationships in further detail in Chapter 6. When it comes to rows and col- umns, you find a few different terms that all mean the same thing.

The terms row and record are interchangeable. Similarly, columns are sometimes called fields, attributes, or variables. Database tables and spreadsheets have quite a bit in common. In fact, it may help you to think of a database as a collection of related spreadsheets.

Databases, however, offer a number of significant advantages over the use of simple spreadsheets. First, they allow you to create multiple tables and model the way they relate to each other. This grouping of data into tables reduces redundant storage of information, facilitates quick changes to infor- mation that affects large portions of the database, and allows you to pull together related information from multiple sources.

The similarity between databases and spreadsheets is a powerful one. Databases also provide powerful tools to help you interact with your data. For example, you can use a reporting facility called SQL Server Reporting Services SSRS , which helps you provide business users with powerful, inter- active reports in an automated fashion.

Chapter 9 tells you more about SSRS. Organizing a Database Earlier sections in this chapter describe the relational database model and show you how databases organize related data into tables.

In this section, you get started on designing databases that meet your business needs. You do that using a four-step process for organizing a database, as follows:. Define the objectives of your database. Group related data into tables.

Identify primary keys that uniquely identify records. Link related tables together. I cover each of these four design steps in further detail in the following sections. A trip without a clearly defined goal would be a terrible waste of time. Things are no different in a database design project. Instead, begin your journey with the end in mind.

Ask yourself these questions:. Instead, I encourage you to think about database design differently. Walk through the preceding questions to determine what data your business processes require, and only then look at methods you can use to obtain that data and organize it effectively.

This type of thinking will help you overcome the tendency to act like a data packrat, squirreling away all the data you can find. It forces you to focus on business requirements and put in your database only data that is likely to result in business value down the road. When you design tables, keep in mind that your goal is to group related data and reduce redundancy.

If you create too many tables, queries against your database will take a long time to complete. Suppose you are tasked with creating a database for a newspaper delivery service. If you followed the spreadsheet mentality, you might simply create a single table with all this information.

However, having just one table would create two significant problems for you:. Assume that each carrier has 1, customers. What if a carrier quits and you need to reassign customers to a new hire? Instead, you can improve your design by grouping related data into tables. First, look at the data and see what discrete entities already exist in your data.

This example already has the notion of a customer and the separate notion of a carrier. Each of those entities already has some data associated with it. There are two of your tables! The Customers table and Carriers table are shown in Tables and I introduce you to routes and subscription types later in this section. Next, analyze the data and determine whether you can find any abstract concepts that you can use to extract other groups of related data.

Perhaps your business process analysis revealed that your newspaper offers only three subscription types: weekday delivery, weekend delivery, and full-week delivery. You can create a table containing information about each of these subscription types and reduce the amount of information stored in the customer table, as shown in Table Some carriers may have multiple routes, and carriers frequently switch from one route to another.

You should also include this concept by introducing a route table and assigning each customer to a route rather than a carrier. An example routes table appears in Table Notice that the routes table is quite simple.

The sole purpose of this table is to link route and carrier information. Selecting primary keys Each table in a well-designed database should have a primary key that uniquely identifies each row in the table. The primary key is usually a single attribute that the database guarantees will be unique for each row.

When you look for a primary key, first examine the attributes that already exist in the table. Are any of the attributes guaranteed to be unique for every row? If so, those attributes may be a good choice for a primary key. Make sure that your choice of a primary key is guaranteed to be unique. Generally speaking, only U. Good examples of primary keys include unique identifiers issued by an orga- nization.

Many businesses issue employee identification numbers to each employee. If these numbers are never reused, they make excellent primary key candidates. Similarly, colleges and universities issue student identification numbers as an alternative to using SSNs. These also make great primary keys. Any attribute or combination of attributes that uniquely identifies records in a table is known as a candidate key.

The candidate key that you select to uniquely identify those records in the database is known as the primary key. Therefore, a table may contain several candidate keys but only one primary key.

You accomplish this task by selecting foreign keys. Foreign keys identify records in other tables that are related to records in the primary table. Typically, the foreign key in the primary table contains the value of the pri- mary key from the related table. For that table, I introduce the notion of a subscription type and create a business rule requiring a subscription type for each customer. I discuss relationships between tables in further detail in Chapter 6. The previous section of this chapter presents you with a few tables and describes the relationships between them in words.

Figure shows the same concept using a diagram. Friday Saturday. An ER diagram is a common tool that database designers use to document their designs and share them in a commonly understood format.

When you see an ER diagram, there are a few elements you should examine to identify various features of the relational database:. The name of the table appears centered in the shaded area of the box. Each attribute appears in a separate row. In addition, an arrow points from the table containing the foreign key to the referenced table.

Attributes that may contain NULL values discussed later in this chapter appear in a regular typeface. Visio is a great tool that allows you to quickly and easily build many kinds of technical diagrams.

The form of ER diagrams presented in this book is a simplified approach to the diagramming process. Advanced approaches allow you to include addi- tional information in your diagram, such as the type of relationship that exists between tables. He called these principles normalization techniques and created several sets of requirements known as normal forms. In this section, I discuss the three most common normal forms: first normal form abbreviated 1NF , second normal form 2NF , and third normal form 3NF.

The normal forms are cumulative. Normalization techniques provide you with guidelines for sound database design. Keep in mind that they are only guidelines, not inviolable rules. Sometimes business necessity or expediency may dictate deviating from these best practices. First normal form There are two requirements for a table to be in first normal form:.

This criteria is automatically met if you define a primary key for the table. I provide an example to help you understand this concept. Look back at the carriers table in Table However, this table contains a multi-valued attribute. An alternative approach would be to create the table shown in Table What happens if Jeremy wants to add a third route?

The original approach Table creates a separate table to link routes and carriers and allows for an unlimited number of routes per carrier. Second and third normal forms The second normal form 2NF introduces one additional requirement: all attributes that are not part of a candidate key must be functionally depen- dent upon the entire primary key.

The third normal form 3NF also requires that all attributes that are not part of a candidate key must be nontransitively dependent upon each candidate key in the table. This means that the attributes may not be dependent only upon the primary key, because they are dependent upon another attribute that is dependent upon the primary key.

What does all of this boil down to? Imagine if you tried to combine the routes table in Table with the carriers table in Table to get the result shown in Table Normalization requires that you separate this table into a carriers table and a routes table, as I do earlier in the chapter.

The three normal forms described previously are the ones most commonly implemented in databases. There are other, more advanced, normal forms that impose more burdensome requirements that are difficult to implement and often result in significant inefficiencies.

The primary task to perform is the selec- tion of appropriate data types for each of the attributes in your database. The data type tells SQL Server how to interpret the data stored in each column. Here, you can focus on discovering the various data types and mapping them to your design.

They include data types capable of storing both integers and decimal numbers. Table Numeric Data Types Data Type Description Length int Stores integer values rang- 4 bytes ing from —2,,, to 2,,, tinyint Stores integer values ranging 1 byte from 0 to smallint Stores integer values ranging 2 bytes from —32, to 32, bigint Stores integer values ranging 8 bytes from — to —1 money Stores monetary values ranging 8 bytes from —,,,, The maximum precision is 38 digits.

Always use the smallest-length variable that will accommodate all anticipated values stored in a column. Consider the case of an integer value that stores values between 1 and If you use a standard int data type, each row will require 4 bytes for that column.

On the other hand, if you use a tinyint, that column will require only 1 byte per row. Date and time data types SQL Server provides several data types specifically designed for the storage of date and time data. Table shows the character string data types.

Here are a few facts you should know about character string data types:. Doing so avoids the 2-byte overhead of the varchar and nvarchar data types.

Doing so avoids wasting space storing short strings in large spaces. These use half the space that the nchar and nvar- char data types use. You should avoid them to ensure the compatibility of your database with future versions. Use varchar max or nvarchar max instead. The binary data types are shown in Table Examples of binary data include documents, images, encrypted text, and any other data that can be represented in binary form.

SQL Server also supports the image data type but, as is true of text and ntext, image will not be supported in future releases of SQL Server. You should use another binary data type in its place to ensure the compatibility of your database with future versions of SQL Server.

These types appear in Table The timestamp data type is one of the least understood aspects of SQL Server. You can create user-defined types UDTs to develop your own, nonstandard data types. If you did not know the number of times a customer visited your store, you would use the NULL value.

If a customer has never visited your store, you would use a value of 0. When you create a database table, you may specify whether each column may contain NULL values. If you do not allow a column to contain NULLs, users may not create a row without entering an appropriate value for that column. When you compare database values, you need to consider the possibility that a column might contain a NULL value and remember that it may affect the results of your comparison. Here are a few pointers:.

I discuss doing so in Chapter 7. The only exception to this result is if one of the values is known to be false.

In that case, the clause will be false no matter what. And as with any database, you want to apply the basics of good database design, which I cover in Chapter 4. You find out how easily you can configure a new database, populate it with the tables that hold your data, and modify existing tables. Remember that a database is a collection of related tables that store your data.

Each time you install SQL Server on a system, you have the ability to create one or more databases to store different kinds of data. Rather, you create a server that has the capability to store databases. If you just opened the book and skipped to this chapter, you probably want to take a few minutes to look over Chapter 4, where I discuss the proper way to design a database.

If you try to create your database and tables without under- standing that information, you might make design decisions that will make your life difficult down the road.

Redesigning existing database tables requires modifying all the queries and reports that use those tables — a time-consuming task. Although this powerful platform certainly enables you to customize your database, it also includes a great set of default options that can have you up.

Follow these steps to create a new SQL Server database:. Click the Connect button to connect to your server. If your server uses SQL Server Authentication, you also need to provide your username and password in the same window. You see the first screen of the New Database wizard, shown in Figure , which assists you in configuring your database. Type a name that describes your database into the Database Name textbox.

Every database on a SQL Server system must have a unique name. For this example in this chapter, I use the name Cookies. Figure You can configure your data- base using the New Database Wizard. Click through the various pages by using the Select a Page pane in the upper-left corner of the New Database Wizard window.

I discuss recovery models in Chapter Figure shows the Options page with default options. In the interest of keeping your first database simple, I recommend accepting all the default options for now. Click OK to create your database. The computer will probably take a while to build your database. Doing so expands the list of databases, and you should now see your new data- base underneath the System Databases and Database Snapshots entries.

Figure The Progress pane displays while your database is being built. Now you want to change options so that the database automatically closes. No problem! Right-click the database and choose Properties from the pop-up menu. The database Properties window appears and shows the currently selected options. Browse the property pages by clicking their titles in the Select a Page pane of the Properties window; then, modify any option s you want. To do so, you set go to the Options page and set the Auto Close property to True.

I discuss mirroring in Chapter Click OK to confirm your changes. Deleting or renaming a database Occasionally, you may need to delete an entire database when you no longer need it. Also, you might want to change the name you initially assigned to a database based upon changes you make after the initial design.

To delete a database, follow these steps:. Right-click the object and choose Delete from the pop-up menu. Backing up your database before you delete it is a good idea.

After you delete it, your structure and data are gone, and restoring from backup is the only way to bring the database back online. Figure Confirming the deletion of a data- base.

If your use of a database changes over time, you can rename the database to match the revised use. To change the name of a database, follow these steps:. Right-click the object and select Rename from the pop-up menu. Type the new name over the old name and press Enter. After all, to open an Access database, you simply browse your computer and dou- ble-click the database file. Administrators, however, should be aware of these files, because their location and configuration can affect database performance.

In this section, I offer you a look at the files that make up a SQL Server data- base and then turn your attention to the use of filegroups, which help you group related files for convenient file management. By default, SQL Server creates a primary data file named database. SQL Server uses three file types to store database information and logs:.

Each database has one and only one primary data file. By default, this file contains all the data stored in your database. It also contains important configuration information and the location of other database files. Most administrators use the. I discuss transaction logs in Chapter Separating your data files and log files onto separate physical disks helps optimize database performance. For example, if you have four physical disks, you can have a primary data file, two secondary data files, and a log file all on separate disks, improving data access times.

Right-click the database name and select Properties from the pop-up menu. The Properties dialog box appears. Click the Files page in the Select a Page pane. SSMS displays the files associated with the current database. Click the Add button to add a new data file. You see the new data file appear as a new, unnamed row in the Database files table located in the center of the window. Click in the Logical Name cell and type the name of your file Figure Use the scroll bar to view the right side of the Database files table and click the ellipsis.

Click OK to confirm the addition. Figure Adding a secondary data file to a database. Adding log files follows the same process. Just choose the Log file type from the drop-down menu in the Database files table to add a new log file to your database. Removing a file You may want to rearrange the way you stored your database files on disk.

For example, you might plan to remove a drive from a system for mainte- nance purposes. Before doing so, you need to remove the database files stored on that disk. Removing a file from a database is a two-step process: You first need to ensure that the file is empty and then you can remove it from the database. Ensure that the file is empty by following these steps:. Click OK to empty the file.

Right-click the database object and select Properties from the pop-up menu. The filename is now highlighted. Click the Remove button. The file disappears from the list. Click OK to confirm the deletion. Using filegroups If you have a large, complex SQL Server environment, managing individual files may be cumbersome. SQL Server provides the ability to group related files into filegroups to help ease your administrative burden.

Each primary and secondary data file may be a member of one and only one filegroup. A filegroup may contain one or more data files. Log files may not belong to a filegroup. Click the Filegroups page in the Select a Page pane. Click the Add button to add a new filegroup. The new filegroup appears as a new, unnamed entry. Click in the Name cell and type the name of your filegroup. Figure illustrates this process. Figure Creating a new file- group. The PRIMARY filegroup contains a vari- ety of system information and, unless you specify otherwise, serves as the default filegroup for all new data files.

You may change the default filegroup using SSMS by checking the Default box in the desired entry on the filegroups page of the database properties sheet. In this section, you find out how to create a new table, assign it a name, add data columns, and select a primary key. You might create a shops table that holds essential information about each one of the stores in your cookie empire. Your table might contain the columns shown in Table Getting started The first thing you need to do is create the basic structure of your table in SQL Server.

Expand the Tables folder. If your database already has tables, you see a listing of them here. Right-click the Tables folder and select New Table from the pop-up menu. Figure Starting with an empty table. Adding columns After you create the basic table structure, you need to add columns to your table that correspond to the data elements in your design. I outlined the col- umns of a Shops table in Table , shown previously, and now you can use them to duplicate the table by following these steps:.

Click in the empty cell in the Column Name column in the middle pane of the Table Designer window and enter the name of your column for example, Unit Number. Select the appropriate data type using the Data Type drop-down box. Robert D. Schneider is a database optimization consultant who has been delivering software solutions for 15 years. Darril Gibson is a professional trainer specializing in certification and Microsoft technologies.

Details zum Adobe-DRM. Mit dem amazon-Kindle ist es aber nicht kompatibel. Buying eBooks from abroad For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries. Anmeldung Mein Konto Merkzettel 0. Erweiterte Suche.



0コメント

  • 1000 / 1000