Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


dylan kane
dylan kane
2,772 Points

What on earth is a schema???

I am making a web app with mongodb and all I hear when trying to learn about it and javascript is schema. What is this thing in which I apparently need?

3 Answers

Travis Bailey
Travis Bailey
13,675 Points

Schema is like the blueprint of your database. You plan out how you're data is stored, and how data will be retrieved. Schema design is a lot more complicated with SQL databases like MySQL, but you still need to do some planning with a NoSQL database like Mongo.

There's a good post here from Mongo that talks about schema design.

Steven Parker
Steven Parker
229,645 Points

Basically, a schema is a structure, plan, or pattern. In speaking of databases, the schema refers to the organization of the data into related tables (in the case of standard databases) or into collections in the case of NoSQL/Mongo databases.

So creating your schema means making the decisions on how you will organize your data to make it easy to store, find, and retrieve the parts as needed. In traditional databases, this planning needed to be done thoroughly and carefully to avoid problems later in the life of a project. With newer NoSQL databases it simplified considerably and is easier to change down the road. But there are many more possible choices for each situation. Either way, you still need to develop a basic concept to start with.

Ken Alger
Ken Alger
Treehouse Teacher


While MongoDB touts itself as schemaless, as others have said, there is much involved in designing a MongoDB schema that can greatly enhance or hinder your application's performance. So much so that MongoDB offers a training class in Advanced Schema Design that takes place over several days.

That being said, one of the important things to consider when designing your schema in MongoDB is how you plan on using the information you are storing. How big are you anticipating your collections and individual documents getting? Are you doing mostly reads from the data store, mostly reads to the data store? Do you have data that could/should be embedded in the documents or are document references a better choice?

I have found the documentation on the MongoDB site to be very helpful for much of these decisions, but it is still an "art form" to have great running database.

Post back if you have specific "how-to" questions. I'm sure there will be lots of help offered.

Happy coding,