Presentation is loading. Please wait.

Presentation is loading. Please wait.

SQL John Nowobilski. What is SQL? Structured Query Language Manages Data in Database Management Systems based on the Relational Model Developed in 1970s.

Similar presentations


Presentation on theme: "SQL John Nowobilski. What is SQL? Structured Query Language Manages Data in Database Management Systems based on the Relational Model Developed in 1970s."— Presentation transcript:

1 SQL John Nowobilski

2 What is SQL? Structured Query Language Manages Data in Database Management Systems based on the Relational Model Developed in 1970s by IBM

3 Relational Database Matches data by common characteristics within data set Based on relational algebra and relational calculus Also known as a schema

4 RDBMS Relational Database Management System DBMS where data and relationships among data are stored in tables Data can be accessed without changing forms of tables

5 Advanced Clothing Solutions

6 Queries Way to access information from the Database All data and relationships are stored in tables SQL: “SELECT - FROM - WHERE” statement format to access the relations/data stored in schema

7 Tables Name of the table is the object you are trying to represent Consist of a tuple of columns that contain information about that table OOP: member variables ≈ columns

8 Column Datatypes Each column has associated datatype Set of “primitive” types as in OOP INT, CHAR, VARCHAR, BOOL, FLOAT DATE, TIME, YEAR, BLOB

9 SELECT - FROM “SELECT” clause accesses columns from a selected table Access all columns, or specify which you want to access “FROM” clause determines which tables to access columns from

10 SELECT * FROM articles; SELECT stock, rating, price FROM inventory;

11 WHERE clause Adds constraints to returned results from queries Allows for relationships to be accessed between multiple tables “AND” clause adds more constraints to returned results

12 SELECT * FROM articles WHERE size =‘M’ AND gender =‘F’; SELECT price, type FROM articles, inventory WHERE articles.id = inventory.articleID;

13 DISTINCT clause Allows for distinct results from columns to be returned Avoids redundancy in results

14 SELECT DISTINCT description FROM articles WHERE gender = ‘M’ AND type = ‘shirt’;

15 CREATE TABLE Creates table in the database Specify column names in CREATE TABLE statement NOT NULL ensures column isn’t null when entries are inserted

16 CREATE TABLE articles( ‘id’ INT NOT NULL, ‘company_id’ INT NOT NULL, ‘type’ VARCHAR(45), ‘description’ VARCHAR(160), ‘size’ VARCHAR(5), ‘color’ VARCHAR(30), ‘gender’ VARCHAR(1));

17 INSERT Adds entry into a table in the database Can populate as many or as few columns as you want, as long as they’re not required for insertion

18 INSERT INTO articles(gender, type, color) VALUES (‘M’, ‘shirt’, ‘red’);

19 UPDATE Updates column values in a table Can update certain entries, or all entries in the table at once

20 UPDATE articles SET size=‘S’, color=‘blue’ WHERE Type=‘shirt’;

21 DELETE Removes entries from a table Similar to “SELECT-FROM-WHERE” format Use “DROP” to delete tables

22 DELETE FROM articles WHERE size=‘S’ AND color=‘blue’; DROP TABLE articles;

23 Thank you Sources: http://en.wikipedia.org/wiki/SQL http://en.wikipedia.org/wiki/Relational_database_mana gement_system http://en.wikipedia.org/wiki/Relational_database_mana gement_system http://www.w3schools.com/sql/sql_syntax.asp


Download ppt "SQL John Nowobilski. What is SQL? Structured Query Language Manages Data in Database Management Systems based on the Relational Model Developed in 1970s."

Similar presentations


Ads by Google