1. Trang chủ
  2. » Tất cả

Slide2

27 180 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

Session 2Introduction to Indexes ReviewIn session 1 we learnt about:Data IntegrityDefine and describe data integrityList the rules for data integrityTypes of Data IntegrityIntegrity ConstraintVarious Types of Indexes Session ObjectivesIntroduction to IndexesIndex ArchitectureRetrieving Stored DataFinding RowsVarious Types of IndexesWorking with IndexesViewing Index Information Overview of Data StorageA book contains pages, which contain paragraphs made up of sentences.SQL Server 2005 stores data in storage units known as data pages. These pages contain data in the form of rowsA page type begins with a 94 byte header, which stores system information about the page Database FilesIn SQL Server 2005, every database is mapped over a set of operating-system files. Databases have their individual files.The data and log information are maintained in separate files.The three types of database files in SQL Server are:Primary data filesSecondary data filesLog filesThe primary data file is the starting point of the database and points to the other files in the database. The suggested filename extension for primarydata files is .mdf mdfSecondary data files consist of all of the data files, excluding the primary data file. The recommended filename extension for secondary data files is .ndf ndf.ldfLog files contain all the log information used to recover the database. Theremust be at least one log file for each database. The recommended filenameextension for log files is .ldf. IndexesIn a table, records are stored in the order in which they are entered. Their storage in the database is unsorted. -> when data is to be retrieved from such tables, the entire table needs to be scanned. This slows down the query retrieval process.->When an index is created on a table, the index creates an order for the data rows or records in the table.Emp_NoEmp_NameEmp_DOBEmp_DOJ345 James 24-Sep-196830-May-1990873 Pamela 27-Jul-197019-Nov-1993693 Allan 10-Sep-197001-Jul-1992305 Geoff 12-Feb-197329-Oct-1996Emp_No305345693873 Guidelines about indexesIndexes increase the speed of queries that join tables or perform sorting operationsIndexes implement the uniqueness of rows if defined when you create an index.Indexes are created and maintained in ascending or descending orderIndexes should not be created if they are not used frequently since, maintaining them requires time and resourcesIndexes should not be created on columns having duplicate data Overview of index architectureB-treeRoot NoteIntermediateNodeLeaf Note Overview of index architectureIndex B-tree StructureIndex pageIndex pageIndex/Data PageIndex/Data PageIndex pageIndex/Data PageIndex/Data PageRoot NoteIntermediateNoteLeaf Note Overview of index architectureClustered Indexes causes records to be physically stored in a sorted of sequential order, determines the actual order in which data is stored in the databaseNonclustered Indexes is defined on a table that has data either in a clustered structure or a heap. Each index row in the nonclustered index contains a nonclustered key value and a row locatorIndexClustered Index Nonclustered Index 123doc.vn

Ngày đăng: 12/01/2013, 15:42

Xem thêm

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN