# MEBN-RM: A Mapping between Multi-Entity Bayesian Network and Relational Model
## 2 Background
### Relational Model
As another example, the relation schema of the relation _VehicleLocation_ is VehicleLocation[_LocatingVehicleID_:{v1, v2,...}, _LocatingTimeID_:{t1, t2,...}, Location:{r1, r1_1, r1_2,...}, where _LocatingVehicleID_, _LocatingTimeID_, and Location are attributes, with domains {v1, v2,...}, {t1, t2,...}, and {r1, r1_1, r1_2,...}, respectively. **Definition 6** (Key). : _A key of a relation schema is a set of one or more attributes that uniquely identify a row of the relation._  
**Definition 7** (Foreign Key). : _A foreign key, FK, of a relation schema, \(RS[A_{1}\), \(A_{2}\),..., \(A_{n}]\), is a subset of the attributes \(A_{1}\), \(A_{2}\),..., \(A_{n}\) that uniquely identifies a row of another relation._  
The relation _VehicleLocation_ of Figure 2 has two foreign keys (i.e., _LocatingVehicleID_/_Vehicle_ and _Location_/Region). Here, we use the \"/\" symbol followed by the relation name to indicate the relation to which the foreign key points, i.e., the foreign key _LocatingVehicleID_ refers to the relation _Vehicle_. A relation schema containing a foreign key is called a _target relation schema_ for the foreign key, while a relation schema which is referenced by the foreign key is called a _home relation schema_. For example, the relation schema _VehicleLocation_ is the target relation schema for the attribute _LocatingVehicleID_, while the relation schema _Vehicle_ is the home relation schema of the attribute. If the target and home relation schema are same, the foreign key and primary key are the same. In this case, the foreign key is called a _recursive foreign key_. Figure 2: Example of a Part of the Vehicle Identification RDB. **Definition 8** (**Primary Key**). : _A primary key, PK, of a relation schema RS[\(A_{1}\), \(A_{2}\),..., \(A_{n}\)] is a selected subset of the attributes \(A_{1}\), \(A_{2}\),..., \(A_{n}\) that uniquely identifies each tuple in the RS._  
The relation _VehicleLocation_ of Figure 2 has a PK composed of two attributes (i.e., _LocatingVehicleID/Vehicle_ and _LocatingTimeID_). Each tuple of the relation _VehicleLocation_ is uniquely identified by these two arguments. Please note that the attribute \(\text{Location}/\text{Region}\) in the relation is not used as the PK in the target relation, but it uniquely identifies each tuple in its home relation (i.e., the relation _Region_); therefore, it is a foreign key. This kind of key is called a _Non-Primary Foreign Key_. **Definition 9** (**Non-Primary Foreign Key**). : _A Non-Primary Foreign Key, NK, is a Foreign Key that is not used for a PK in a target relation._  
The attribute _ContainingRegion_ of the relation _Region_ of Figure 2 is another example of a non-primary foreign key since the home relation schema of the attribute _ContainingRegion_ is the relation _Region_ and it is not used for the PK of the target relation. **Definition 10** (**Non-Foreign-Key Attribute**). : _A Non-Foreign-Key Attribute, A, is an attribute which is not a foreign key._  
For example, in Figure 2, the _VehicleClass_ and _TerrainType_ attribute are non-foreign-key attributes since they are not foreign keys. **Definition 11** (**Original Primary Key**). : _An Original Primary Key, OK, is a PK that is not a foreign key in any target relation._  
A PK in one relation can be imported from the PK in another relation (i.e., foreign & primary key), while an original primary key is not originated from other PK in another relation. Examples for the original primary key can include _VehicleID_ in the relation _Vehicle_, _RegionID_ in the relation _Region_, and _LocatingTimeID_ in the relation _Location_. **Definition 12** (**Entity Relation Schema**). : _An entity relation schema, ERS, is a relation schema containing an original primary key that is not a foreign key and consists of exactly one attribute._  
In Figure 2, the _Vehicle_ and _Region_ relation schema are ERSs. An ERS represents a type of entity. An original primary key in an ERS is a field that holds an identifier that uniquely identifies an instance of the entity type.