Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 22 Databases Numeric & Symbolic Computing (S&G, §§11.3–11.4)

Similar presentations


Presentation on theme: "Lecture 22 Databases Numeric & Symbolic Computing (S&G, §§11.3–11.4)"— Presentation transcript:

1 Lecture 22 Databases Numeric & Symbolic Computing (S&G, §§11.3–11.4)
1/12/2019 1:53 PM Lecture 22 Databases Numeric & Symbolic Computing (S&G, §§11.3–11.4) 1/12/2019 CS Lecture 22 CS 100

2 Read S&G ch. 12 (Computer Networks) for next week
1/12/2019 CS Lecture 22

3 Data Organization A database is a collection of related files
analogy: all the file cabinets in a business A file is a collection of related records analogy: all the folders in one drawer (holding, say, the personnel records) A record is composed of fields analogy: the folder for a particular employee, containing, for example their name, employment history, pay rate, insurance information, evaluations 1/12/2019 CS Lecture 22

4 Example File “Employee”
Field ID Name Age PayRate Hours Pay 86 Janet Kay 51 16.50 94 123 Francine Perreira 18 8.50 185 149 Fred Takasano 43 12.35 250 71 John Kay 53 17.80 245 165 Butch Honou 17 6.70 355.10 Record 1/12/2019 CS Lecture 22

5 How is this different from a spreadsheet?
Databases are typically oriented toward very large amounts of data think of IRS databases, Wal-Mart employee & inventory databases Therefore efficiency is critical: efficiency of data storage efficiency of retrieval The data in a database is usually static updated manually, not automatically 1/12/2019 CS Lecture 22

6 Relational Database Model
A file is viewed as a table Each table contains information about a number of instances of some entity an entity is a fundamental distinguishable object, such as “employee” Each instance of the entity is represented by a tuple e.g., the data for a particular employee Each tuple has a number of attributes which characterize the instance (e.g., a particular employee’s attributes) Primary key: attribute(s) that uniquely identify a tuple 1/12/2019 CS Lecture 22

7 A Table for the “Employee” Entity
Attribute Primary Key ID Name Age PayRate Hours Pay 86 Janet Kay 51 16.50 94 123 Francine Perreira 18 8.50 185 149 Fred Takasano 43 12.35 250 71 John Kay 53 17.80 245 165 Butch Honou 17 6.70 355.10 Tuple 1/12/2019 CS Lecture 22

8 Query Languages A query language allows users to:
retrieve information from a database relate information in different files in a database update information in a database perform statistical and other data processing operations on selected information SQL (Structured Query Language) a standard query language a textual language sometimes used behind a graphical “front end” 1/12/2019 CS Lecture 22

9 Example Query >SELECT ID, NAME, AGE, PAYRATE, HOURS, PAY
>FROM EMPLOYEE >WHERE ID = 123; 123 Francine Perreira 18 $ $ > 1/12/2019 CS Lecture 22

10 Example Query (2) >SELECT ID, NAME, AGE, PAYRATE, HOURS, PAY
>FROM EMPLOYEE >WHERE NAME = ’John Kay’; 71 John Kay 53 $ $ > 1/12/2019 CS Lecture 22

11 Example Query (3) >SELECT NAME, PAY >FROM EMPLOYEE
>WHERE NAME = ’John Kay’; John Kay $ > 1/12/2019 CS Lecture 22

12 Example Query (4) >SELECT * >FROM EMPLOYEE >ORDER BY PAYRATE;
ID Name Age PayRate Hours Pay 165 Butch Honou 17 $6.70 53 $355.10 123 Francine Perreira 18 $8.50 185 $ 149 Fred Takasano 43 $12.35 250 $ 86 Janet Kay 51 $16.50 94 $ 71 John Kay $17.80 245 $ 1/12/2019 CS Lecture 22

13 Example Query (5) >SELECT * >FROM EMPLOYEE
>WHERE AGE > 21; ID Name Age PayRate Hours Pay 86 Janet Kay 51 $16.50 94 $ 149 Fred Takasano 43 $12.35 250 $ 71 John Kay 53 $17.80 245 $ 1/12/2019 CS Lecture 22

14 Modifying Databases DELETE * FROM EMPLOYEE WHERE AGE < 21;
UPDATE EMPLOYEE SET PAYRATE = 8.75 WHERE ID = 123; INSERT INTO EMPLOYEE VALUES (456, ’Sandy Beech’, 13.25, 0, 0); 1/12/2019 CS Lecture 22

15 Another Table InsuredID PlanType DateIssued 86 A4 02/23/78 123 B2
Primary Key InsuredID PlanType DateIssued 86 A4 02/23/78 123 B2 12/03/91 149 A1 06/11/85 71 10/01/72 04/23/90 1/12/2019 CS Lecture 22

16 Foreign Key The “InsuredID” attribute is a foreign key because it is a primary key into a different table (EMPLOYEE) Foreign keys establish relationships between tables E.g., between the employee (with all his/her attributes) and the insurance plan (with all its attributes) 1/12/2019 CS Lecture 22

17 Example Query of Joined Tables
>SELECT EMPLOYEE.NAME, INSURANCE.PLANTYPE >FROM EMPLOYEE, INSURANCE >WHERE EMPLOYEE.NAME = ’Fred Takasano’ AND EMPLOYEE.ID = INSURANCE.INSUREDID; NAME PLANTYPE Fred Takasano A1 Fred Takasano B2 > 1/12/2019 CS Lecture 22

18 Computer Science Issues
SQL is a very high-level language nonprocedural problem-specific Performance in a major issue Consistency issues with simultaneous updates Distributed databases (files stored in many locations) access time & consistency problems 1/12/2019 CS Lecture 22

19 Numeric and Symbolic Computing
1/12/2019 CS Lecture 22

20 Lecture 22 1/12/2019 1:53 PM Numeric Computation Applications that make heavy use of real arithmetic Especially used in science, engineering, economics, statistics, animation The motivation for the first computers Still drives the development of supercomputers and parallel computers a teraflop machine performs at least 1012 (a trillion) floating-point operations per second 36 Tflops already achieved (Japan’s Earth Simulator, which cost $350–500M) Data from Washington Technology V.18 No.21 (02/09/04). 1/12/2019 CS Lecture 22 CS 100

21 Computer Science Issues
Performance: better algorithms accessing of data in memory hierarchies parallel computation data communication in networks Mathematical software libraries Accuracy and stability of numerical approximations 1/12/2019 CS Lecture 22

22 Symbolic Computing Manipulate mathematical formulas, equations, etc. much the way a mathematician would automate processes that are mechanical, tedious, and error-prone Examples: Macsyma, Mathematica, Maple, MatLab 1/12/2019 CS Lecture 22

23 Example: Simplification
Simplify[(x-1)^2 + (x+2) + (2x-3)^2 + x] x + 5x2 1/12/2019 CS Lecture 22

24 Example: Expansion Expand[(1 + x + 3y)^4]
1 + 4x + 6x2 + 4x3 + x4 + 12y + 36xy + 36x2y + 12x3y + 54y xy2 + 54x2y y3 +108xy3 + 81y4 1/12/2019 CS Lecture 22

25 Example: Solving Equations
Solve[ {2x + y == 11, 6x - 2y == 8}, {x, y}] {{x -> 3, y -> 5}} 1/12/2019 CS Lecture 22

26 Typical Expansion Rules
Lecture 22 1/12/2019 1:53 PM Typical Expansion Rules Hence, Expand[(n + 1)2] Expand[(n + 1)(n + 1)] Expand[(n + 1)n + (n + 1)1] Expand[nn + 1n + n1 + 11] Note need for simplification in result. 1/12/2019 CS Lecture 22 CS 100

27 Digression Recall our discussion of formalized mathematics, and the idea of reducing mathematics to the mechanical application of formal rules Formal rules: depend on the form of expressions, not their meaning Symbolic computation is an application of the idea of a calculus 1/12/2019 CS Lecture 22

28 Computer Science Issues
Symbolic computation systems are: very high-level languages problem-specific nonprocedural Depend on many algorithms, e.g.: pattern matching efficient management of complex data structures representing formulas Results should be presented in a form familiar and useful to the mathematically literate 1/12/2019 CS Lecture 22


Download ppt "Lecture 22 Databases Numeric & Symbolic Computing (S&G, §§11.3–11.4)"

Similar presentations


Ads by Google