Presentation is loading. Please wait.

Presentation is loading. Please wait.

Databases and SQL Databases SQL Rev 1.5

Similar presentations


Presentation on theme: "Databases and SQL Databases SQL Rev 1.5"— Presentation transcript:

1 Databases and SQL Databases SQL Rev 1.5
© Scott Miller, University of Victoria 5/14/2018

2 Introduction to Databases
What is a database? A collection of records Each record is composed of fields; each field is a related attribute of a record e.g. Name Address Rather Dashing 1 Thatched Roof Cottage, Peasantry Trogdor The Countryside © Scott Miller, University of Victoria 5/14/2018

3 History of Databases: First Attempt
Late 50s/Early 60s: Began as a flat file Completely redundant data Iterative search (search each record from start to finish) Archaic way of storing data; very inefficient © Scott Miller, University of Victoria 5/14/2018

4 Flat File Example Name Address Course Grade Mr. Eric Tachibana
123 Kensigton Chemistry 102 C+ Chinese 3 A 122 Kensigton Data Structures B English 101 Ms. Tonya Lippert 88 West 1st St. Psychology 101 Mrs. Tonya Ducovney 100 Capitol Ln. Psychology 102 Human Cultures European Governments © Scott Miller, University of Victoria 5/14/2018

5 History of Databases: Second Attempt – A Better Model
Late 60s: Hierarchical Model Adds efficiency, as it eliminates redundancy Uses pointers to navigate; Need to understand physical layout of database to navigate it Information spread across files Doesn’t support many:many relationships e.g. One class can have many student numbers related to it and one student number can have many classes related to it Still has redundancies Can’t add a child until parents are added © Scott Miller, University of Victoria 5/14/2018

6 Hierarchical Example ©2006 Scott Miller, University of Victoria
5/14/2018

7 History of Databases: Third Attempt – Fix Many:Many
1971: Network Model Same as Hierarchical Model, but uses extra pointers to allow many:many relationships © Scott Miller, University of Victoria 5/14/2018

8 Fourth Attempt - Currently in Databases…
1980s: Relational Model Developed in late 60s by E.F. Codd at IBM Too expensive (HW-wise) at the time Most common database style in practice currently; has many related off-shoots e.x. M$ Access, mySQL, Oracle, etc. Consist of Tables of information instead of files © Scott Miller, University of Victoria 5/14/2018

9 Relational Databases Properties:
Each row must be unique (through at least one key or index field) Generally, related items in different tables can reference this key and link the tables together. This can be done by using identical column names as well. Each column must have a unique name (each record must have different attributes) Sequence of rows and columns is insignificant While traversing up or a down a column, the values are of the same kind Are connected by queries in real-time. Are easy to understand layout and data (no pointers!) © Scott Miller, University of Victoria 5/14/2018

10 Relational Databases Most enforce zero redundancies
All data can easily be joined at runtime (create complex or simple queries as needed) Great for administrators as the structure of the database can be queried e.x. Table names, present query names, permissions, etc. Almost infinite ways of search If info is forgotten, you can use a different method of searching to find what you need © Scott Miller, University of Victoria 5/14/2018

11 How Do We Search RDBMS? Queries: SQL: Query Language
SQL puts together a view of the data MVC Analogy: Controller SQL Model DB, Tables, etc. View Output © Scott Miller, University of Victoria 5/14/2018

12 SQL “Simple” language Easy to learn for a scripter, page designer, etc. Very simple, but powerful commands Allows very customized views and data connections “universal” Each database has their own little glitches; same idea as “universality of JavaScript” – Enjoy! © Scott Miller, University of Victoria 5/14/2018

13 SQL “SELECT” Keywords SELECT: Pulls information from the database
Creates a view UPDATE: Updates information into a database Updates fields in an existing record DELETE: Removes information from a database Removes a record INSERT INTO: Adds new information into a database Creates a new record © Scott Miller, University of Victoria 5/14/2018

14 SQL Basic Syntax and Examples
All keywords are uppercase All lines end with a ; SELECT column_name(s) FROM table_name e.x. SELECT * FROM MyTable SELECT ThisField, ThatField FROM MyTable SELECT * FROM MyTable WHERE Attribute = something More Examples in M$ Access © Scott Miller, University of Victoria 5/14/2018

15 Reading for Next Class Finish Assignment 3 Finish Lab 5/6
Review for Exam NEXT CLASS: CASE STUDIES AND REVIEW © Scott Miller, University of Victoria 5/14/2018


Download ppt "Databases and SQL Databases SQL Rev 1.5"

Similar presentations


Ads by Google