Basic SQL - Summary
Chapter Outline
- SQL Data Definition and Data Types
- Specifying Constraints in SQL
- Basic Retrieval Queries in SQL
- INSERT, DELETE, and UPDATE Statements
- Additional Features of SQL
1. Introduction to SQL
- SQL is the standard language for relational databases.
- It originated from SEQUEL, based on tuple relational calculus.
- Designed for practical interaction with relational data.
2. SQL Data Definition & Data Types
- Terms: Table = Relation, Row = Tuple, Column = Attribute.
- CREATE is the main statement to define tables and schemas.
- Standards evolved through SQL-86 to SQL-3, with XML and OO features.
3. Schema & Catalog Concepts
- Schema: Logical container for tables, views, etc.
- CREATE SCHEMA defines a schema.
- Catalog: Collection of schemas.
4. CREATE TABLE
- Used to define attributes, types, and constraints.
Page 1
Basic SQL - Summary
- Base tables are stored; views are virtual.
5. Data Types
- Numeric: INTEGER, FLOAT, DOUBLE
- Strings: CHAR(n), VARCHAR(n)
- Others: BIT, BOOLEAN, DATE, TIME, TIMESTAMP, INTERVAL
- Domains improve schema clarity.
6. Constraints in SQL
- Key: PRIMARY KEY, UNIQUE
- Entity Integrity: No NULL in primary keys.
- Referential Integrity: FOREIGN KEY with ON DELETE/UPDATE options.
- Attribute: DEFAULT, NOT NULL, CHECK
7. Basic Retrieval Queries
- SELECT-FROM-WHERE is the main structure.
- Supports duplicates unless DISTINCT is used.
- Set operations: UNION, INTERSECT, EXCEPT.
8. Aliasing & Ambiguous Names
- Alias used to differentiate same table used more than once.
9. Special Clauses
- * selects all attributes.
- ORDER BY controls result sorting.
Page 2
Basic SQL - Summary
- LIKE and BETWEEN for filtering.
- Arithmetic expressions in SELECT.
10. Data Modification
- INSERT: Adds rows (single or bulk).
- DELETE: Removes rows conditionally.
- UPDATE: Modifies rows with SET and WHERE clauses.
11. Additional Features
- Complex queries, embedded SQL.
- Triggers, UDTs, XML, OLAP support.
- Transaction control and access privileges.
Summary
- SQL supports data definition, manipulation, and security.
- Includes commands for creating, querying, and updating tables.
Page 3