So i'm trying to set up and pre populate a database for later use when the actual application ships.

The issue i'm having is i'm not able to insert into the field which is creating the relationship the field is just empty. Screenshot below:

[![Screenshot should type field is empty](https://i.stack.imgur.com/iCBL1.jpg)](https://i.stack.imgur.com/iCBL1.jpg)
These are my data models

**The data model holding the info the type is the key to the other object**

```
class sourceRecentData: Object {

    // Name
    dynamic var sourceName: String = ""

    // Description
    dynamic var sourceDesc: String = ""

    // TypeID
    dynamic var type : sourceType?

    // Key
    dynamic var sourceKey: String = ""

    // Enabled
    dynamic var sourceEnabled: Bool = true

    // Unlocked
    dynamic var sourceUnlocked: Bool = false
}

```

**The id in this object links to the object above**

```
class sourceType: Object {

    // NewsType
    dynamic var typeOfNews: String = ""

}

```

**The method i'm using to perform the insert for now it's just dummy data**

```
func createTopDB() {

    let recentData = sourceRecentData()

    let realm = try! Realm()

    recentData.sourceName = "dfdfd"
    recentData.sourceDesc = "fdfd"
    recentData.sourceKey = "fdfdf"
    recentData.sourceEnabled = true
    recentData.sourceUnlocked = false
    recentData.type?.typeOfNews = "fdfdfd"

    try! realm.write({ () -> Void in
        realm.add(recentData)

    })
}

```