SQL is a complete database language because it is both a data definition language (DDL) and a data manipulation language (DML). It can create a relational database, query it, and manipulate the data in the database.
One of the major operational advantages of a relational DBMS is that DDL statements (data definition statements such as creating a table) can be executed at any time. Earlier DBMSs often require halting the entire system to create a new table, views, and indexes.
The primary key is used to uniquely identify any record of a table and is typically the primary index by which a table is searched. A unique key also uniquely identifies a table, but it is only used for additional indexes to the table.
The three choices for the ON DELETE command are: restrict, cascade, set null. The restrict option does permit deletion of a primary key when there are matching foreign keys in a related table. The cascade option automaticallydeletes all rows in a related table with matching foreign keys. The set null option sets all corresponding rows to null. The following table shows the advantages and disadvantages of all three options.
| Option | Advantages | Disadvantages |
| RESTRICT | * referential integrity
* no accidental loss of records |
* update is cumbersome: each value of the corresponding foreign key must be deleted before one value of a primary key can be deleted |
| CASCADE | * referential integrity
* convenient update |
* all related records are lost, some data might be lost accidentally |
| SET NULL | * convenient update
* no accidental loss of records |
* referential integrity: possibly many useless records with null values as foreign key |
A view can be created for a variety of reasons:
CREATE UNIQUE INDEX firmname ON shr (shrfirm);
a. No, it would not make sense to create a unique index for PE since two companies might have the same PE.
An equijoin table contains two identical columns. If one of these two columns is dropped, the remaining table is called a natural join.
GRANT SELECT, INSERT ON nation TO hui-tze;
REVOKE ALL ON tablename FROM william;
(This has to be repeated for each table for which William has been granted privileges)
GRANT SELECT ON address TO chris WITH GRANT OPTION;
SELECT tname FROM system.syscatalog WHERE creator = 'CMS5432';
SELECT tname, cname FROM system.syscolumns WHERE COLTYPE ='SMALLINT';
SQL processes one table at a time while COBOL processes one record at a time. Thus, COBOL uses a loop to process each record of a table.
|
This page is part of the promotional and support material for Data Management (fifth edition) by Richard T. Watson |