# MEBN-RM: A Mapping between Multi-Entity Bayesian Network and Relational Model
## 3 Mebn-Rm  
Both MEBN and RM have their theoretical basis in FOL, and both represent entities in a domain and relationships among them. We would like to be able to use data stored in an RDB to learn the joint distribution represented by an MTheory. To do this, we need a mapping from elements of RM to elements of MEBN. MEBN-RM provides such a mapping. MEBN-RM contains four levels of mapping from elements of a relational database to elements of an MTheory. In the first level, an entity mapping between an ERS and an entity in MEBN is defined. In the second level, a resident node mapping is defined. In the third level, a relation and MFrag mapping is defined. In the fourth level, a relational database schema and MTheory mapping is defined. Before discussing these mappings, some ingredients and assumptions are discussed in this section. The following Listing 3 from the _Vehicle Identification_ RDB in Section 2 is used for an illustrative example through Section 3. In the example RDBS, there are four relations: _Vehicle_, _Region_, _VehicleLocation_, and _Follow_. The relation _Vehicle_ has two attributes: _VehicleID_ and _VehicleClass_. The relation _Region_ has three attributes: _RegionID_, _TerrainType_, and _ContainingRegion_. The relation _VehicleLocation_ has three attributes: _LocatingVehicleID_, _LocatingTimeID_, and _Location_. The relation _Follow_ has two attributes: _FollowingVehicleID_ and _LeadingVehicleID_. ```
1:VehicleIdentification[
2:VehicleID, VehicleClass],
3:Region[RegionID, TerrainType, ContainingRegion/Region],
4:VehicleLocation[LocatingVehicleID/Vehicle, LocatingTimeID, Location/Region],
5:Follow[FollowingVehicleID/Vehicle, LeadingVehicleID/Vehicle]
6]
```  
**Listing 3** Vehicle Identification. As we saw in Section 2, an attribute in a relation can be a _Primary key_ (PK), _Non-Foreign-Key Attribute_ (NF), or _Non-Primary Foreign Key_ (NK). For example, in the relation _Region_, the attribute _RegionID_ is PK, the attribute TerrainType is NF, and the attribute _ContainingRegion_ is NK. Because each of these types of attribute plays a different role in MEBN-RM, we distinguish them from each other. In Section 2, Definition 5 defined a relation schema as a set of pairs consisting of an attribute name and a domain (i.e., RS[A\({}_{1}\):D\({}_{1}\), A\({}_{2}\):D\({}_{2}\),..., A\({}_{n}\):D\({}_{n}\)], where A\({}_{i}\) is the \(i\)-th attribute name and D\({}_{i}\) is the domain for the attribute \(i\)). The attributes[A\({}_{1}\), A\({}_{2}\),..., A\({}_{n}\)] can be grouped into three disjoint and exhaustive subsets: PK, NF, and NK, where PK is the set of attributes in a primary key, NF is the set of non-foreign-key attributes, and NK is the set of attributes in a non-primary foreign key. A variety of relations can be formed in accordance with the following restrictions on the attributes in these subsets. A PK in a relation cannot be empty; however, an NF, NK, or both in a relation may be empty. Therefore, a relation can be one of four types: (1) RS[PK] denotes a relation schema containing only a primary key, (2) RS[PK, NF] denotes a relation schema containing only a primary key and non-foreign-key attributes, (3) RS[PK, NK] denotes a relation schema containing only a primary key and non-primary foreign key attributes, and (4) RS[PK, NF, NK] denotes a relation schema containing a primary key, non-foreign-key attributes, and non-primary foreign key attributes. We define the mapping between RM and MEBN for each of these four types of relation. We start by assuming that all relations in the RDB are in at least first normal form [52]. Therefore, no relation may contain multiple values in a row (and domain) of an attribute of the relation. To accord with the formalism of MEBN, we introduce a new kind of normalization for MEBN-RM, which we call _Entity-Relationship Normalization_. An MTheory developed from an RDB represents entities. We would like to derive these entities from the RDB. We can do this by defining an entity type in MEBN for each entity relation.