Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL lookup and reference table definitions

I need some clarification. What is a lookup table and what is a reference table in SQL?

I was under the impression that a lookup table is a table that has static data that hardly ever changes (e.g. a table that has all 50 states and their capitals) and a reference table is one that contains primary keys and links two other tables. In the example below, Table B would be a reference table. Can someone tell me what Table B is called?

Table A
CustomerID
CustomerName
CustomerAddress

Table B
CustomerID
OrderID

Table C
OrderID
OrderDate
like image 639
Halcyon Avatar asked Jan 12 '12 18:01

Halcyon


2 Answers

Table B is a Link Table or Junction Table.

Reference and Lookup tables can mean different things for different sources, and I am not aware of a strict definition to differentiate the two.

For me personally I normally use a reference to mean an long value stored out of the main table (like a StoreID), and lookup to mean a list of allowable values (enforced by a FK constraint) for a certain field.

like image 128
JNK Avatar answered Nov 03 '22 00:11

JNK


There is no hard-and-fast definition for those terms. It really comes down to whether or not the other person knows what you are talking about.

Among the people I work with table B would be called a "Mapping Table".

like image 23
Jonathan Allen Avatar answered Nov 03 '22 00:11

Jonathan Allen