《计算机科学导论Chap 09》由会员分享,可在线阅读,更多相关《计算机科学导论Chap 09(63页珍藏版)》请在金锄头文库上搜索。
1、,An Introduction to Computer Science,计算机科学引论,XIANG, Hui 向辉 Shandong University,Computer Science: An Overview Tenth Editionby J. Glenn Brookshear,Chapter 9: Database Systems,3,Chapter 9: Database Systems,9.1 Database Fundamentals 9.2 The Relational Model 9.3 Object-Oriented Databases 9.4 Maintaining
2、Database Integrity 9.5 Traditional File Structures 9.6 Data Mining 9.7 Social Impact of Database Technology,4,Database,A collection of data that is multidimensional in the sense that internal links between its entries make the information accessible from a variety of perspectives,5,Figure 9.1 A file
3、 versus a database organization,6,Figure 9.2 The conceptual layers of a database implementation,7,Schemas,Schema: A description of the structure of an entire database, used by database software to maintain the database Subschema: A description of only that portion of the database pertinent to a part
4、icular users needs, used to prevent sensitive data from being accessed by unauthorized personnel,8,Database Management Systems,Database Management System (DBMS): A software layer that manipulates a database in response to requests from applications Distributed Database: A database stored on multiple
5、 machines DBMS will mask this organizational detail from its users Data independence: The ability to change the organization of a database without changing the application software that uses it,9,Database Models,Database model: A conceptual view of a database Relational database model Object-oriente
6、d database model,10,Relational Database Model,Relation: A rectangular table Attribute: A column in the table Tuple: A row in the table,11,Figure 9.3 A relation containing employee information,12,Relational Design,Avoid multiple concepts within one relation Can lead to redundant data Deleting a tuple
7、 could also delete necessary but unrelated information,13,Improving a Relational Design,Decomposition: Dividing the columns of a relation into two or more relations, duplicating those columns necessary to maintain relationships Lossless or nonloss decomposition: A “correct” decomposition that does n
8、ot lose any information,14,Figure 9.4 A relation containing redundancy,15,Figure 9.5 An employee database consisting of three relations,16,Figure 9.6 Finding the departments in which employee 23Y34 has worked,17,Figure 9.7 A relation and a proposed decomposition,18,Relational Operations,Select: Choo
9、se rows Project: Choose columns Join: Assemble information from two or more relations,19,Figure 9.8 The SELECT operation,20,Figure 9.9 The PROJECT operation,21,Figure 9.10 The JOIN operation,22,Figure 9.11 Another example of the JOIN operation,23,Figure 9.12 An application of the JOIN operation,24,S
10、tructured Query Language (SQL),Operations to manipulate tuples insert update delete select,25,SQL Examples,select EmplId, Dept from ASSIGNMENT, JOB where ASSIGNMENT.JobId = JOB.JobId and ASSIGNMENT.TermData = “*” insert into EMPLOYEE values (43212, Sue A. Burt, 33 Fair St., 444661111),26,SQL Example
11、s (continued),delete from EMPLOYEE where Name = G. Jerry Smith update EMPLOYEE set Address = 1812 Napoleon Ave. where Name = Joe E. Baker,27,Object-oriented Databases,Object-oriented Database: A database constructed by applying the object-oriented paradigm Each entity stored as a persistent object R
12、elationships indicated by links between objects DBMS maintains inter-object links,28,Figure 9.13 The associations between objects in an object-oriented database,29,Advantages of Object-oriented Databases,Matches design paradigm of object-oriented applications Intelligence can be built into attribute
13、 handlers Can handle exotic data types Example: multimedia,30,Maintaining Database Integrity,Transaction: A sequence of operations that must all happen together Example: transferring money between bank accounts Transaction log: A non-volatile record of each transactions activities, built before the
14、transaction is allowed to execute Commit point: The point at which a transaction has been recorded in the log Roll-back: The process of undoing a transaction,31,Maintaining database integrity (continued),Simultaneous access problems Incorrect summary problem Lost update problem Locking = preventing
15、others from accessing data being used by a transaction Shared lock: used when reading data Exclusive lock: used when altering data,32,Sequential Files,Sequential file: A file whose contents can only be read in order Reader must be able to detect end-of-file (EOF) Data can be stored in logical record
16、s, sorted by a key field Greatly increases the speed of batch updates,33,Figure 9.14 The structure of a simple employee file implemented as a text file,34,Figure 9.15 A procedure for merging two sequential files,Figure 9.16 Applying the merge algorithm (Letters are used to represent entire records. The particular letter indicates the value of the records key field.),36,Indexed Files,Index: A list of key values and the location of their associated records,