Navigating with Path Expressions
Assume two tables are given as follows:
CREATE TABLE company (
companyID INT NOT NULL,
name VARCHAR NOT NULL,
street VARCHAR NOT NULL,
location VARCHAR NOT NULL,
president INT NOT NULL,
PRIMARY KEY ( companyID ),
FOREIGN KEY ( president ) REFERENCES employee ( emplno ) );
|
CREATE TABLE vehicle
vehicleID INT NOT NULL,
model VARCHAR NOT NULL,
manufacturer INT NOT NULL,
color VARCHAR NOT NULL,
PRIMARY KEY ( vehicleID ),
Foreign KEY ( manufacturer ) REFERENCES company ( companyID ) );
|
Determine the president of the company manufacturing the car with number 93:
SELECT c.president FROM vehicle v, company c
WHERE v.vehicleID = 93 AND v.manufacturer = c.companyID
|
company: [
name: STRING,
headoffice: address,
president: employee ]
|
|
|
vehicle: [
model: STRING,
manufacturer: company,
color: STRING ]
|
|
president( manufacturer( v ) ), or name( president( manufacturer( v ) )
|
OODB languages use expressions (path expressions) which allow evaluation from left to right:
v.manufacturer.president.name
|
The dot-notation renders bracketing superfluous.