Database Reference
In-Depth Information
The result is shown in the table below.
EmployeeID LastName SupID SupLastName
1
Davolio
2
Fuller
2
Fuller
NULL
NULL
3
Leverling
2
Fuller
...
...
...
...
NULL
NULL
1
Davolio
NULL
NULL
3
Leverling
...
...
...
...
With respect to the left outer join shown above, the above table has, in
addition, tuples of the form (NULL, NULL, SupervID, SupLastName) ,which
correspond to employees who do not supervise any other employee.
SQL: A Query Language for Relational DBMSs
SQL (structured query language) is the most common language for creating,
manipulating, and retrieving data from relational DBMSs. SQL is composed
of several sublanguages. The data definition language (DDL) is used to
define the schema of a database. The data manipulation language (DML)
is used to query a database and to modify its content (i.e., to add, update,
and delete data in a database). In what follows, we present a summary of the
main features of SQL that we will use in this topic. For a detailed description,
we encourage the reader to check in the references provided at the end of this
chapter.
Below, we show the SQL DDL command for defining table Orders in the
relational schema of Fig. 2.4 . The basic DDL statement is CREATE TABLE ,
which creates a relation and defines the data types of the attributes, the
primary and foreign keys, and the constraints:
CREATE TABLE Orders (
OrderID INTEGER PRIMARY KEY,
CustomerID INTEGER NOT NULL,
EmployeeID INTEGER NOT NULL,
OrderDate DATE NOT NULL,
RequiredDate DATE NOT NULL,
ShippedDate DATE NOT NULL,
ShippedVia INTEGER NOT NULL,
Freight MONEY NOT NULL,
ShipName CHARACTER VARYING (50) NOT NULL,
ShipAddress CHARACTER VARYING (50) NOT NULL,
ShipCity CHARACTER VARYING (50) NOT NULL,
ShipRegion CHARACTER VARYING (50),
ShipPostalCode CHARACTER VARYING (30),
 
Search WWH ::




Custom Search