Limit number of associated records in one-to-many relationship

Let say I have a records in table A, that have a one-to-many relationship with records in table B. Is there a way to check/limit the max number of records in table B that can be associated with a record in table A? For example, let say we have a person table. A person can be associated with a widget table. We would like to limit the max number of widgets a person can have to say 7.