Careeroza
Collection & field
Collections & Fields
Collection in MongoDB
A collection is a group of documents. It is similar to a table in SQL databases
- Stores multiple documents
- Does not require a fixed schema
- Each document can have different structure
users // collection name
Field in MongoDB
A field is a key-value pair inside a document.
It is similar to a column in SQL
{
name: "Rahul",
age: 25,
city: "Hyderabad"
}Relation Between Them
- Collection → contains multiple documents
- Document → contains multiple fields
Database
↓
Collection (like users)
↓
Documents
↓
Fields (name, age, etc.)