Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.

Similar presentations


Presentation on theme: "Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000."— Presentation transcript:

1 Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000

2 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/2 Copyright © 2004 Introduction  SQL Server 2000 can be installed on Windows 2000 and Windows XP computers  There are two ways to create database, to insert data, and to modify its structure –Use the Server Enterprise Manager, i.e., graphical design tools similar to those in Microsoft Access –Write SQL statements and submit them to SQL Server via the SQL Query Analyzer utility  Many professionals choose to create structures via SQL, but to modify them with the graphical tools

3 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/3 Copyright © 2004 Example: CREATE TABLE statement

4 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/4 Copyright © 2004 Example: Table Properties

5 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/5 Copyright © 2004 IDENTITY Constraint  SQL Server supports SQL-92 standard  IDENTITY constraint is the only new constraint –IDENTITY (m, n) creates a surrogate key with an Identity Seed of m and an Identity Increment of n –Example: CREATE TABLE CUSTOMER( CustomerID int NOT NULL IDENTITY (1000,1), Name char(25) NOT NULL, CONSTRAINT CustomerPK PRIMARY KEY (CustomerID), CONSTRAINT CustomerAK1 UNIQUE (Name));

6 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/6 Copyright © 2004 Example: Relationship Diagram

7 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/7 Copyright © 2004 Creating Views

8 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/8 Copyright © 2004 Indexes  Indexes are special data structures used to improve database performance  SQL Server automatically creates an index on all primary and foreign keys  Additional indexes may be assigned on other columns that are –Frequently used in WHERE clauses –Used for sorting data

9 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/9 Copyright © 2004 Indexes (cont.)  SQL Server supports two kinds of indexes: –Clustered index: the data are stored in the bottom level of the index and in the same order as that index –Nonclustered index: the bottom level of an index contains pointers to the data  Clustered indexes are faster than nonclustered indexes for updating and retrieval

10 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/10 Copyright © 2004 Application Logic  SQL Server database application can be processed using –Programming language, e.g., C#, C++, Visual Basic, Java, to invoke SQL Server DBMS commands –Stored procedures –SQL Query Analyzer to invoke database commands stored in.sql files –Triggers

11 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/11 Copyright © 2004 Stored Procedures  With SQL Server 2000, stored procedures must be written in TRANSACT/SQL, or T/SQL –T/SQL surrounds basic SQL statements with programming constructs such as parameters, variables, and logic structures such as IF and WHILE  Creating stored procedures –Write a stored procedure in a text file and process the commands using the Query Analyzer –Using Enterprise Manager

12 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/12 Copyright © 2004 Triggers  Triggers can be used to –Enforce business rules –Set complex default values –Update views –Implement referential integrity actions  SQL Server supports INSTEAD OF and AFTER triggers only –A table may have one or more AFTER triggers –AFTER triggers may not be assigned to views –A view or table may have only one INSTEAD OF trigger for each triggering action  Triggers can roll back the transactions that caused them to be fired

13 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/13 Copyright © 2004 Concurrency Control  Three factors determine the concurrency control behavior of SQL Server –Transaction isolation level –Cursor concurrency setting –Locking hints provided in the SELECT clause  Locking behavior also changes, depending on whether actions occur in the context of transactions or cursors independently –Therefore, SQL Server places locks on behalf of the developer –Locks may be placed at many levels of granularity and may be promoted or demoted as work progresses

14 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/14 Copyright © 2004 SQL Server Concurrency Options

15 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/15 Copyright © 2004 SQL Server 2000 Security  SQL server provides two modes of authentication –Windows only: the authentication is provided by the windows operating system –Mixed security: SQL Server will accept either the windows-authenticated user name or it will perform its own authentication  Roles may be assigned to a SQL Server user account –A role is a group of predefined authorities –Public role has the authority only to connect to the database

16 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/16 Copyright © 2004 SQL Server Backup  SQL Server supports several types of backup –A complete backup makes a copy of the entire database –A differential backup makes a copy of the database changes since the last complete backup Differential backups are faster and can be taken more frequently Complete backups are simpler to use for recovery  The transaction log also needs to be periodically backed up

17 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/17 Copyright © 2004 Database Recovery  Both data and log files are created by SQL Server  SQL Server provides a wizard for setting up database maintenance plan, e.g., scheduling database and log backups  To recover a database with SQL Server –The database is restored from a prior database backup –Log after images are applied to the restored database –At the end of the log, changes from any transaction that failed to commit are then rolled back

18 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 11/18 Copyright © 2004 SQL Server Recovery Models  Three recovery models –Simple recovery: neither logging is done nor log records applied To recover a database is to restore the database to the last backup This method can be used for a database that is never changed –Full recovery: all database changes are logged –Bulk-logged: all changes are logged except those that cause large log entries

19 Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000


Download ppt "Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000."

Similar presentations


Ads by Google