Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL, Data Storage Technologies, and Web-Data Integration Week 1.

Similar presentations


Presentation on theme: "SQL, Data Storage Technologies, and Web-Data Integration Week 1."— Presentation transcript:

1 SQL, Data Storage Technologies, and Web-Data Integration Week 1

2 Today’s Agenda Instructor Introduction Review Syllabus Student Introductions Introduction to Unix and Course Servers Introduction to Database Design –1 st Normal Form

3

4 Databases A database is anything that can store data –text file, spreadsheet, custom file, filing cabinet, library Typically, one uses the word database to mean a Database Management System (DBMS)

5 DBMS A DBMS handles the storage and retrieval of data for you, in a very efficient way It also provides persistence and access control. Example uses: –Airline reservation systems, banking systems, corporation records.

6 Relational DBMS Some of the more popular DBMS’s are Relational DBMS’s (RDBMS) –Oracle, IBM DB2, MySQL Allows the definition of relationships between separate pieces of data Structured Query Language (SQL) allows a standard way of communicating to a RDBMS

7 RDBMS Using and interacting with a RDBMS, specifically MySQL, will be the focus of this class. The first step towards using a RDBMS is designing your database

8 Database Design A good database starts with a good database design. This is typically done with a data model To start a data model, we need to list all the data we need to store.

9 Sources for a Data Model Design documents –Requirements –Functional Specifications –Screen shots –Technical Specifications Brainstorming User interviews Use cases

10 Data Model Example We want to build a database for a non- profit organization to track of donors, and their donations to each of the organization's divisions. Brainstorm a list that details some of the data we will need to store.

11 Example Data Model Donor Name Donor Address Donor Phone number Donor E-mail Donation Amount Donation Date Division Name

12 In Class Exercise Brainstorm a list of data for the following applications 1.Recipes 2.Dating Service 3.Bookstore 4.Surveys 5.Movie Collection

13 Example Data Model How do we store this data? Begin by creating some examples. Donor Name Donor Address Donor Phone # Donor Email Donation Amount Donation Date Prcessor Name Division Name Fred Smith 123 Bedrock 555- 1212 f@fred.com 100.0001/02/04MarthaMarketin g Beth Kirsh 104 Ballard 555- 1234 b@kirs h.com 250.0012/11/04JimChild- care, trips Erin Lovett 1580 Stone Ln 555- 5098 e@eri n.com 10.0009/07/04JimChild- care,trip s Fred Smith 123 Bedrock 555- 1212 f@fred.com 100.0002/02/04JimChild- care

14 Example Data Model Potential problems with one big table Repetitive data –Extra work for data entry –A lot of work for updating (what if Fred moves?) Donations to multiple divisions –Separated with commas? –Hard to search for? –How to update? –Limited number? –What if we want to know more about a division than its name?

15 Example Data Model One big table is insufficient, we need a better design. We can use a relational data model to create a better design –Entity-Relationship (ER) model

16 Entities A thing or object that we need to store information about Specifically, it must be a “thing” that has attributes and/or relationships to other “things” Example: Person is probably an entity. However, “first name” is probably not an entity. What are the entities in our data model?

17 Entity Attributes An attribute is a descriptive piece of information about an entity. Attributes might be any data type –numbers, character strings, dates, times, etc. An attribute can only describe a single entity What attributes do our Entities need?

18 ER Diagrams We can model our Entities and Attributes inside an ER Diagram.

19 Entities and Objects In programming, Objects tend to be focused on behaviors Entities are focused on attributes, which Objects tend to hide Both PHP & JavaScript support Objects, which we can use to model an Entity

20 PHP Objects <?php class Donor { var $name; var $address; var $email; var $phone; function make_donation($donation) { … } ?>

21 JavaScript Objects JSON: JavaScript Object Notation var donor = { name: “Fred”, address: “123 Bedrock”, phone: “555-1212”, email: “f@fred.com” };

22 JavaScript Objects function Donor(name) { this.name = name; this.address = “”; this.setAddress(address) { this.address = address; } this.make_donation(donation) { … }

23 Normalization Soon after the RDBMS was invented, the idea of database normalization was invented. Normalization helps to remove redundancy and create a scalable design There are numerous levels and types of normalization.

24 First Normal Form First Normal Form (1NF) occurs when all attributes are single valued. –No repeating or attributes with multiple values Examples: –A Movie entity with attributes actor1, actor2, actor3. –A Sundae entity with a toppings attributes Is our data model in 1NF?

25 Example Data Model Our “Division Name” is not in 1NF –Contains multiple values –Isn’t really an attribute of a Donation –Better suited as an attribute of a Division One solution is to make the attribute into a new entity –Create a Division entity, with a Division Name attribute

26 Example Data Model

27 In Class Exercise Create an Data Model in 1 st Normal Form for the following applications: 1.Recipes 2.Dating Service 3.Bookstore 4.Surveys 5.Movie Collection


Download ppt "SQL, Data Storage Technologies, and Web-Data Integration Week 1."

Similar presentations


Ads by Google