Fuzzy definition of namespace on the lecture

I found topic about namespaces a little bit fuzzy. In video there is a statement “In MongoDB, a database serves as a namespace for a collections.” In quiz the question “Each database and collection combination define a namespace” must be checked as true.

So, what is namespace? Database or combination of database and collection?

I had the same question.
The Oxford (computing) definition of the word “namespace” is:

a class of elements (e.g. addresses, file locations, etc.) in which each element has a name unique to that class, although it may be shared with elements in other classes.

which means that the concept of a “namespace” is essentially about what names are available at a certain level, so at the databases level, you can’t have two databases with the same name & at the collections level (within a specific database), you can’t have two collections with the same name. You can have two collections with the same name only & only if they exist within different databases. With that in mind, the combination of a database & a collection is indeed a class of elements in which each element has a name unique to that class. Hope that helps :slight_smile:

The question at issue is: “databaseName.collectionName” defines a namespace, true or false. Given the information provided so far in the course, the answer might be either, because if n is a namespace of elements of type m, then n.m is a namespace of elements of type k, if and only if the elements of type k happen to have names that are unique within the set of n.m, and this is not necessarily true. For example, if n is a lower case letter, and d is a decimal digit, then n is a namespace for a set of 10 or fewer elements named by the digits. However, there could be members of the set named by n.d that have the same name, making n.d not a namespace.

For, making the definition of namespace more precise, a namespace is a set in which each member has a name different from the name of every other member in the set. And the set defined by databaseName.collectionName is the set of documents in the collection, so it while it seems very likely true that databaseName.collectionName defines a namespace: the namespace of documents in the collection, this is true only if every document has a unique name or some other unique identifier. While this many be expected to be true in any well-designed identifier metamodel, where dot notations always in practice are used in such a way it is namespaces all the way down, counterexamples are possible.

However, the lesson refers to nothing about this database.collection namespace of documents. The lesson only tells us that a database is a namespace of collections. That is the only namespace mentioned. Which means that every collection in the database has a unique name within the database, and nothing more can be inferred.

Therefore, the question asks about something that has not been mentioned in the lesson, and that can’t even be inferred until one knows something more about unique identifiers for documents withing collection, as this is used in Mongo. Therefore, it is a faulty question, and I believe the more careful and knowledgeable about computer science people in the class will have answered it most correctly (saying it is false). So, it is a shame to have a poor question so early in the course, and I would say that careful and knowledgeable thinkers should not accept the course answer as true, but instead only remember the answer that is expected, so they can get it right on a test. A question formulated to reflect what was in the lesson would simply say: a database is a namespace for collections.