vet-clinic-db

Table of Contents

About Project

This project is built as a practice for optimizing search queries in a populated database. We start with a regular database, then fill it with data to slow down the query times, and then use optimization techniques to achieve faster query calls compared to the unoptimized ones. Using this project, you can replicate the database to see how you can also implement your own solutions to the problems, or see how your solution compares to ours.

The following are screenshot displaying the before and after results on analysing the SQL data.

Query ONE

explain analyze SELECT COUNT(*) FROM visits where animal_id = 4;

BEFORE

query1

AFTER

normalized-query1

Query TWO

explain analyze SELECT * FROM visits where vet_id = 2;

BEFORE

query2

AFTER

normalized-query2

Query THREE

explain analyze SELECT * FROM owners where email = 'owner_18327@mail.com';

BEFORE

query3

AFTER

normalized-query3

Built With

  • PostgreSQL

Prerequisites

  • Ensure you have PostgreSQL DBMS installed
sudo apt update && sudo apt install postgresql postgresql-contrib

Getting Started

  • Clone this repo https://github.com/enkog/vet-clinic-db

    git clone https://github.com/enkog/vet-clinic-db.git
  • Navigate to vet-clinic folder/directory

    cd vet-clinic
  • Create the vet_clinic database

  • If you need help working with Postgres follow this GUIDE

  • Creating Tables

psql vet_clinic < schema.sql
  • Add data to Tables
psql vet_clinic < data.sql
  • Run the Queries
psql vet_clinic < queries.sql

Contributing

Contributions, issues, and feature requests are welcome!

Feel free to check the issues page

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/newFeature)
  3. Commit your Changes (git commit -m 'Add some newFeature')
  4. Push to the Branch (git push -u origin feature/newFeature)
  5. Open a Pull Request

Authors

👤 Oguadinma Nkiruka Ngozika

👤 Lameck Otieno

Acknowledgements

  • Postgres ORG for the documentation and guides on getting started with PostgreSQL DBMS.

Show your support

Give a ⭐️ if you like this project!