Chapter 5 Database Processing “We Don’t Have a Way to Track the Data About the Videos.” • Falcon Security stores sequentially numbered digital video files in separated directories for each client. • Tracking down exact footage of when equipment stolen means searching hundreds of video files. • Need database to track video files. • MongoDB for tracking video files? Copyright © 2017 Pearson Education, Inc. 5-2 What Is the Purpose of a Database? • Organize and keep track of things. • Keep track of multiple themes. • General rule: – Single theme - store in a spreadsheet. – Multiple themes - use a database. • What's a theme? – Ex: student grades, student emails, student office visits. Copyright © 2017 Pearson Education, Inc. 5-3 A List of Student Grades Presented in a Spreadsheet – Single Theme Copyright © 2017 Pearson Education, Inc. 5-4 Student Data Form for a Database Application Copyright © 2017 Pearson Education, Inc. 5-5 Database Database: A collection of information that is organized and accessed according to the logical structure of the information Columns are also called fields Rows are also called records 5-6 What Is a Database? Copyright © 2017 Pearson Education, Inc. 5-7 Hierarchy of Data Elements Copyright © 2017 Pearson Education, Inc. 5-8 Components of a Database Copyright © 2017 Pearson Education, Inc. 5-9 Database Terms Relational databases • Relationships among tables are created by using foreign keys. Relation • Formal name for a table or the connection between tables 5-10 Example of Relationships Among Rows Copyright © 2017 Pearson Education, Inc. 5-11 Primary Keys Primary Key – A column or group of columns that identifies a unique row in a table. – Student Number is the key of the Student table. Given a value of Student Number, you can determine one and only one row in Student. Only one student has the number 1325. – Every table must have a key. – Email_Num is the key of Email Table. – VisitID is the key of Office_Visit Table. 5-12 Foreign Keys Foreign keys - These are keys of a different (foreign) table than the table in which they reside. - They are primary keys in another table 5-13 Sample of Access Metadata Copyright © 2017 Pearson Education, Inc. 5-14 Ethics Guide: Querying Inequality? • MaryAnn has a data mart. • Business professional majored in HR, now "expert" in SQL. • Uses SQL to do job faster and better. • Examined data, saw possible discriminatory pattern. • What would you do from categorical imperative and utilitarian perspectives? Copyright © 2017 Pearson Education, Inc. 5-15 Ethics Guide: Querying Inequality? (cont’d) • Queries could reveal all sorts of patterns and trends. – Be sure what answers you want before starting query. • How strongly do you feel about social and personal responsibility, considering your needs and those of your family? • How important is social responsibility posture of an employer to you? –Is that something to add to your criteria for a job search? Copyright © 2017 Pearson Education, Inc. 5-16 So What? Not What the Data Says . . . • Subjective: – Small, nonrandom sample. – Called four different sales reps who can’t get any prospects to bite. • Objective: – Same month historical data, seasonal data comparisons. • How to recognize and minimize bias? – Use non-routine cognitive skills. Copyright © 2017 Pearson Education, Inc. 5-17 What Is a Database Management System (DBMS)? • Program to create, process, administer a database. • Licensed from vendors –IBM, Microsoft, Oracle, and others. DB2, Access, SQL Server, Oracle Database. • Open source – MySQL: License-free for most applications. Copyright © 2017 Pearson Education, Inc. 5-18 Processing the Database DBMS Process Operations 1. Read 2. Insert 3. Modify 4. Delete data Copyright © 2017 Pearson Education, Inc. 5-19 Processing the Database • Structured Query Language - SQL (see-quell) – International standard – Used by nearly all DBMS SQL Example INSERT INTO Student ([Student Number], [Student Name], HW1, HW2, MidTerm) VALUES (1000, ‘Franklin, Benjamin’, 90, 95, 100); Copyright © 2017 Pearson Education, Inc. 5-20 Adding a New Column to a Table (in Access 2013) Copyright © 2017 Pearson Education, Inc. 5-21 Administering the Database • Set up security system, user accounts, passwords, permissions, limits for processing. • Limit user permissions. • Back up database, improve performance of database applications, remove unwanted data. Copyright © 2017 Pearson Education, Inc. 5-22 Summary of Database Administration Tasks Copyright © 2017 Pearson Education, Inc. 5-23 Summary of Database Administration Tasks (cont'd) Copyright © 2017 Pearson Education, Inc. 5-24 How Do Database Applications Make Databases More Useful? Forms Queries View data; insert new, update existing, delete existing data. Search using values provided by user. Reports Structured presentation of data using sorting, grouping, filtering, other operations. Application programs Provide security, data consistency, special purpose processing, e.g., handle out-of-stock situations. Copyright © 2017 Pearson Education, Inc. 5-25 How Do Database Applications Make Databases More Useful? (cont'd) Copyright © 2017 Pearson Education, Inc. 5-26 Example of a Student Report Copyright © 2017 Pearson Education, Inc. 5-27 Query Example Copyright © 2017 Pearson Education, Inc. 5-28 Browser Forms, Reports, Queries, and Applications Copyright © 2017 Pearson Education, Inc. 5-29 Account Creation Browser Form Copyright © 2017 Pearson Education, Inc. 5-30 Browser Report Copyright © 2017 Pearson Education, Inc. 5-31 Graphical Query: User Clicks on Video Icon to Find All Videos from that Location Copyright © 2017 Pearson Education, Inc. 5-32 Enterprise DBMS vs. Personal DBMS • Enterprise DBMS process large organizational and workgroup databases for 100s/1000s of users • Personal DBMS designed for smaller databases used by 1 to 100 users. 5-33 Multiuser Processing Problem 1.Andrea puts both in shopping baskets, but delays checking out. 1.Andrea reads pedal record showing balance of 2 pedals. 1 2 3 2. Jeffrey reads same record showing balance of 2 pedals. 1.Andrea proceeds to checkout. Someone will be disappointed. 4 5 4.Jeffrey puts both in shopping basket and checks out before Andrea. Copyright © 2017 Pearson Education, Inc. 5-34 How Are Data Models Used for Database Development? Copyright © 2017 Pearson Education, Inc. 5-35 What Is the Entity-Relationship Data Model? Entities • Something to track. – Order, customer, salesperson, item, volunteer, donation Attributes • Describe characteristics of entity. – OrderNumber, CustomerNumber, VolunteerName, PhoneNumber Identifier • Uniquely identifies one entity instance from other instances – Student_ID_Number Copyright © 2017 Pearson Education, Inc. 5-36 Student Data Model Entities Copyright © 2017 Pearson Education, Inc. 5-37 Example of Department, Adviser, and Student Entities and Relationships (cont'd) Copyright © 2017 Pearson Education, Inc. 5-38 Sample of Relationships―Version 1 Crow’s Feet 1:N One department may have many advisers, but an adviser may be in only one department N:M An Adviser may have many students, and one student may have many advisers Copyright © 2017 Pearson Education, Inc. 5-39 Sample of Relationships─Version 2 “Crow’s Foot” N:M A department has many advisors, and an advisor may advise for more than one depart 1:N A student has only one advisor, but an adviser may advise many students Copyright © 2017 Pearson Education, Inc. 5-40 Crow’s-Foot Diagram Version Maximum cardinality─maximum number of entities in a relationship. Vertical bar on a line means at least one entity required. Minimum cardinality—minimum number of entities in a relationship. Small oval means entity is optional; relationship need not have entity of that type. Copyright © 2017 Pearson Education, Inc. 5-41 How Is a Data Model Transformed into a Database Design? • Normalization – Converting poorly structured tables into two or more wellstructured tables. • Goal – Construct tables with single theme or entity. • Purpose – Minimize data integrity problems. Copyright © 2017 Pearson Education, Inc. 5-42 Database Design - Normalization Normalization is a foundation of database design. Representation of relationships will help you understand important design considerations. Normal forms – Dr. E.F. Codd • 1st Normal Form – eliminate repeating groups • 2nd Normal Form – 1st normal form and eliminate all partial key dependencies • 3rd Normal Form – 2nd normal form and eliminate all transitive dependencies 5-43 First Normal Form • Unnormalized • A table that contains repeating groups (a subset of rows that depend on the same key) • 1NF • Contains no repeating groups of data • Sample table • class and classTitle attributes repeat multiple times for some of the students • Repeat the rows for each repeating group of data • Create a combined key of studentId and class 5-44 First Normal Form (continued) Figure 14-11 Students table in 1NF • Atomic attributes – As small as possible, containing an undividable piece of data 5-45 Second Normal Form • Eliminate all partial key dependencies • No column should depend on only part of the key • Must be in 1NF • All nonkey attributes must be dependent on the entire primary key • Create multiple tables • Each nonkey attribute of each table is dependent on the entire primary key for the specific table within which the attribute occurs 5-46 Second Normal Form (continued) Figure 14-12 Students table in 2NF 5-47 Third Normal Form • The table must be in 2NF, and it has no transitive dependencies • Transitive dependency • The value of a nonkey attribute determines, or predicts, the value of another nonkey attribute • Example: zip code determines city and state • Remove the attributes that are determined by, or are functionally dependent on, the zip attribute 5-48 Third Normal Form (continued) Figure 14-13 The complete Students database Transforming Data Models into a Database Design Poorly structured Employee table 5-50 Data Integrity Problems • Data integrity problems. – Incorrect or inconsistent information. – Users lose confidence in information. – System gets a poor reputation. • Can only occur if data are duplicated. Copyright © 2017 Pearson Education, Inc. 5-51 Poorly Designed Employee Table Causes Data Integrity Problem Copyright © 2017 Pearson Education, Inc. 5-52 Two Normalized Tables Single Themes Copyright © 2017 Pearson Education, Inc. 5-53 Summary of Normalization Copyright © 2017 Pearson Education, Inc. 5-54 Representing 1:N Relationships Copyright © 2017 Pearson Education, Inc. 5-55 Representing an N:M Relationship: Strategy for Foreign Keys Copyright © 2017 Pearson Education, Inc. 5-56 Users’ Role in the Development of Databases • Final judges. • Thorough review of data model. – Entities must contain all the data users need to do their jobs. – Must accurately reflect their view of the business. • Take it seriously. • Devote time. Copyright © 2017 Pearson Education, Inc. 5-57 Data Aggregators Acxiom obtain data from public and private sources and store and process it in sophisticated ways. Use your grocery store club card, that data is sold to a data aggregator. Credit card data, credit data, public tax records, insurance records, product warrantee card data, voter registration data, and hundreds of other types of data are sold to aggregators. Using a combination of phone number, address, email address, name, and other partially identifying data, such companies can integrate that disparate data into an integrated, coherent whole to form detailed descriptions about companies, communities, zip codes, households, and individuals. 5-58 Data Aggregators Laws that limit the data that federal and other governmental agencies can acquire and store. Some legal safeguards on data maintained by credit bureaus and medical facilities. No such laws that limit data storage by most companies (nor are there laws that prohibit governmental agencies from buying results from companies like Acxiom). 5-59 How Can Falcon Security Benefit from a Database System? • Find videos by querying their characteristics. – “Which videos do we have of the Beresford Building in October 2014, shot from 3,000 feet or less?” • Choices 1. Store videos on a file server and keep metadata about each video in a relational database to query with SQL. 2. Use NoSQL MongoDB. Copyright © 2017 Pearson Education, Inc. 5-60 Falcon Security Chooses Option 1 • Use Access to store metadata. • Less risky: uses known technology. • Creates E-R diagram. • Decide to keep design simple at first. Copyright © 2017 Pearson Education, Inc. 5-61 2026? • Volume of database continues to grow. • Cheap, unlimited storage, greater processing speeds do in relational databases. • Security becomes more important. • Many NoSQL, NewSQL, and in-memory databases exist in commerce. Copyright © 2017 Pearson Education, Inc. 5-62 ACID Transactions • Atomic, Consistent, Isolated, Durable transactions. • Critical to traditional commercial applications. • New Internet applications (Twitter) don’t need ACID. Copyright © 2017 Pearson Education, Inc. 5-63 New Categories of DBMS 1. NoSQL DBMS (NotRelational DBMS) • Supports very high transaction rates, processing relatively simple data structures, • Replicated on many servers in the cloud, without ACID transaction support. • MongoDB, Cassandra, Bigtable, and Dynamo. Copyright © 2017 Pearson Education, Inc. 5-64 New Categories of DBMS (cont’d) 2. NewSQL DBMS • Process very high levels of transactions, like NoSQL DBMS, but provide ACID support. • May or may not support relational model. • Current hotbed of development. 3. In-memory DBMS using SQL extension • SAP HANA, Tableau. • High volume ACID transaction support with complex relational query processing. Copyright © 2017 Pearson Education, Inc. 5-65 2026? (cont'd) • Keep abreast of developments. • Watch from investor’s perspective. • New opportunities and career paths will develop around these new DBMS products. • Separate yourself from the competition when it comes to job interviews. Copyright © 2017 Pearson Education, Inc. 5-66 Security Guide: Theft by SQL Injection • Common way of stealing data from corporations. • Done by people outside of host nation to avoid prosecution. • Highly organized and well-funded. – Criminal syndicates, nation states, or political hacktivists. – Mandiant report “APT1: Exposing One of China’s Cyber Espionage Units” • Attempting SQL injection could result in your arrest. Copyright © 2017 Pearson Education, Inc. 5-67 Security Guide: Theft by SQL Injection (cont'd) Copyright © 2017 Pearson Education, Inc. 5-68 Security Guide: Theft by SQL Injection (cont'd) 1. Retailers suffer two times as many SQL injection attacks as other industries. 2. Most Web applications receive four or more Web attack campaigns per month, and others are constantly under attack (176 out of 180 days). 3. One Web site received 94,057 SQL injection attack requests in one day. Copyright © 2017 Pearson Education, Inc. 5-69 Guide: Immanuel Kant, Data Modeler • Perception of reality based on our perceptive apparatus. • Brain processes perceptions into something meaningful. • Human’s model what appears to be. • Users determine if a data model fits their perception of reality. Copyright © 2017 Pearson Education, Inc. 5-70 Active Review Q1: What is the purpose of a database? Q2: What is a database? Q3: What is a database management system (DBMS)? Q4: How do database applications make databases more useful? Q5: How are data models used for database development? Q6: How is a data model transformed into a database design? Q7: How can Falcon Security benefit from a database system? Q8: 2026? Copyright © 2017 Pearson Education, Inc. 5-71 Case Study 5: Dean's Piano Database • Certified piano tuner and technician repairing and restoring pianos for many years. • Clown entertainer at children’s parties. Copyright © 2017 Pearson Education, Inc. 5-72 Pianos in Storage Copyright © 2017 Pearson Education, Inc. 5-73 Columns in the Piano Table Copyright © 2017 Pearson Education, Inc. 5-74 Query Design and Result Copyright © 2017 Pearson Education, Inc. 5-75 Piano Sound Quality by Building Copyright © 2017 Pearson Education, Inc. 5-76 Copyright © 2017 Pearson Education, Inc.
© Copyright 2026 Paperzz