I'm puzzled about the results for this task

Yep, it’s me, puzzled again :grinning:

For this exercise I need to list posts, but only for active users. My code doesn’t exactly match what’s being sought, but I believe that I have the code that the program expects, which hinges on the JOIN between the posts.user_id and users.id fields.

I sorted on username to bring the interesting posts to the top of my results. The top 6 results (posts) have an ID that exist in both tables, which is why they were found, but the username/email are both NULL. So, my question is whether the existence of an ID in the users table is enough to confirm that the user is active. Or, do the NULL values for both username and email suggest that the user is inactive, despite the existence of the ID?

Listing posts for active users only - but is an ID enough to say the user is active

That depends on the business logic of the database. Generally if you’re going to track inactive vs active users, and you wanted to keep track of old users, you’d have some boolean flag for whether they were active or not. In the absence of that it may be that membership in the main list is implicit “activene”-ness. But again it depends on the logic. You yourself could design it either way based on what makes the most sense for your needs.


That sounds reasonable. It didn’t slow me down, but I was curious to get someone’s opinion on how they’d handle that.