Chapter 6 Flashcards
(49 cards)
What is SQL?
Structure Query Language
What is the standard for relational database management systems (RDBMS)?
Stucture Query Language (SQL)
What is a relational database management systems (RDBMS)?
A database management system that manages data as a collection of tables in which all relationship are represented by common values in related tables.
What is the purpose of SQL Standard?
- Specify syntax/semantics for data definition and manipulation
- Define data structures and basic operations
- Enable portability of database definition and application modules
- Specify minimal (level 1) and complete (level 2) standards
- Allow for later growth/enhancement to standard (referential integrity, transcation management, user-defined functions, extended join operations, national character sets)
What are the benefits of a standardized relational language?
- Reduced training costs
- Productivity
- Application portability
- Application longevity
- Reduced dependence on a single vendor
- Cross-system communication
What is a catalog?
- A set of schemas that constitute the description of a database
What is a Schema?
- The structure that contains descriptions of objects created by a user (base tables, views, constraints)
What is Data Definition Language (DDL)?
- Commands that define a database, including creating, altering, and dropping tables and establishing constraints
What is Data Manipulation Language (DML)?
- Commands that maintain and query a database
What is Data Control Language (DCL)?
- Commands that control a database, including administering privileges and committing data.
Simplified SQL environment example
How DDL, DML, and DCL affect the database development process. Visual
What are the major CREATE statements in Data Definition Language (DDL)?
- CREATE SCHEMA - defines a portion of the database owned by a particular user
- CREATE TABLE - defines a new table and its columns
- CREATE VIEW - defines a logical table from one or more tables or views
*Other CREATE statements*
CHARACTER SET, COLLATION, TRANSLATION, ASSERTION, DOMAIN
SQL Data Types - Visual
What are the steps in table creation?
- Identify data types for attributes
- Identify columns that can and cannot be null
- Identify columns that must be unique (candidate keys)
- Identify primary key - foreign key mates
- Determine default values
- Identify constraints on columns (domain specifications)
- Create the table and associated indexes
General Syntax for CREATE TABLE in DDL
What is a constraint that ensures that foreign key values of a table must match primary key values of a related table in 1:M relationships?
Referential Integrity
What do ALTER TABLE statements allow you to do?
To change column specifications:
Example:
ALTER TABLE table_name alter_table_action;
What are Table Actions?
Example of adding a new column with a dafault value
ALTER TABLE CUSTOMER_T
ADD COLUMN CustomerType VARCHAR2 (10) DEFAULT “Commercial”;
What command statement allows you to remove tables from your schema?
DROP TABLE
Example:
DROP TABLE CUSTOMER_T
What does an insert statement do?
Adds one or more rows to a table
Example:
INSERT INTO Customer_t VALUES
(001, ‘Contemporary Casuals’, ‘1355 S. Himes Blvd.’, ‘Gainsville’, ‘FL’,32601);
What is required when inserting a record that has some null attributes?
It requires identifying the fields that actually get data.
Example:
INSERT INTO Product_T (ProductID, ProductDescription, ProductFinish, ProductStandardPrice) VALUES (1, ‘End Table’, ‘Cherry’, 175, 8);
How do you insert from another table?
Example:
INSERT INTO CaCustomer_T
SELECT * FROM Customer_T
WHERE CustomerState = ‘CA’;