Download Candidate Key

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Microsoft Access wikipedia , lookup

Concurrency control wikipedia , lookup

Business intelligence wikipedia , lookup

SAP IQ wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Data vault modeling wikipedia , lookup

Database wikipedia , lookup

Versant Object Database wikipedia , lookup

Relational algebra wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Clusterpoint wikipedia , lookup

Open Database Connectivity wikipedia , lookup

SQL wikipedia , lookup

PL/SQL wikipedia , lookup

Database model wikipedia , lookup

Relational model wikipedia , lookup

Transcript
2.4 Concept of Key
Key is an attribute or group of attributes, which is used to identify a row
in a relation. Key can be broadly classified into (1) Superkey (2) Candidate
key, and (3) Primary key
Superkey
A superkey is a subset of attributes of an entity-set that uniquely identifies
the entities. Superkeys represent a constraint that prevents two entities from
ever having the same value for those attributes.
Candidate Key
Candidate key is a minimal superkey. A candidate key for a relation
schema is a minimal set of attributes whose values uniquely identify tuples in
the corresponding relation.
Primary Key
The primary key is a designated candidate key. It is to be noted that the
primary key should not be null.
Example:
Consider the employee relation, which is characterized by the attributes,
employee ID, employee name, employee age, employee experience,
employee salary, etc. In this employee relation:
1
Superkeys can be [employee ID, employee name], [employee ID],
[employee name], etc.
Candidate keys can be [employee ID], [employee name].
Primary key is [employee ID].
Note: If we declare a particular attribute as the primary key, then that
attribute value cannot be NULL. Also it has to be distinct.
Foreign Key
Foreign key is set of fields or attributes in one relation that is used to
“refer” to a tuple in another relation.
2.5 Introduction to SQL
IBM developed the original version of SQL, originally called Sequel, as
part of the System R project in the early 1970s. The Sequel language has
evolved since then, and its name has changed to SQL (Structured Query
Language). Many products now support the SQL language. SQL has clearly
established itself as the standard relational database language. In 1986, the
American National Standards Institute (ANSI) and the International
Organization for Standardization (ISO) published an SQL standard, called
SQL-86. ANSI published an extended standard for SQL, SQL-89, in 1989.
The next version of the standard was SQL-92 standard, followed by
SQL:1999, SQL:2003, SQL:2006, and most recently SQL:2008.
2
Although we refer to the SQL language as a “query language,” it can do
much more than just query a database. It can define the structure of the data,
modify data in the database, and specify security constraints.
SQL language can be divided into the following categories, as shown in
figure 1:
 Data Query Language (DQL) Statements that query the database but
do not alter any data or database objects. This category contains the
SELECT statement. Not all vendors make a distinction here; many lump
DQL into DML, as defined next.
 Data Manipulation Language (DML) Statements that modify data
stored in database objects (that is, tables). This category contains the
INSERT, UPDATE, and DELETES statements.
 Data Definition Language (DDL) Statements that create and modify
database objects. Whereas DML and DQL work with the data in the
database objects, DDL works with the database objects themselves. In
other words, DDL manages the data containers whereas DML manages
the data inside the containers. This category includes the CREATE,
ALTER, and DROP statements.
 Data Control Language (DCL) Statements that manage privileges that
database users have regarding the database and objects stored in it. This
category includes the GRANT and REVOKES statements.
3
(Figure 1) Categories of SQL Languages
4