Presentation is loading. Please wait.

Presentation is loading. Please wait.

信息处理技术. Chapter 10: Databases2 111Chapter 4: File Management, Virus Protection, and Backup 1Chapter 1: Computer, Internet, Web, and E-Mail Basics.

Similar presentations


Presentation on theme: "信息处理技术. Chapter 10: Databases2 111Chapter 4: File Management, Virus Protection, and Backup 1Chapter 1: Computer, Internet, Web, and E-Mail Basics."— Presentation transcript:

1 信息处理技术

2 Chapter 10: Databases2 111Chapter 4: File Management, Virus Protection, and Backup 1Chapter 1: Computer, Internet, Web, and E-Mail Basics

3 Chapter 10: Databases3 After this chapter, you should be able to: –Define basic database terminology, such as fields, records, record types, and cardinality –Describe the characteristics of hierarchical, network, relational, and object-oriented databases –Explain the capabilities of various data management tools, such as commercial applications, word processing software, spreadsheet software, file management software, and database management Chapter 10 Preview

4 Chapter 10: Databases4 –Describe various ways to provide access to databases via the Web –Explain how to design an effective relational database –Use your knowledge of SQL queries to describe how to add records, delete records, search for information, update fields, and simultaneously access data from multiple tables Chapter 10 Preview

5 Chapter 10: Databases5 Chapter 10 Outline Section A –File and Database Concepts Section B –Data Management Tools Section C –Database Design Section D –SQL

6 Computer Concepts 8th Edition Chapter 10 Databases Section A: File and Database Concepts 文件及数据库的概念

7 Chapter 10: Databases7 A database is a collection of information Databases are typically stored as computer files A structured file uses a uniform format to store data for each person or thing in the file Databases and Structured Files: What is a database? Page 514

8 Chapter 10: Databases8 A field contains the smallest unit of meaningful information Each field has a unique field name that describes its contents A field can be either variable length or fixed length Fields: What is the basic element of a structured file? Page 514

9 Chapter 10: Databases9 Records: What is a record? A record refers to a collection of data for someone or something A record is made of fields of individual pieces of data for each person or thing Page 515

10 Chapter 10: Databases10 A data file that contains only one record type is often referred to as a flat file In contrast, a database can contain a variety of different record types Relationships and Cardinality: How do record types pertain to files and databases? Page 517

11 Chapter 10: Databases11 An association between data that’s stored in different record types (a field in one table can refer to a record in another Table) One important aspect of the relationship between record types is cardinality Cardinality refers to the number of associations that can exist between two record types –A particular order cannot be placed jointly by two customers When one record is related to many records, the relationship is referred to as a one-to-many relationship What are relationships? Page 517

12 Chapter 10: Databases12 What are relationships? Page 518 ???

13 Chapter 10: Databases13 Not Relationship Stores data in a collection of related tables Each table (also called a “relation”) is a sequence, or list, of records. All of the records in a table are of the same record type What’s a relational database? Page 520

14 Chapter 10: Databases14 What’s a relational database? Page 520

15 Chapter 10: Databases15 Stores data as objects, which can be grouped into object classes, and defined by attributes and method A class specifies the attributes and methods that are shared by all objects in a class A class attribute is equivalent to a field, and contains the smallest unit of data A method is any behavior that the object is capable of performing What’s an object-oriented database? Page 521

16 Chapter 10: Databases16 What’s an object-oriented database? Page 521

17 Computer Concepts 8th Edition Chapter 10 Databases Section B: Data Management Tools 数据管理工具

18 Chapter 10: Databases18 The simplest tools for managing data are software packages designed for a specific data management task To use one of these tools, you just enter your data The software provides menus that allow you to manipulate your data after it is entered Data Management Software: Are simple data management tools available? Page 522

19 Chapter 10: Databases19 How about a simple, generic tool that allows me to define a file structure? Page 522

20 Chapter 10: Databases20 How about a simple, generic tool that allows me to define a file structure? Page 523

21 Chapter 10: Databases21 DBMS (database management system) refers to software that is designed to manage data stored in a database An XML DBMS, for example, is optimized for handling data that exists in XML format An OODBMS (object-oriented database management system) is optimized for the object-oriented database model Database Management Systems: What kinds of tools are specifically designed for creating and manipulating databases? Page 525

22 Chapter 10: Databases22 An RDBMS (relational database management system) allows you to create, update, and administer a relational database Today’s most popular RDBMS software also provides capability to handle object classes and XML data What kinds of tools are specifically designed for creating and manipulating databases? Page 525

23 Chapter 10: Databases23 What kinds of tools are specifically designed for creating and manipulating databases? Page 525

24 Chapter 10: Databases24 The Web provides both opportunities and challenges for accessing the information in a database The Web provides an opportunity for many people to gain access to data from many locations Web access is constrained by the stateless nature of HTTP Web access to hierarchical, network, relational, and object-oriented databases is Databases and the Web: Is it possible to access a database over the Web? Page 527

25 Chapter 10: Databases25 What’s the simplest way to provide Web-based access to a database? Page 527

26 Chapter 10: Databases26 What if I want to provide access to current data? Page 528

27 Chapter 10: Databases27 Is it possible to add and update database records via the Web? Page 529

28 Chapter 10: Databases28 Several tools, including ASP, CGI, and PHP help you create server-side programs ASP (Active Server Pages) technology can be used to generate an HTML document that contains scripts Scripts are small embedded programs that can be designed to get user input, run queries, and display query results CGI (Common Gateway Interface) provides a non-proprietary way to create HTML pages based on data in a database How do I create server-side programs? Page 529

29 Chapter 10: Databases29 How do I create server-side programs? Page 530

30 Chapter 10: Databases30 XML is a markup language that allows field tags, data, and tables to be incorporated into a Web document HTML documents contain lots of information XML provides tags that can be embedded in an XML document to put data in context XML Documents: How does XML relate to the Web and databases? Page 530

31 Chapter 10: Databases31 XML’s most positive contributions to data management is the ability to add context to the information contained in a widely diverse pool of documents on the Web An XML document can also contain structured data organized into records and fields Storing data in an XML document provides several advantages –It is “portable” How is XML typically used today? Page 531

32 Chapter 10: Databases32 How is XML typically used today? Page 531

33 Computer Concepts 8th Edition Chapter 10 Databases Section C: Database Design 数据库设计

34 Chapter 10: Databases34 The first step in designing a relational database is to determine what data must be collected and stored A database designer might begin by listing available data, as well as any additional data that is necessary to produce on-screen output or printed reports The next step is to organize that data into fields Defining Fields: How does a database designer know what data to store? Page 533

35 Chapter 10: Databases35 The treatment of first and last names illustrates the concept of breaking data into fields With the entire name in one field, the database would not be able to access individual parts of the name Why are last names stored in a different field than first names? Page 533

36 Chapter 10: Databases36 A computer must have some way to differentiate between records A primary key is a field that contains data unique to a record Examples: SSN, RUID, not lastname What makes each record unique? Page 534

37 Chapter 10: Databases37 The data that can be entered into a field depends on the field’s data type From a technical perspective, a data type specifies the way data is represented on the disk and in RAM From a user perspective, the data type determines the way that data can be manipulated, e.g. addition The two most common data types are numeric and character How does a database designer know what data types to use? Page 534

38 Chapter 10: Databases38 Real, e.g. 3.14, $5.99 Integer, e.g. 0, 1, 2345 Date, e.g. 11/10/2005 Text, e.g. Gilbert, Grape (fixed length) Logical, e.g. yes/no, on/off, opened/closed Memo, Text with no fixed length BLOB, binary files, e.g. MSWord.exe, itec100.xls, me.gif Hyperlink, e.g. www.radford.edu/~kstevens2 How does a database designer know what data types to use? Page 534

39 Chapter 10: Databases39 A computed field is a calculation that a DBMS performs during processing An efficiently designed database uses computed fields whenever possible Example: MSRP, DiscountPrice, (Savings) How does a database handle computations? Page 535

40 Chapter 10: Databases40 The information supplied by reports and processing routines is only as accurate as the information in the database, GIGO Data entry errors can compromise the accuracy and validity of a database Most DBMS tools that the database designer can use to prevent some, but not all, data entry errors, e.g. require a decimal point, 3.00, or must be numeric In a case sensitive database, uppercase letters are not equivalent to their lowercase counterparts, e.g. Jewel, jewel, JEWEL Can a database designer prevent people from entering inaccurate data? Page 536

41 Chapter 10: Databases41 Can a database designer prevent people from entering inaccurate data? Field validation rule, range $0.00 - $100.00 Pick from a list Look up routine Field format Page 536

42 Chapter 10: Databases42 Normalization helps the database designer create a database structure that can save storage space and increase processing efficiency The goal of normalization is to minimize data redundancy The first step to grouping fields is to get an idea of the “big picture” of the data Groupings correspond to the physical items (nouns), or entities, that are tracked in the database Normalization: How does a database designer group fields into tables? Page 537

43 Chapter 10: Databases43 This data redundancy not only requires extra storage space, but also may lead to storing inconsistent or inaccurate data The solution is to create separate tables If the designer provides fields for ordering ten items, the database cannot handle large orders for more than ten How does a database designer group fields into tables? Page 538

44 Chapter 10: Databases44 How does a database designer group fields into tables? Page 543

45 Chapter 10: Databases45 How does a database designer group fields into tables? Page 538

46 Chapter 10: Databases46 If a customer orders fewer than ten, space is wasted by having empty fields in each record A one-to-many relationship exists between an order and the ordered items The database designer should separate the data into two tables such as Orders and OrderDetails How does a database designer group fields into tables? Page 538

47 Chapter 10: Databases47 How does a database designer group fields into tables? Page 538

48 Chapter 10: Databases48 A table’s sort order is the order in which records are stored on disk Sorted tables typically produce faster queries and updates Queries and updates within an unsorted database are slow A table’s sort key is one or more fields that are used to specify where new records are inserted in a table A table can have only one sort key at a time, but the sort key can be changed, which is slow What happens when the data in a table is sorted? Page 539

49 Chapter 10: Databases49 A database index contains a list of keys, and each key provides a pointer to the record that contains the rest of the fields related to that key An index has no bearing on the physical sequence of records on disk A table can have multiple indexes, but only one sort order Database tables should be indexed by any field or fields that are commonly used as search fields The database designer typically creates indexes at the time the database structure is designed How is indexing different from sorting? Page 539 Figure 10-36

50 Chapter 10: Databases50 Arrange fields in a logical order Provide visual clues, e.g. color Provide easy-to-use controls, e.g. buttons, lists Scroll only if absolutely necessary Provide instructions/help, e.g. Help System, ToolTips Provide appropriate Field Labels What makes a good interface? Page 540

51 Chapter 10: Databases51 A report generator is a software tool that provides the ability to create report templates for a database A report template contains the outline or general specifications for a report The template does not, however, contain data from the database Data is merged into the template when you actually run a report When you actually produce a report, it is based on the data currently contained in the database table Designing Report Templates: How can I display or print data as a formatted report? Page 542

52 Chapter 10: Databases52 The database designer can create templates for reports that effectively present information by observing the following guidelines: –Supply only the information required –Present information in a usable format –Information should be timely How does the database designer create effective report templates? Page 543

53 Chapter 10: Databases53 –Information should be presented in a clear, unambiguous format, and include necessary titles, page numbers, dates, labels, and column headings –Present information in the format most appropriate for the audience How does the database designer create effective report templates? Page 543

54 Chapter 10: Databases54 A conversion routine converts the data from its current format into a format that can be automatically incorporated into the new database An import routine brings data into a database An export routine copies data out of a software package, and into the database How is data loaded into the database tables? Page 544

55 Computer Concepts 8th Edition Chapter 10 Databases Section D: SQL 数据库查询语言 -SQL

56 Chapter 10: Databases56 Structured Query Language, SQL Work behind the scenes as an between the client software provided to users, and the database itself Intermediary database client software collects your input, then converts it into an SQL query An SQL query operates directly on the database to carry out your instructions How does a query language work? Page 546

57 Chapter 10: Databases57 How does a query language like SQL work? Page 546 SQL Query

58 Chapter 10: Databases58 An SQL query is a sequence of words, much like a sentence –SELECT TrackTitle FROM Tracks WHERE TrackTitle = ‘Fly Away’ The SQL query language provides a collection of special command words called SQL keywords Many SQL queries can be divided into three simple elements that specify an action, the name of a database table, and a set of parameters What does a simple SQL query look like? Page 547

59 Chapter 10: Databases59 How does SQL specify the action that I want carried out in the database? Page 547

60 Chapter 10: Databases60 SQL keywords such as USE, FROM, or INTO can be used to construct a clause specifying the table that you want to access. The clause consists of the keyword followed by the name of the table How does SQL specify which table to use? Page 547

61 Chapter 10: Databases61 The term parameter refers to the detailed specifications for a command Keywords such as WHERE usually begin an SQL clause containing the parameters for a command How does SQL specify parameters? Page 548

62 Chapter 10: Databases62 The client software that you use collects the data that you enter in the form and generates an SQL statement using the INSERT command, which adds your data to the database Adding Records: How are records added to a database? Page 548

63 Chapter 10: Databases63 One of the most common database operations is to query for a particular record or group of records using the SELECT command Searching for Information: How do SQL queries carry out searches? Page 549

64 Chapter 10: Databases64 SQL uses search operators to form complex queries Because search operators were originally the idea of mathematician George Boole, they are also referred to as Boolean operators Can SQL perform complex searches? Page 549

65 Chapter 10: Databases65 AND (sometimes indicated by a + sign) is used when you want to retrieve records that meet more than one criteria The AND operator specifies that both of the search criteria must be true for the record to be selected SELECT CDName FROM CompactDisks WHERE ArtistName = ‘Beyonce’ AND DiscountPrice < 10.00 How does AND work in an SQL query? Page 549

66 Chapter 10: Databases66 Inclusive OR Exclusive OR –SELECT CDName FROM CompactDisks WHERE (ArtistName = ‘Beyonce’ OR ArtistName = ’Destiny’s Child’) AND DiscountPrice <10.00 Note the use of parentheses around the OR clause How does OR differ from AND? Page 550

67 Chapter 10: Databases67 The NOT operator can be used to specify a not-equal relationship –SELECT CDName FROM CompactDisks WHERE NOT(ArtistName = ‘Beyonce’) Sometimes NOT relationships are specified using a not-equal operator, like <> or !=, depending on the specifications of the query language –SELECT CDName FROM CompactDisks WHERE ArtistName <> ‘Beyonce’ How does NOT work in an SQL query? Page 550

68 Chapter 10: Databases68 You can change records in a database only if you have the rights to do so –UPDATE CompactDisks SET QtyInStock = QtyInStock – 1 WHERE CDName = ‘Dangerously in Love’ Updating Fields: Can I change the contents of a record? Page 551

69 Chapter 10: Databases69 SQL can perform a global update that changes the data in more than one record at a time It would be easier to change all of the records with a single command –UPDATE CompactDisks SET DiscountPrice = 9.95 WHERE ArtistName = ‘The Rolling Stones’ The UPDATE command means that you want to change the data in some or all of the records Is it possible to update a group of records? Page 551

70 Chapter 10: Databases70 Creating a relationship between tables is referred to as joining tables To take advantage of the relationship between two tables, you first have to join the tables The SQL JOIN command allows you to temporarily join and simultaneously access the data in more than one table Joining Tables: How is data retrieved from more than one table at a time? Page 552

71 Chapter 10: Databases71 How is data retrieved from more than one table at a time? Page 552

72 Chapter 10: Databases72 Very extensive and powerful language Can be used to –Manipulate data –Create databases, tables, and reports How extensive is SQL? Page 553

73 Chapter 10: Databases73 You should now be able to: –Define basic database terminology, such as fields, records, record types, and cardinality –Describe the characteristics of hierarchical, network, relational, and object-oriented databases –Explain the capabilities of various data management tools, such as commercial applications, word processing software, spreadsheet software, file management software, and database management Conclusion

74 Chapter 10: Databases74 –Describe various ways to provide access to databases via the Web –Explain how to design an effective relational database –Use your knowledge of SQL queries to describe how to add records, delete records, search for information, update fields, and simultaneously access data from multiple tables Conclusion


Download ppt "信息处理技术. Chapter 10: Databases2 111Chapter 4: File Management, Virus Protection, and Backup 1Chapter 1: Computer, Internet, Web, and E-Mail Basics."

Similar presentations


Ads by Google