Java Reference
In-Depth Information
As shown in Figure 32.6, courseId is the foreign key in Enrollment that references the
primary key courseId in Course . Every courseId value must match a courseId value
in Course .
Enforcing Integrity Constraints
The database management system enforces integrity constraints and rejects operations that
would violate them. For example, if you attempt to insert the new record (“11115,” “CSCI,”
“2490,” “C++ Programming,” 0) into the Course table, it would fail because the credit hours
must be greater than 0 ; if you attempted to insert a record with the same primary key as an
existing record in the table, the DBMS would report an error and reject the operation; if you
attempted to delete a record from the Course table whose primary key value is referenced by
the records in the Enrollment table, the DBMS would reject this operation.
auto enforcement
Note
All relational database systems support primary key constraints and foreign key
constraints but not all database systems support domain constraints. In the Microsoft
Access database, for example, you cannot specify the constraint that numOfCredits
is greater than 0 and less than 5 .
32.1
What are superkeys, candidate keys, and primary keys?
Check
32.2
What is a foreign key?
Point
32.3
Can a relation have more than one primary key or foreign key?
32.4
Does a foreign key need to be a primary key in the same relation?
32.5
Does a foreign key need to have the same name as its referenced primary key?
32.6
Can a foreign key value be null?
32.3 SQL
Structured Query Language (SQL) is the language for defining tables and integrity
constraints, and for accessing and manipulating data.
Key
Point
SQL (pronounced “S-Q-L” or “sequel”) is the universal language for accessing relational
database systems. Application programs may allow users to access a database without directly
using SQL, but these applications themselves must use SQL to access the database. This
section introduces some basic SQL commands.
SQL
database language
Note
There are many relational database management systems. They share the common SQL
language but do not all support every feature of SQL. Some systems have their own
extensions to SQL. This section introduces standard SQL supported by all systems.
standard SQL
SQL can be used on MySQL, Oracle, Sybase, IBM DB2, IBM Informix, MS Access, or
any other relational database system. This chapter uses MySQL to demonstrate SQL and uses
MySQL, Oracle, and Access to demonstrate Java database programming. The Companion
Website contains the following supplements on how to install and use three popular databases:
MySQL, Oracle, and Access:
Supplement IV.B: Tutorial for MySQL
MySQL Tutorial
Supplement IV.C: Tutorial for Oracle
Oracle Tutorial
Supplement IV.D: Tutorial for Microsoft Access
Access Tutorial
 
 
 
Search WWH ::




Custom Search