Overview and Agenda
I. SQL Server 2008 Platform Overview
II. SQL Server 2008 Architecture
III. Managing Database Objects
IV. Managing Databases
V. Securing SQL Server
VI. Database Maintenance and Data Protection
VII. Reliability & HA Techniques
VIII. SQL Server Maintenance and Best Practices
Relational Database Server Goals
Reliability Availability Scalability
Data
Transaction
Performance Integrity and
Isolation
Protection
Data
Reporting
Analysis
SQL Server 2008 Architecture
• SQL Server Database Engine
– Storage Engine
– Query Engine
• Databases
– Logical collections of related objects
• Instances
– Separate running services of SQL Server
• Default instance and named instances
SQL Server Services
• Instance-Specific • Instance-unaware
(one service per instance): – Notification
– SQL Server Services
– SQL Server Agent – SQL Server
– Analysis Services Browser
– Reporting Services – SQL Server Active
Directory Helper
– Integration
Services – SQL Writer
SQL Server 2008 Admin. Tools
• SQL Server Management Studio[SSMS]
– Database management GUI
• Object browser; templates, reports, etc.
– Support for writing and executing queries
• SQL Business Intelligence Dev.
Studio[BIDS]
– SSIS, SSRS and SSAS
Managing Database Objects
Understanding database design,
tables, and indexes
Understanding Database Schemas
• Schemas
– Logical collection of related database objects
– Part of full object name:
• Server.Database.Schema.Object
– Default schema is “dbo”
• Managing Schemas
– CREATE, ALTER, DROP SCHEMA
– SQL Server Management Studio
– Can assign default schemes to database users:
• WITH DEFAULT_SCHEMA ‘SchemaName’
Overview of Database Objects
Tables Indexes Views Programmability
• Data storage & • Improves • Logical result • Stored
Retrieval query sets Procedures
• Referential performance • Based on • Functions
integrity • Clustered SELECT • Triggers
• Non-clustered queries • Constraints
Managing Databases
An overview of working with physical
and logical database files
SQL Server Physical Data Files
• Database storage
– Primarily table data and index data
• Database Files:
– Primary data file (*.mdf)
– Secondary data files (*.ndf)
– Transaction log file(s) (*.ldf)
• Filegroups:
– Logical collections of files
– Objects can be created on filegroups
Monitoring Disk Usage
• SQL Server Management Studio Reports
– Server: Server Dashboard
– Database: Disk Usage (several reports)
• Transact-SQL
– Stored Procedures:
• sp_Help, sp_HelpDB, sp_SpaceUsed
– System Tables / Views
• Sys.Database_Files
Moving and Copying Databases
• Copy Database Wizard
• Attaching and detaching databases
– Allows directly copying data/log files
– Database must be taken offline
• Backup / Restore
• Other methods:
– SQL Server Integration Services (SSIS)
– Generating scripts for database objects
– Bulk copy / BULK INSERT
Securing SQL Server
Understanding SQL Server 2008’s
security architecture and objects
SQL Server Security Overview
• Layered Security Model:
– Windows Level
– SQL Server Level
– Database
• Schemas (for database objects)
• Terminology:
– Principals
– Securables
– Permissions
• Scopes and Inheritance
Managing Logins
• Windows Logins
– Authentication/Policy managed by Windows
• SQL Server Logins
– Managed by SQL Server
• Based on Windows policies
– Password Policy Options:
• HASHED (pw is already hashed)
• MUST_CHANGE
• CHECK_EXPIRATION
• CHECK_POLICY
Database Users and Roles
• Database Users
– Logins map to database users
• Database Roles
– Users can belong to multiple roles
– Guest (does not require a user account)
– dbo (Server sysadmin users)
• Application Roles
– Used to support application code
Built-In Server / Database Roles
Server Roles Database Roles
• SysAdmin • db_accessadmin
• ServerAdmin • db_BackupOperation
• SetupAdmin • db_DataReader
• SecurityAdmin • db_DataWriter
• ProcessAdmin • db_DDLAdmin
• DiskAdmin • db_DenyDataReader
• DBCreator • db_DenyDataWriter
• BulkAdmin • db_Owner
• db_SecurityAdmin
• public
Configuring Permissions
• Scopes of Securables
– Server
– Database
– Schema
– Objects
• Permission Settings:
– GRANT
– REVOKE
– DENY
• Options
– WITH GRANT OPTION
– AS (Sets permissions using another user or role)
Database Maintenance & Data
Protection
Methods for maintaining, backing up,
and restoring databases
Database Backup Types
• Recovery Models
– Full
– Bulk-logged
– Simple
• Backup operations
– Full Backups
– Differential Backups
– Transaction Log Backups
• Allows point-in-time recovery
Recovery Processes
• Recovery process:
– Latest full backup (Required)
– Latest differential backup (Optional)
– Unbroken sequence of transaction log backups
(Optional)
• All transaction logs should be restored with
NO RECOVERY option (except for the last
one)
– Prevents database from being accessed while
restore process is taking place
Database Maintenance Plans
• Check database integrity
• Shrink database
Maintenance • Rebuild / reorganize indexes
Tasks • Update statistics
• Execute SQL Server Agent Job
Miscellaneous • Maintenance Cleanup Task
Tasks
• Full Backup
• Differential Backup
Backup • Transaction Log Backup
Databases
Maintenance Plan Wizard
• Scheduling
– Single schedule for all tasks
– Multiple schedules
• Databases:
– System, All, All User, or specific databases
• Wizard Options:
– Order of operations
• Manages logging and history of operations
Reliability & High Availability Options
• Database Mirroring
• Log-shipping
• SQL Server Fail-Over Clusters
• Replication
• Load-Balancing (at network or OS level)
SQL Server Maintenance
• Regular tasks
– Monitor disk space usage
– Monitor application performance
– Monitor physical and logical disk space
– Maintain indexes and data files
– Review backup and recovery operations
– Review security
– Review SQL Server Logs and/or Windows logs
– Verify the status of all jobs
Questions & Discussion