foundations of relational implementation (1) is 240 – database management lecture #13 –...
TRANSCRIPT
Foundations of Relational
Implementation (1)
IS 240 – Database ManagementLecture #13 – 2004-04-01
Prof. M. E. Kabay, PhD, CISSP
Norwich University
2 Copyright © 2004 M. E. Kabay. All rights reserved.
Topics
Review of Relational TerminologyDefine DB Using DDLAllocate Disk SpacePlan for MaintenanceLoading the DBDML Interfaces
3 Copyright © 2004 M. E. Kabay. All rights reserved.
Review of Relational Terminology
Relation / table / file / datasetTuple / row / record / entryAttribute / column / fieldDomainUniqueness
4 Copyright © 2004 M. E. Kabay. All rights reserved.
Key – Two Meanings
Design: unique identifier(s) of row Implementation: performance toolLogical key: unique identifierPhysical key: column with an index for faster
performance
5 Copyright © 2004 M. E. Kabay. All rights reserved.
Indexes
Kroenke reserves word “key” for logical keyUses word “index” for physical key Indexes are useful
Find rows fastRetrieve rows in a sorted orderEnforce uniqueness
6 Copyright © 2004 M. E. Kabay. All rights reserved.
Example of Indexes in a Database
Compare # I/Os required to read all the order #9890Without
indexWith index
on OrdNoWith
packing* on index
OrdNo OrderData OrdNo OrderData9890 … 343 …7882 … 343 …7572 … 967 …5308 … 3072 …5308 … 4502 …8021 … 5308 …8496 … 5308 …9394 … 5308 …3072 … 7572 …7882 … 7882 …9890 … 7882 …5308 … 8021 …4502 … 8021 …8021 … 8496 …9890 … 9394 …967 … 9836 …343 … 9890 …343 … 9890 …9836 … 9890 …
*
1 b
lock
7 Copyright © 2004 M. E. Kabay. All rights reserved.
Implementing RDB
Having designed a DB using the relational model, there’s no problem in defining a DB using today’s DBMS products
Use the Data Definition Language (DDL) of the DBMSFormalized language for describing what
we needVaries a bit from DBMS to DBMSEasy to learn once you’re mastered any
one of them
8 Copyright © 2004 M. E. Kabay. All rights reserved.
Define DB Using DDL
Text-file (schema) DDLSpecific syntaxName all the elementsName all the tablesName all the indexes and links
Graphical systemsMS-Access uses tables and also graphicsEasy to define details using textStructures can be linked using graphicsMenus provide guidance, limits
9 Copyright © 2004 M. E. Kabay. All rights reserved.
Allocate Disk Space
PC-based products generally allocate space dynamicallyDB grows as neededDon’t have to worry about defining
maximum sizeMainframe / server DBs generally require size
definitionsNeed to reserve space in advancePerformance issues become important
Multiple disk drives or controllersTry to avoid thrashing of disk heads
10 Copyright © 2004 M. E. Kabay. All rights reserved.
DB Performance Issues
Computer system performance always depends on 5 factorsAccess to & speed of CPUAccess to & speed of RAMAmount & speed of disk I/OCommunications speedApplication design
DB performance often affected byPresence / absence of indexesGood / bad packing of recordsLocking strategies (coming in later lecture)
11 Copyright © 2004 M. E. Kabay. All rights reserved.
Plan for Maintenance
Databases often central components of production systems
Plan forBackupsDiagnostics to find corrupted data
Child records without parentsRecord counters that are incorrectPointers to non-existent recordsData that violate business rules
Archiving inactive recordsCompaction of data files
12 Copyright © 2004 M. E. Kabay. All rights reserved.
Loading the DB
Have to get data somewhereMost DBs get historical data
Older DBsSpecial programs written to read old DB,
write into new DB with correct formatOften get exceptions – write to exception
fileMay have large-scale data entry from paper
records – need careful verificationSome critical systems use dual data entry
Compare records
13 Copyright © 2004 M. E. Kabay. All rights reserved.
Types of Data Manipulation Languages (DMLs)Relational algebraRelational calculusTransform-oriented languagesGraphical interfaces
14 Copyright © 2004 M. E. Kabay. All rights reserved.
Relational Algebra
Operators function on recordsUnion / intersection etc.
Much like set theoryProcedural language
Step-by-step changes in collections of dataNot used in commercial DBsUseful to understand as preparation for SQLWill study in next lesson
15 Copyright © 2004 M. E. Kabay. All rights reserved.
Relational Calculus
Non-procedural theoretical framework for dealing with relations
E.g., De Morgan's law, “The complement of a union is equal to the union of the complements."
Learned in mathematics and advanced theory of programming and data structures
Not used in commercial DB processingNot part of this course
16 Copyright © 2004 M. E. Kabay. All rights reserved.
Transform-Oriented Languages
Non-proceduralChange relations into a single relationThus define conditions for selecting records
and end up with a set of records that satisfy the conditions
SQL is most important example of this kind of language
Will study in detail in this course
17 Copyright © 2004 M. E. Kabay. All rights reserved.
Graphical Interfaces (1)
Query-by-Example (QBE)
User sees place to enter specific values or rangesGenerates SQL without bothering user
18 Copyright © 2004 M. E. Kabay. All rights reserved.
Graphical Interfaces (2)
Query-by-Form (QBF)Allows more complex queriesStill generates underlying SQL
19 Copyright © 2004 M. E. Kabay. All rights reserved.
DML Interfaces to the DBMS
Forms (e.g., in MS-Access)Query languages (e.g., SQL)Stored procedures (incl. triggers)API = application program interface
20 Copyright © 2004 M. E. Kabay. All rights reserved.
Homework
For Thu 8 April 2004: REQUIREDReread chapter 8, pp. 211-221 thoroughly
using Read-Recite-Review phases of SQ3RDo exercises 8.1-8.17 for 34 points
For next Tuesday:Read onwards in chapter 8 from page 221
through 231Continue working on MS-Access lab work
21 Copyright © 2004 M. E. Kabay. All rights reserved.
DISCUSSION