From 0b357a1e285ecce30f27ef477fbf5b63834fcdd7 Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 21 Jan 2020 19:26:40 -0700 Subject: Start notes for unit 5 --- doc/unit-5.md | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) (limited to 'doc') diff --git a/doc/unit-5.md b/doc/unit-5.md index 142015c..38df362 100644 --- a/doc/unit-5.md +++ b/doc/unit-5.md @@ -10,6 +10,118 @@ Read Chapter 6: Introduction to SQL * The SQL Environment * Defining a database in SQL +ANSI SQL was first published in 1986. +Updated in: + +* 1989 +* 1992 +* 1999 +* 2003 +* 2006 +* 2008 + +Concepts were first articulated in 1970 by E.F. Codds paper +"A Relational Model of Data for Large Shared Data Banks". + +IBM devs started to build System R which was to demo an +implementation of a relational model in a dbms. + +They used a language named "Sequel" which was renamed SQL. + +SQL/DS: the first relational DBMS. +DB2: introduced in 1983 + +Original purpose of SQL standard: + +1. specify syntax and semantics of SQL DDL and DML +2. define data structures and basic operations for designing, accessing, maintaining, controlling and protecting a SQL database. +3. portability between database definition and application modules between DBMS's. +4. Specify minimal and complete standards +5. Extension point for handling referential integrity, transaction management, user defined functions, join operators and character sets. + +A standard provides + +* Reduced training costs +* Productivity +* Application portability +* Application longevity +* Reduced dependence on a single vendor +* Cross system communication + +The SQL Environment + +SQL is used to: + +* create tables +* translate user requests +* maintain data dictionary and system catalog +* update and maintain the tables +* establish security +* carry out back and recovery procedures + + +> RDBMS: a database management system that manages data as a collection of tables in which all data relationships are represented by common values in related tables. + +Each database is contained in a catalog, which describes any object that is a part of the database. + +> Catalog: A set of schemas that, when put together, constitute a description of a database. + +> Schema: A structure that contains descriptions of objects created by a user, such as base tables, views and constraints as part of a database. + + +Each catalog must also contain an information schema. + +* tables +* views +* attributes +* privileges +* constraints +* domains + +SQL commands can be classified into three types: + +1. DDL: Data definition language +2. DML: Data manipulation language +3. DCL: Data control language + +> DDL: Commands used to define a database, including those for creating, altering and dropping tables and establishing constraints. +> DML: Commands used to maintain and query a database, including those for updating, inserting, modifying and querying data. +> DCL: Commands used to control a database, including those for administering privileges and committing (saving) data. + +Each DBMS has a defined list of data types that it can handle. + +* numeric +* string +* date/time +* graphic data +* spatial data +* image data + +Defining a database in SQL + +```sql +CREATE SCHEMA database_name; +AUTHORIZATION owner_user mokha; +``` + +To define a portion of a database that a particular user owns. + +```sql +CREATE SCHEMA +``` + +To define a new table and columns + +```sql +CREATE TABLE +``` + +To define a new view + +```sql +CREATE VIEW +``` + ## Section 2: SQL as a Data Manipulation Language (DML) Read Chapter 6: Introduction to SQL -- cgit v1.2.3