Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCTION TO DATABASES CS 260 Database Systems.

Similar presentations


Presentation on theme: "INTRODUCTION TO DATABASES CS 260 Database Systems."— Presentation transcript:

1 INTRODUCTION TO DATABASES CS 260 Database Systems

2 Course Outline  SQL queries  DML Select (SELECT)  DDL (CREATE, ALTER, DROP)  DML Action (INSERT, UPDATE, DELETE)  User authentication  Data modeling and normalization  Transaction processing  Stored DBMS programs  Scaling and performance  Distributed databases

3 Why Study Database Systems?  Important  The back end of many important systems Web-based e-commerce (e.g. amazon.com, imdb.com) Scientific sites (e.g. protein sequences) Real-time systems (e.g. air-traffic control) Business systems (e.g. banking)  Good job experience  Many jobs require database systems experience  Oracle DBAs hired at >$80K, often make >$100K  A lot of data out there  Facebook – over 100 petabytes  Amazon – over 90 pb  Google processes over 20pb per day  AT&T (323 TB, 2010)  World Data Center for Climate (6+ PB, 2010)

4 Why Study Database Systems?  As it relates to UWEC courses  CS268 Use SQL and JDBC  CS355 & CS485 (SE I and II) Project(s) might use databases  Any CS course might use a database!

5 Overview  Data management  Database system architectures  Database vocabulary & history

6 Data Management  "Real" computer applications tend to have:  Large volumes of data  Different types of data  Data with complex relationships

7 “Old” Approach to Data Management  File-based  Decentralized  Each application has its own data files Data File 1 Application 1 Application 2 Data File 2

8 Problems with file based approach?  Duplicate data  Redundant data  Becomes inconsistent over time  Requires custom programs to create, update, and retrieve data from files  Transaction atomicity  Concurrent access issues  Security

9 DBMS Approach to Data Management  Data is viewed as a shared organizational resource  Centralized  All applications interact with a single centralized database Database Application 1 Application 2

10 What is a Database?  Components  Data files  Database Management System (DBMS) Data Files DBMS Application 1 Application 2 Database

11 What is the DBMS?  Set of programs that perform…  Basic data handling tasks Insert, Update, Delete, Retrieve  Creating atomic transactions  Enabling/disabling concurrency  Database administration tasks Creating users, creating objects, enforcing security, creating backups, …  Applications interact only with the DBMS  Never interact directly with the data files  Major players today:  Oracle, SQL Server, DB2, MySQL

12 Overview  Data management  Database system architectures  Database vocabulary & history

13 Database System Architectures  Single-tier  2-tier  N-tier

14 Single-Tier Databases  Personal computer-based  Applications and database run on the same local computer  Example: Access, Filemaker  What are the limitations? Database Applications Host Computer (microcomputer)

15 Single-Tier Databases  Mainframe-based (host)  Applications & database run on the same host computer  Mainly used in legacy systems Database Applications Host Computer Terminals Network

16 2-Tier (Client/Server)  DBMS runs on a server  Client applications run on the clients  Example: Oracle (server) + SQL Developer (client) Client Workstations Database Applications Database Applications Database Applications Database Database Server Network

17 N-Tier Database Systems  N-tier system places each service type on a different host Database Client Workstations (Browser) User Services User Services User Services Database Server Business Services Middle-tier Server(s) (Web server)

18 Sample Database (CANDY) CANDY_CUSTOMER CANDY_PURCHASE CANDY_CUST_TYPE CANDY_PRODUCT

19 Overview  Data management  Database system architectures  Database vocabulary & history

20 Basic Database Vocabulary  Field: column of similar data values  Record*: row of related fields  Table*: set of related rows PROD_ID PROD_DESCPROD_COSTPROD_PRICE 1Celestial Cashew Crunch7.45$ 10.00$ 2Unbrittle Peanut Paradise5.75$ 9.00$ 3Mystery Melange7.75$ 10.50$ 4Millionaire’s Macadamia Mix12.50$ 16.00$ 5Nuts Not Nachos6.25$ 9.50$ Mathematical terms for record and table: tuple and relation

21 Database History  All pre-1960’s systems used file-based data  First database: Apollo project  Goal: No duplicate data in multiple locations  Used a hierarchical structure  Created relationships using pointers Pointer: hardware address

22 Example Hierarchical Database Student ID Student LastName Student FirstName Student MI Pointers to Course Data* 5000NelsonAmberS 5001HernandezJosephP 5002MyersStephenR UNIVERSITY_STUDENT CourseIDCourse Name Course Title 100MIS 290Intro. to Database Applications 101MIS 304Fundamentals of Business Programming 102MIS 310Systems Analysis & Design UNIVERSITY_COURSE * Hex number referencing data’s physical location on hard drive

23 Problems with Hierarchical Databases  Relationships are all one-way; to go the other way, you must create a new set of pointers  Pointers are hardware-specific  VERY hard to move to new hardware  Applications must be custom-written  Usually in COBOL

24 Relational Databases  Circa 1972  E.J. Codd  “Normalizing” relations  Goal: No redundant data  Stores data in a tabular format  Creates relationships by sharing key fields

25 Key Fields  Primary key: field that uniquely identifies a record  Often abbreviated “PK” InstructorIDInstructor LastName Instructor FirstName 1BlackGreg 2McIntyreKaren 3SarinNaj UNIVERSITY_INSTRUCTOR Primary keys

26 Class Discussion  What is the primary key of each table in the CANDY database?  How can you tell if a field is a primary key?

27 Sample Database (CANDY) CANDY_CUSTOMER CANDY_PURCHASE CANDY_CUST_TYPE CANDY_PRODUCT

28 Special Types of Primary Keys  Composite PK: made by combining 2 or more fields to create a unique identifier  Consider the CANDY_PURCHASE table…  Surrogate PK: ID generated by the DBMS solely as a unique identifier (not done in above example, but likely in CANDY_CUSTOMER and CANDY_PRODUCT) Composite PK

29 Key Fields (continued)  Foreign key  Field that is a primary key in another table  Serves to create a relationship StudentIDStudent LastName Student FirstName StudentMIAdvisorID 5000NelsonAmberS1 5001HernandezJosephP1 5002MyersStephenR3 UNIVERSITY_STUDENT Foreign keys InstructorIDInstructor LastName Instructor FirstName 1BlackGreg 2McIntyreKaren 3SarinNaj UNIVERSITY_INSTRUCTOR Primary keys

30 Alternative to Foreign Keys  Repeat data values for every record  Problems  Takes extra space  Redundant data becomes inconsistent over time StudentIDStudent LastName Student FirstName StudentMIAdvisorLast Name AdvisorFirst Name 5000NelsonAmberSBlackGreg 5001HernandezJosephPBlackGregory 5002MyersStephenRSarinNaj UNIVERSITY_STUDENT

31 Class Discussion  What are the foreign keys in the CANDY database?  Does a table HAVE to have foreign keys?  How can you tell if a field is a foreign key?

32 Sample Database (CANDY) CANDY_CUSTOMER CANDY_PURCHASE CANDY_CUST_TYPE CANDY_PRODUCT

33 Rules for Relational Database Tables  Every record has to have a non-NULL (or “non- empty”) and unique PK value  Every FK value must be defined as a PK in its parent table


Download ppt "INTRODUCTION TO DATABASES CS 260 Database Systems."

Similar presentations


Ads by Google