Recommended: MongoDB Atlas (free, no installation, works everywhere)
- Go to mongodb.com/cloud/atlas and click "Try Free"
- Create an account (use Google/GitHub for speed)
- Choose the FREE tier (M0 Sandbox) when prompted
- Select any cloud provider & region (pick one close to you)
- Create a database user - username and password (save these!)
- Add your IP address to the access list (click "Add My Current IP Address")
- Click "Connect" → "Connect your application" → Copy the connection string
- Replace
<password>in the connection string with your actual password - Install the driver in your project:
- Node.js:
npm install mongodb - Python:
pip install pymongo
- Node.js:
- Test it works - paste this in your code:
// Node.js const { MongoClient } = require('mongodb'); const client = new MongoClient('your-connection-string-here'); await client.connect(); console.log('Connected!');
That's it! You now have a working database. For more details, see the MongoDB Starter Kit.
Welcome to Hack@Brown's Database Starter Kit!
Choosing the right database is one of the most important decisions you'll make during a hackathon. The database you select will shape how you structure your data, how quickly you can iterate, and how well your application scales. This starter kit is designed to help you navigate that choice with confidence.
This repository provides comprehensive guides for three widely-used database systems: MongoDB, PostgreSQL, and MySQL. Each has its strengths and ideal use cases. Whether you're building a social platform with rapidly evolving data models, an e-commerce application requiring complex transactions, or a content management system with flexible schemas, one of these databases will fit your needs.
The guides below will walk you through setup, basic operations, and best practices for each database. Take a few minutes to review the comparison table and explore the starter kit that matches your project requirements.
This starter kit includes detailed documentation to help you get started:
-
setup_guide.md - Complete setup instructions for all three databases (MongoDB, PostgreSQL, and MySQL). Start here to get your database running with step-by-step instructions for both cloud and local setups.
-
walkthrough.md - A beginner-friendly, detailed walkthrough that explains each step in depth. Perfect if you're new to databases or want to understand what's happening behind the scenes.
Quick Start: Choose your database below, then follow the setup_guide.md for installation instructions.
| Feature | MongoDB | PostgreSQL | MySQL |
|---|---|---|---|
| Type | NoSQL (Document) | SQL (Relational) | SQL (Relational) |
| Best For | Flexible schemas, rapid prototyping, unstructured data | Complex queries, data integrity, ACID compliance | Web applications, read-heavy workloads |
| Schema Flexibility | Very flexible, schema-less | Structured, requires migrations | Structured, requires migrations |
| Query Language | MongoDB Query Language (MQL) | SQL with advanced features | Standard SQL |
| Scaling | Horizontal (sharding built-in) | Primarily vertical | Primarily vertical |
| Transactions | Supported (recent versions) | Full ACID compliance | Full ACID compliance |
| Joins | Limited ($lookup) | Excellent, complex joins | Good, standard joins |
| Data Model | Document-oriented (JSON-like) | Relational tables | Relational tables |
| Learning Curve | Moderate (data modeling approach) | Steeper (many features) | Gentle (familiar SQL) |
| Performance | Fast reads/writes, horizontal scaling | Excellent for complex queries | Excellent for read-heavy loads |
| Advanced Features | Aggregation pipeline, geospatial | JSON/JSONB, full-text search, window functions, CTEs | Good standard features |
| Community & Ecosystem | Large, JavaScript-focused | Very large, enterprise adoption | Huge, web development focus |
| Ideal Use Cases | User profiles, content management, catalogs | Analytics, complex relationships, financial data | Traditional web apps, content sites |
- MongoDB Starter Kit - Get started with flexible, document-based data storage
- PostgreSQL Starter Kit - Learn the most feature-rich open-source relational database
- MySQL Starter Kit - Set up the popular web application database
Start Here
|
├─ Is your data structure still evolving?
│ └─ YES → MongoDB
│ └─ NO → Continue
|
├─ Do you need complex queries with multiple joins?
│ └─ YES → PostgreSQL or MySQL
│ └─ NO → MongoDB
|
├─ Do you need advanced features (window functions, CTEs, etc.)?
│ └─ YES → PostgreSQL
│ └─ NO → Continue
|
├─ Are you building a traditional web application?
│ └─ YES → MySQL
│ └─ NO → Continue
|
├─ Do you need the most flexible schema?
│ └─ YES → MongoDB
│ └─ NO → PostgreSQL or MySQL
|
└─ When in doubt: Start with PostgreSQL (most versatile)
Recommendation: MongoDB or PostgreSQL
- MongoDB: Great for user profiles, posts, comments (document model)
- PostgreSQL: Better if you need complex social graphs and relationships
Recommendation: PostgreSQL or MySQL
- Both excellent for product catalogs, orders, inventory
- PostgreSQL if you need advanced search and filtering
- MySQL for simpler implementations
Recommendation: PostgreSQL or MongoDB
- PostgreSQL: Best for complex aggregations and analytics
- MongoDB: Good for rapidly changing metrics and flexible schema
Recommendation: MongoDB or MySQL
- MongoDB: Flexible content types, easy to add new fields
- MySQL: Traditional approach, proven pattern
Recommendation: Any (depends on data structure)
- MongoDB: Fast prototyping, flexible responses
- PostgreSQL: Complex business logic, strict data validation
- MySQL: Simple CRUD operations, standard API
Fastest Setup:
- MongoDB: MongoDB Atlas (free tier, no installation)
- PostgreSQL: Supabase (includes auth, storage)
- MySQL: PlanetScale (serverless, no configuration)
Local Docker Setup:
# MongoDB
docker run -d -p 27017:27017 --name mongo mongo:latest
# PostgreSQL
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=pass --name postgres postgres:15
# MySQL
docker run -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pass --name mysql mysql:8.0- Over-engineering: Start simple, add complexity only when needed
- No indexes: Add indexes on foreign keys and frequently queried fields
- Security: Never commit database credentials to git
- No backups: Export your data periodically during development
Database-Specific:
- MongoDB: Compass
- PostgreSQL: pgAdmin
- MySQL: MySQL Workbench
Keep your credentials safe! Use environment variables:
# .env file (add to .gitignore!)
DB_TYPE=mongodb # or postgresql, mysql
DB_HOST=localhost
DB_PORT=27017 # 5432 for postgres, 3306 for mysql
DB_NAME=hackatbrown
DB_USER=username
DB_PASSWORD=password
# For MongoDB Atlas, PostgreSQL cloud, etc.
DATABASE_URL=mongodb+srv://user:[email protected]/hackatbrownLoad in your app:
- Node.js:
npm install dotenvthenrequire('dotenv').config() - Python:
pip install python-dotenvthenfrom dotenv import load_dotenv - Java: Use Spring Boot's application.properties
Before building your full application, test your database:
// test-connection.js
const { MongoClient } = require('mongodb');
MongoClient.connect(process.env.DATABASE_URL)
.then(client => {
console.log('Connected to MongoDB');
client.close();
})
.catch(err => console.error('Connection failed:', err));// test-connection.js
const { Client } = require('pg'); // or 'mysql2'
const client = new Client({ connectionString: process.env.DATABASE_URL });
client.connect()
.then(() => {
console.log('Connected to database');
client.end();
})
.catch(err => console.error('Connection failed:', err));During the hackathon:
- Check the relevant starter pack markdown file
- Search Stack Overflow (most common issues are documented)
- Check official documentation
- Ask mentors or teammates
- Database-specific communities (Discord, Slack, Reddit)
Official Documentation: