Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Build a Social Network with Flask How to Win Friends Relationship Model

Why are relationship columns named "from_user" and "to_user" ( instead of "user" and "follower")?

What is the convention or reason behind naming the relationship table columns "from_user" and "to_user"?

I had a bit trouble understanding how the joins work, until i renamed the fields to "user" and "follower" - with a stopgap of names "user_id" and "follower_id".

This code seems much easier to understand for me:

    def following(self):
        """The users that we are following"""
        return (
            User.select()   # Select all users
                .join(Relationship, on=Relationship.user)  # that are in relationship table via "users" field
                .where(Relationship.follower == self)  # where the relationship "follower" field contains "current user"
        )

Also the stopgap version: That also has the redundant User.id == Relationship.user_id parameter in the join clause which might be helpful with little bit of SQL knowledge:

    def following(self):
        """The users that we are following"""
        return (
            User.select()   # Select all users
                .join(Relationship, on=User.id == Relationship.user_id)  # join by user.id = relationship.user_id 
                .where(Relationship.follower_id == self)  # and follower_id = currentuser.id 
        )

Are there any cases where from_user and to_user make more sense? Or does it just seem to make more sense to me because i have seen similar naming before?