Skip to content

Repository files navigation

ride-registry

Relational NoSQL Queries

A multimodel database project that represents a taxi-ride scenario in both relational and document-oriented forms. The repository includes the Oracle schema, sample inserts, relational queries, MongoDB documents, and MongoDB query examples used to explore the same data in two different database styles.

Table of Contents

What This Project Does

ride-registry documents the same transportation dataset in two database paradigms:

The domain centers on ride records that link passengers, cars, travel details, and trip usage.

Why This Project Is Useful

This repository is useful if you want to:

  • Compare how the same business problem is modeled in Oracle and MongoDB.
  • Study normalization versus embedded document design.
  • Reuse the provided DDL, sample data, and queries for coursework or demos.
  • Trace how logical and conceptual models map to executable SQL and MongoDB examples.

Architecture Overview

The project is organized around one shared dataset and two persistence styles:

  • Relational side:
    • Carro stores vehicle data.
    • Passageiro stores passenger data.
    • Viagem stores trip data and references Carro.
    • Usa links passengers to trips.
  • MongoDB side:
    • A NoSQL collection stores each trip as a document.
    • Carro and Passageiro are embedded inside each trip document.

Execution pattern:

  1. Create the Oracle tables.
  2. Load the sample inserts.
  3. Run the sample relational queries.
  4. Inspect the MongoDB documents.
  5. Run the MongoDB query examples against the collection.

Data Model

Relational Model

The Oracle schema defines four tables:

Table Purpose
Carro Vehicle metadata such as plate, brand, model, year, color, and driver name.
Passageiro Passenger data such as CPF, name, email, phone, neighborhood, and payment method.
Viagem Trip facts such as distance, fare, departure neighborhood, destination city, extra fee, and trip type.
Usa Association table connecting passengers to trips.

Document Model

The MongoDB collection stores each trip as a single document with nested Carro and Passageiro objects. This makes the trip record self-contained and easier to query for embedded data such as passenger or vehicle fields.

Getting Started

Prerequisites

  • Oracle Database or an Oracle-compatible SQL tool.
  • MongoDB or a MongoDB shell / UI that can read JSON documents.
  • A text editor capable of opening the modeling files in this repository.

Run the Oracle scripts

From the repository root, execute the SQL files in this order:

  1. ORACLE_TABLES.sql
  2. ORACLE_INSERT.sql
  3. ORACLE_CONSULTAS.sql

Load the MongoDB data

Import the documents from MongoDB_COLLECTION_NoSQL.json into a collection named NoSQL, then run the queries from MongoDB_CONSULTAS_NoSQL.json.

Usage Examples

1) Find trips that start in Floresta

The relational version returns the car code for trips whose departure neighborhood is Floresta.

The MongoDB version filters documents by Bairro_Partida and projects Carro.Codigo.

2) Match passenger neighborhood with trip origin

The second query demonstrates a comparison between passenger and trip data:

  • Oracle joins Passageiro, Usa, and Viagem.
  • MongoDB uses $expr to compare Bairro_Partida with Passageiro.Bairro.

3) Sum kilometers by passenger

The third query aggregates total distance traveled per passenger in both models.

Project Structure

.
├── Conceitual.brM3
├── Lógico.brM3
├── MongoDB_COLLECTION_NoSQL.json
├── MongoDB_CONSULTAS_NoSQL.json
├── NAO_RELACIONAL.asta
├── ORACLE_CONSULTAS.sql
├── ORACLE_INSERT.sql
├── ORACLE_TABLES.sql
└── README.md

Where To Get Help

Maintainers

Maintainer:

About

Multi-model database architecture for a trip registration system, featuring Oracle SQL and MongoDB Atlas implementation. Includes schema design, data integrity enforcement, and complex cross-platform querying.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages