# MEBN-RM: A Mapping between Multi-Entity Bayesian Network and Relational Model
## 3 Mebn-Rm
### Relation Schema and MFrag Mapping  
In the previous section, we discussed the mapping between the elements of the relation schema and the elements of the MFrag. In this section, we discuss the mapping between a relation schema and a partial MFrag. It is called _RS-MFrag Mapping_. For ERS and RRS, we define the RS-MFrag mapping formally.  
**Definition 21** (**RS-MFrag Mapping**).: _An RS-MFrag Mapping is a mapping in which a relation schema, RS, is mapped to a partial MFrag, F, denoted by \(RS[\textbf{PK},\textbf{O}]\mapsto F[\textbf{C},\textbf{R}]\). Here, **C** denotes a set of context nodes (Definition 1), **R** denotes a set of resident nodes (Definition 1), **PK** = {\(K_{1}\), \(K_{2}\),..., \(K_{n}\)} is the PK, and **O** = {\(O_{1}\), \(O_{2}\),..., \(O_{m}\)}, where \(O_{i}\) is the i-th NF or NK attribute. The mapping satisfies the following conditions:_  
1. _If the_ RS _is an ERS and_ \(\mid\)_O_\(\mid\)_ _> _0, the_ PK_ _and_ \(O\) _of the_ ERS _are mapped to the_ \(C\) _and_ \(R\) _of the F, respectively. This is denoted by_ \(RS[\textbf{PK},\textbf{O}]\mapsto F[C1[IsA(K_{1},E(K_{1}))],\)__\(R_{1}[O_{1}(K_{1})],\)..., \(R_{m}[O_{m}(K_{1})]]\)_._
2. _If the_ RS _is an RRS and_ \(\mid\)_O_\(\mid\)_ _> _0, the_ PK_ _and_ \(O\) _of the_ _RRS_ _are mapped to the_ \(C\) _and_ \(R\) _of the F, respectively. This is denoted by_ \(RS[\textbf{PK},\textbf{O}]\mapsto F[C_{1}[IsA(K_{1},E(K_{1}))],\)..., \(C_{n}[IsA(K_{n},E(K_{n}))],\)__\(R_{1}[O_{1}(\textbf{PK})],\)..., \(R_{m}[O_{m}(\textbf{PK})]]\) _(E(X) is the entity type which the attribute X points to)._
3. _If the RS is an RRS and_ \(\mid\)_O_\(\mid\) _= _0, the_ PK_ _and_ _RRS_ _are mapped to the_ \(C\) _and_ \(R\) _of the F, respectively. This is denoted by_ \(RS[\textbf{PK}]\mapsto F[C_{1}[IsA(K_{1},E(K_{1}))],\)..., \(C_{n}[IsA(K_{n},E(K_{n}))],\)__\(R_{1}[RRS(\textbf{PK})]]\)_._  
Case (a) is that the RS is an ERS and it has at least one attribute which is not used for the PK. In this case, the single attribute K\({}_{1}\) in _PK_ is used to create the IsA context node, and each attribute in \(O\) is mapped to each resident node respectively using the function resident node mapping. For example, the relation Vehicle[_VehicleID/Vehicle_, VehicleClass] becomes a partial MFrag denoted by F[C[IsA(_Vehicleid_, VEHICLE), R[VehicleClass(_vehicleid_)]]. Case (b) is that the RS is an RRS and it has an attribute which is not used for the PK. Each attribute K\({}_{i}\) in _PK_ is used to create its respective IsA context node and each attribute in \(O\) is mapped to a resident node using the function resident node mapping. For example, the relation VehicleLocation[_LocatingVehicleID/Vehicle_, _LocatingTimeID/Time_, Location/Region] becomes a partial MFrag denoted by F[C[IsA(_locatingVehicleid_, VEHICLE), IsA(_locatingtimeid_, TIME), R[Location(_locatingvehicleid_, _locatingtimeid_)]]. Case (c) is that the RS is the RRS and has no attributes other than the PK. In this case, each attribute K\({}_{i}\) in _PK_ is used to create the IsA context node and the relation is mapped to a predicate resident node, RRS(K\({}_{1}\), K\({}_{2}\),..., K\({}_{n}\)), using the predicate resident node mapping. For example, the relation Follow [_FollowingVehicleID/Vehicle_, _LeadingVehicleID/Vehicle_] becomes a partial MFrag denoted by F[C[IsA(_followingvehicleid_, VEHICLE), IsA(_leadingvehicleid_, VEHICLE), R[Follow(_followingvehicleid_, _leadingvehicleid_)]].