TL; DR
In this case, as I understand it, I consider it a good idea to create a "global" location in the Location table. I definitely find it preferable to create a “global” flag in the article table.
"Is that a good idea ...?" this is not a question that we like to answer on SO. This is mainly a discussion point, not a Q&A, and we also have enough creativity in our community to come up with an example where “this” would be a good idea, regardless.
To your more specific question, how can I represent "all locations" in a database? It is a solution based on your business requirements.
Do you want “all locations” to include future locations?
If not, then probably you should only implement “all locations” as an assistant that selects all current locations in the database.
Do you expect to have a hierarchy of locations?
The location of the real world has a significant hierarchy:
- Global
- Multinational (continent, trade block)
- A country
- Administrative region (state, province, canton, etc.).
- Town
- The neighborhood
If you think you want to be able to choose, say, a country rather than a global one, then implementing a hierarchical view such as Damir is the best way to go. However, if you are not sure that you will ever have any grouping other than Global, the hierarchical data structure currently works too much. All you have to do is make sure your current implementation has a transition path to a possible future hierarchical representation.
Global as a pseudo-location
If you want future locations to be included in the global network and not need a hierarchical location structure, my instinct, based on many years of experience, would be to create a “Global” as a pseudo-location. That is, Global will be one of the places in the Location table, but this will be of particular importance. This is definitely a compromise, but it has the advantage of not changing the data structure to support Global, which means that all the special cases that Global creates are handled by excluding or including some locations in queries, rather than checking some flags somewhere. (Or, if you like flags, you can add the pseudo-location flag to the Location table.)
When using Global as a location, additions or deletions to the Location table are processed automatically. The query for all global articles is simple: the same as the query for all articles for any other location. Reporting on articles by location is also straightforward, and global articles appear in reports in exactly the same way as elsewhere. You can also imagine the difference between a “global” article (all current and future locations) and an “all locations” article (all current locations, but not in future locations).
Selecting all the articles that should be visible in a certain place is a little more complicated, now it is a check against the "Global" as well as this location, but at least it checks 2 values in one table and checks two different tables,
SELECT article_id FROM ArticleLocation WHERE location_id in (1, 5);
against
SELECT article_id FROM ArticleLocation WHERE location_id = 5 UNION SELECT id FROM Article WHERE is_global;