开发者

Relationship between new user and existing record

I have an unusual design for users in my app开发者_C百科, and want to make sure I'm not overlooking something.

Users and Athletes are separate models in my app. When a User registers, they must affiliate themselves with one and only one Athlete. Conversely, an athlete should only belong to one user.

My users actually are athletes, however I need to differentiate between the two because I need to input race results for Athletes who may not be registered (yet, or ever) as Users. So I set up my relationship between Users and Athletes as a Has_one and Belongs_to, almost like a User/Profile relationship.

The analogy doesn't really work though because the Athlete record already exists in the database.

Do you see any inefficiencies here? Is there a more appropriate way to establish the relationship between Users and Athletes? Or is there something I'm overlooking that could simplify this particular problem? As always, thanks for any insight.


Could you not have one model, where an empty "username" field in the database means this is an Athlete who hasn't registered? It works like this in Admidio, a software used to manage clubs (for example sports clubs), where you also have members who have not yet registered but are needed in the database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜