SQL Database Languages SQL is an example of a(declarative)language with interacts with a database management system(DBMS)in order to make data processing easier and faster It collects records into tables,or a collection of rows with a value for each column A row has a value for titude Longitude Name each column A column 38 122 Berkeley... has a name and a type 42 71 Cambridge 45 93 Minneapolis A table has columns and rows
SQL & Database Languages SQL is an example of a (declarative) language with interacts with a database management system (DBMS) in order to make data processing easier and faster It collects records into tables, or a collection of rows with a value for each column Latitude Longitude Name 38 122 Berkeley 42 71 Cambridge 45 93 Minneapolis A table has columns and rows A row has a value for each column A column has a name and a type
Tables in SQL CREATE TABLE cities AS SELECT 38 AS latitude,122 AS longitude,"Berkeley"AS name UNION SELECT 42, 71, "Cambridge" UNION SELECT 45, 93, "Minneapolis"; SELECT "west coast"AS region,name FROM cities WHERE longitude >115 UNION SELECT "other", name FROM cities WHERE longitude 115; Cities: Latitude Longitude Name Region Name 38 122 Berkeley west coast Berkeley 42 71 Cambridge other Minneapolis 45 93 Minneapolis other Cambridge
Tables in SQL CREATE TABLE cities AS SELECT 38 AS latitude, 122 AS longitude, "Berkeley" AS name UNION SELECT 42, 71, "Cambridge" UNION SELECT 45, 93, "Minneapolis"; Latitude Longitude Name 38 122 Berkeley 42 71 Cambridge 45 93 Minneapolis SELECT "west coast" AS region, name FROM cities WHERE longitude >= 115 UNION SELECT "other", name FROM cities WHERE longitude < 115; Cities: Region Name west coast Berkeley other Minneapolis other Cambridge
SQL Basics The SQL language varies across implementations but we will look at some shared concepts. A SELECT statement creates a new table,either from scratch or by taking information from an existing table .A CREATE TABLE statement gives a global name to a table. Lots of other statements exist:DELETE,INSERT,UPDATE etc... Most of the important action is in the SELECT statement. Full credit to John Today's theme: DeNero for the examples in today's lecture
SQL Basics The SQL language varies across implementations but we will look at some shared concepts. ● A SELECT statement creates a new table, either from scratch or by taking information from an existing table ● A CREATE TABLE statement gives a global name to a table. ● Lots of other statements exist: DELETE, INSERT, UPDATE etc… ● Most of the important action is in the SELECT statement. Today’s theme: Full credit to John DeNero for the examples in today’s lecture