liveBook · Manning

Foreign key

As explained in AI-Powered Search

A foreign key is a value or column in one table that references an entity or key in another table to link records.

A foreign key is a value or column in one table that references an entity or key in another table. Shared identifiers let joins combine related records into a composite record. For example, a company ID in a companies table can be referenced by company_id in an employees table. section 2.1.2

The same linking idea applies to search documents. Separate text, image, video, or audio documents can be related when they contain a shared term such as “Haystack.” Unstructured data can also support fuzzy foreign keys: different phrases, such as a full name and a first name, may resolve to the same entity before joining. section 2.1.3 section 2.1.3

Foreign-key relationships support several increasingly flexible forms:

  • Exact joins match a shared discrete value, commonly an ID field. section 2.1.2
  • Document joins match the same term across separate search records. section 2.1.3
  • Fuzzy joins resolve multiple representations to one entity before creating the relationship. section 2.1.3
Figure 2.3 Structured data in a typical database. Discrete values represent identifiers and enumerated values, continuous values represent data that falls within ranges, and foreign keys exist when the same value exists across two tables and can thus be used as a shared attribute that creates a relationship between corresponding rows from each table.
figure

Use the structured-data diagram to compare discrete identifiers, continuous values, and foreign-key relationships across table rows. section 2.1.2

Figure 2.5 Fuzzy foreign keys. In this example, the same entity is being referenced using different terms, and a join is occurring based upon multiple phrases resolving to the same entity.
figure

Use the fuzzy-key diagram to see how different phrases can resolve to the same entity and support a join. section 2.1.3

How AI-Powered Search covers it

How deep it goes
Defines exact and fuzzy relationships with table and document examples, but stops short of implementation code.
Examples
Uses employee-company tables, shared “Haystack” documents, and full-name versus first-name entity references.
What it assumes
Assumes basic awareness of database tables and records while explaining discrete values, joins, identifiers, and entity resolution.
What you can do after
Evaluate how shared identifiers or resolved entity references connect records across structured tables and search documents.
How it connects
Connects foreign keys to joins, relational data, unstructured data, entity resolution, fuzzy joins, and search engines.

Also explained in

Compare how 18 books explain foreign key →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI-Powered Search. The section links point to the parts of the book it draws on.