Skip to content

TheSpaceMan915/database-models

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

database-models

A curated set of assignment modules demonstrating database modeling across relational, document, and graph paradigms—aimed at students, educators, and developers.

Repository Branch Languages Languages Last Commit License

Table of Contents

Overview

This repository collects a progression of assignments focused on understanding and practicing data modeling techniques:

  • Relational modeling and operations (e.g., Select–Project–Join)
  • Document modeling with MongoDB
  • Graph modeling with Neo4j

JavaScript (if present) is primarily used for tooling, scripts, or small utilities to set up and interact with the databases. PLpgSQL may appear in relational assignments as stored procedures or functions to demonstrate server-side logic in PostgreSQL. The series is designed to start with fundamentals and build toward more advanced modeling and querying concepts.

Repository Structure

A high-level view of the repository:

database-models/
├─ .gitignore
└─ assignments/
   ├─ 01-spj/
   ├─ 02-data-modelling/
   ├─ 03-rsl-lp-db/
   ├─ 04-mongo-db/
   ├─ 05-neo4j-db-creator-app/
   └─ 06-assessment/
  • Root files:

  • Assignments:

    • 01-spj — Fundamentals of relational operations (Select, Project, Join).
    • 02-data-modelling — Conceptual/logical/physical modeling exercises.
    • 03-rsl-lp-db — Relational schema and query language practice (details if present).
    • 04-mongo-db — Document modeling with MongoDB (schemas, indexing, queries).
    • 05-neo4j-db-creator-app — Graph modeling and database generation with Neo4j.
    • 06-assessment — Capstone or assessment materials.

Explore the top-level assignments directory: assignments

Getting Started

Prerequisites

Install the tools relevant to the assignments you plan to run:

  • Node.js and npm (if JavaScript tooling is present)
  • PostgreSQL (for PLpgSQL or relational assignments, if applicable)
  • MongoDB Community Server (for document assignments)
  • Neo4j Desktop or Neo4j Server (for graph assignments)

Optional tools:

  • A package manager like pnpm or yarn (if a package.json exists)
  • psql CLI for PostgreSQL
  • mongosh or mongoimport for MongoDB
  • Neo4j Browser and APOC library (if needed)

Installation

Navigate to the specific assignment folder you want to work on. If a package.json exists:

# from the desired assignment folder
npm install
npm run start

Database setup suggestions (adjust per assignment):

  • PostgreSQL:
    • Create a local database:
      createdb db_models_dev
    • Run schema scripts and PLpgSQL functions (if present):
      psql db_models_dev -f ./schema.sql
      psql db_models_dev -f ./functions.sql
  • MongoDB:
    • Start local server and import seed data:
      mongod --dbpath /path/to/db
      # If seeds present:
      mongoimport --db db_models_doc --collection items --file ./seed/items.json --jsonArray
    • Run Node.js scripts (if applicable):
      node ./scripts/seed.js
  • Neo4j:
    • Create a database in Neo4j Desktop or set up a server database.
    • Install APOC (if needed) and then run the app/tooling (if present):
      # Example environment variables (if required)
      export NEO4J_URI=bolt://localhost:7687
      export NEO4J_USERNAME=neo4j
      export NEO4J_PASSWORD=your_password
      npm run start

Usage

  • Navigate to an assignment that matches your learning goals:
  • Read the README or instructions in each folder (if present) for assignment-specific steps.
  • Typical workflow:
    1. Check for README.md, package.json, .env.example, or scripts/ directories.
    2. Install dependencies and configure environment variables:
      cp .env.example .env # if present
      # edit .env with local credentials
    3. Run scripts or start the app:
      npm run start
      # or
      node index.js
  • Expected outputs:
    • SQL query results printed to terminal or persisted in tables.
    • MongoDB scripts inserting or querying documents.
    • Neo4j app generating nodes/relationships and enabling Cypher queries.

Educational Notes

Relational

  • Key concepts:
    • Normalization (1NF–3NF+), primary/foreign keys, referential integrity
    • Set-based operations: Select, Project, Join, Group By
    • Indexes for performance and query planning
  • Recommended resources:
    • PostgreSQL Docs: SQL Commands
    • PostgreSQL Docs: PL/pgSQL
    • Use EXPLAIN and EXPLAIN ANALYZE for performance insights

Document

  • Design strategies:
    • Schema versioning, validation, and indexing
    • Embedding vs referencing trade-offs
    • Optimizing for read/write patterns
  • Recommended resources:

Graph

  • Modeling patterns:
    • Nodes and relationships with well-defined labels and properties
    • Domain-driven modeling: meaningful relationship types
    • Writing Cypher for traversal and pattern matching
  • Recommended resources:

Contributing

Contributions are welcome! To propose changes:

  1. Open an issue describing your improvement or bug report.
  2. Fork the repo and create a feature branch.
  3. Make changes with clear commit messages and add/update assignment-level docs.
  4. Submit a pull request referencing the issue.

Guidelines:

  • Follow consistent folder naming (e.g., NN-name with zero-padded numbers).
  • If JavaScript tooling is present, consider adding linting (e.g., ESLint) and formatting (Prettier).
  • Include sample data and setup instructions for new assignments when applicable.

License

License: TBD
If a LICENSE file is later added, it will define usage terms for the repository.

Acknowledgments

  • Thanks to instructors, course materials, and the communities behind PostgreSQL, MongoDB, and Neo4j.
  • Tools and libraries used in assignments (if present) are credited within their respective folders.

Appendix

Troubleshooting

  • PostgreSQL:
    • Connection issues: verify pg_hba.conf and port (default 5432).
    • Permissions: ensure your role can create schemas/tables/functions.
  • MongoDB:
    • EACCES/permission errors: check your dbpath and user permissions.
    • Import errors: confirm JSON format and use --jsonArray when needed.
  • Neo4j:
    • Bolt connection failures: verify NEO4J_URI and credentials.
    • APOC not found: ensure APOC is installed and enabled in config.

Example Datasets

  • If sample datasets are provided, look for seed/ or data/ directories within each assignment.
  • Prefer small, well-indexed datasets for query performance exploration.

Performance Considerations

  • Use indexes thoughtfully (relational and document).
  • Profile queries:
    • PostgreSQL: EXPLAIN ANALYZE
    • MongoDB: db.collection.aggregate([...]) with $indexStats
    • Neo4j: PROFILE and EXPLAIN in Cypher

About

A curated set of assignments exploring data modelling across relational, document, and graph paradigms. It helps students and developers practice fundamentals like Select–Project–Join, design schemas for MongoDB, and build/visualize graph structures with Neo4j

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages