how many instances of o are there in:
a foreign key (made up of a particular column or combination of columns) relates the information in one table (the foreign table) to information in another (referenced or primary) table. for the foreign key relationship to be valid, the entries in the foreign key must correspond to the primary key values of a row in the referenced table. occasionally, some other unique column combination may be referenced instead of a primary key.
the sql anywhere sample database contains an employees table and a departments table. the primary key for the employees table is the employee id, and the primary key for the departments table is the department id. in the employees table, the department id is called a foreign key for the departments table because each department id in the employees table corresponds exactly to a department id in the departments table.
the foreign key relationship is a many-to-one relationship. several entries in the employees table have the same department id entry, but the department id is the primary key for the departments table, and so is unique. if a foreign key could reference a column in the departments table containing duplicate entries, or entries with a null value, there would be no way of knowing which row in the departments table is the appropriate reference. this is a mandatory foreign key.
suppose the database also contained an office table listing office locations. the employees table might have a foreign key for the office table that indicates which city the employees office is in. the database designer can choose to leave an office location unassigned at the time the employee is hired, for example, either because they havent been assigned to an office yet, or because they dont work out of an office. in this case, the foreign key can allow null values, and is optional.
user
There are one hundred and two "o"s.
assistant