     fileprivate struct Keys {
         
         static var email = "email"
-        static var marketName = "market_name"
+        static var market = "market"
         static var lowPrice = "low_price"
         static var highPrice = "high_price"
+        static var marketForeignKey = "name"
     }
 }
 

    required init(row: Row) throws {
        
        email = try row.get(NotificationRequest.Keys.email)
        market = try row.get(NotificationRequest.Keys.marketName)
        lowPrice = try row.get(NotificationRequest.Keys.lowPrice)
        highPrice = try row.get(NotificationRequest.Keys.highPrice)
    }
    
    init(json: JSON) throws {
        
        guard let name: String = try json.get(NotificationRequest.Keys.marketName) else { throw Abort.badRequest }
        
        self.market = try Market.findOr404(byName: name)
        self.email = try json.get(NotificationRequest.Keys.email)

            
            builder.id()
            builder.string(NotificationRequest.Keys.email)
            builder.string(NotificationRequest.Keys.market)
            builder.foreignKey(NotificationRequest.Keys.market, references: NotificationRequest.Keys.marketForeignKey, on: Market.self)
            builder.double(NotificationRequest.Keys.lowPrice, optional: true)
            builder.double(NotificationRequest.Keys.highPrice, optional: true)
        }
