'Helper method to find the component record ID for
a particular link of a particular master record
@param link: the link (S3Resource)
@param master_id: the ID of the master record
@param link_id: the ID of the link table entry'

def component_id(self, master_id, link_id):

    if ((self.parent is None) or (self.linked is None)):
        return None
    join = self.get_join()
    ltable = self.table
    mtable = self.parent.table
    ctable = self.linked.table
    query = (join & (ltable._id == link_id))
    if (master_id is not None):
        query &= (mtable._id == master_id)
    row = current.db(query).select(ctable._id, limitby=(0, 1)).first()
    if row:
        return row[ctable._id.name]
    else:
        return None
