An open API service indexing awesome lists of open source software.

https://github.com/luigirazum/pawclinic-db

PawClinic is a relational database project based on a real-life example which creates the data structure for a vet clinic. It starts with one table, and step by step, you will create a complete database. Apart from building data structure, it challenges you with tasks that require SQL queries to answer specific questions. Created with PostgreSQL.
https://github.com/luigirazum/pawclinic-db

Last synced: 2 months ago
JSON representation

PawClinic is a relational database project based on a real-life example which creates the data structure for a vet clinic. It starts with one table, and step by step, you will create a complete database. Apart from building data structure, it challenges you with tasks that require SQL queries to answer specific questions. Created with PostgreSQL.

Awesome Lists containing this project

README

          

logo

### Paw Clinic
is a relational database based on a real-life example which creates the data structure for a vet clinic.

# 📗 Table of Contents

- [🐾 Paw Clinic](#about-project)
- [🛠 Built With](#built-with)
- [Tech Stack](#tech-stack)
- [Key Features](#key-features)
- [💻 Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Setup](#setup)
- [Run](#run)
- [Usage](#usage)
- [👥 Authors](#authors)
- [🔭 Future Features](#future-features)
- [🤝 Contributing](#contributing)
- [⭐️ Show your support](#support)
- [🙏 Acknowledgements](#acknowledgements)
- [📝 License](#license)


# 🐾 Paw Clinic

**Paw Clinic** is a relational database based on a real-life example which creates the data structure for a vet clinic. It starts with one table, and step by step, you will create a complete database with data about:
- animals
- animals' owners
- clinic employees
- visits

Apart from building data structure, it challenges you with tasks that require SQL queries to answer specific questions.

- ## 📈 Entity Relationship Diagram
ERD was made with [**draw**SQL](https://drawsql.app/).



## 🛠 Built With

- ### Tech Stack

- ### Key Features

#### 1️⃣ Create `animals` table.


- Create Database `vet_clinic`.
- Add Table `animals`.
- Add demo Data to `animals` table.
- Use of SQL queries to consult data.



#### 2️⃣ Query and update `animals` table.

- Modify `animals` table.
- Add more dummy Data to 'animals' table.
- Use transactions to update and delete records.
- Use `ROLLBACK` and `SAVEPOINT` to restore the database to a previous state.
- Use aggregate functions and `GROUP BY` to answer analytical questions.



#### 3️⃣ Query multiple tables.

- Use primary key & foreign key mechanism for joining tables.
- Add new `owners` and `species` tables and,
- Add foreign key columns to your existing `animals` table to model one-to-many relationships.
- Insert data to `owners` and `species` tables.
- Query multiple tables.
- Afterward, use `JOIN` to query the data.
- Prepare complex queries that answer analytical questions.
- What animals belong to Melody Pond?
- List of all animals that are pokemon (their type is Pokemon).
- List all owners and their animals, remember to include those that don't own any animal.
- How many animals are there per species?
- List all Digimon owned by Jennifer Orwell.
- List all animals owned by Dean Winchester that haven't tried to escape.
- Who owns the most animals?

#### 4️⃣ Add many-to-many `JOIN` tables.

- Create a table named `vets`.
- Create a "join table" called `specializations` to handle a **many-to-many** relationship between the tables `species` and `vets`.
- Create a "join table" called `visits` to handle a **many-to-many** relationship between the tables `animals` and `vets`.
- Insert data for `vets`.
- Insert data for `specialties`.
- Insert data for `visits`.
- Write more complex queries to use them to answer questions.
- Who was the last animal seen by William Tatcher?
- How many different animals did Stephanie Mendez see?
- List all vets and their specialties, including vets with no specialties.
- List all animals that visited Stephanie Mendez between April 1st and August 30th, 2020.
- What animal has the most visits to vets?
- Who was Maisy Smith's first visit?
- Details for most recent visit: animal information, vet information, and date of visit.
- How many visits were with a vet that did not specialize in that animal's species?
- What specialty should Maisy Smith consider getting? Look for the species she gets the most.



#### 5️⃣ Add ERD (Entity Relationship Diagram).

- Create ERD on [**draw**SQL](https://drawsql.app/).
- Export the ERD to `png` image.
- Convert `png` to `svg` image.
- Upload the ERD image to this repo.
- Add the ERD image to this `README`.

(back to top)

## 💻 Getting Started

To get a local copy of this project up and running, follow these steps.

- ### Prerequisites

- In order to run this project locally you need `git` installed. Please got to [Getting Started - Installing Git guide](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and follow the steps described for your system to install `git`.
- Also you must have `PostgreSQL` installed, you can follow the [PostgreSQL Tutorial](https://www.postgresqltutorial.com/) and follow the steps for your computer OS.

- ### Setup
Clone this repository to your desired folder:
```sh
cd my-folder
git clone git@github.com:luigirazum/pawclinic-db.git
cd pawclinic-db
```
- ### Run
Start your `PostgreSQL` CLI:
```sh
psql postgres
```
`PostgreSQL` will show the `prompt`:
```postgresql
postgres=#
```
Now you can start typing `SQL` sentences. Happy querying!✌️
- ### Usage
This repository includes files with plain SQL that can be used to recreate a database:
- Use [schema.sql](./schema.sql) to create all tables.
```sql
CREATE DATABASE vet_clinic;
```
```sql
CREATE TABLE animals (
id INT GENERATED ALWAYS AS IDENTITY,
name VARCHAR(50),
date_of_birth DATE,
escape_attempts INT,
neutered BOOLEAN,
weight_kg DECIMAL,
PRIMARY KEY(id)
);
```
- Use [data.sql](./data.sql) to populate tables with sample data.
```sql
INSERT INTO animals(name, date_of_birth, escape_attempts, neutered, weight_kg)
VALUES ('Agumon', '02/03/2020', 0, true, 10.23);
```
- Check [queries.sql](./queries.sql) for examples of queries that can be run on a newly created database.
```sql
SELECT * from animals WHERE name LIKE '%mon';
```
⚠️ _*Important note: this file might include queries that make changes in the database (e.g., remove records). Use them responsibly!*_

(back to top)

## 👥 Author(s)

👨‍💻 **Luis Zubia**

(back to top)

## 🔭 Future Features

- Add more dummy data to test the database.
- Add sample queries to show how the database works.
- Add the Entity Relationship Diagram (ERD).

(back to top)

## 🤝 Contributing

Contributions, issues, typos, and feature requests are welcome!

Feel free to check the [issues page](../../issues/).

(back to top)

## ⭐️ Show your support

If you like this project, your support giving a ⭐ will be highly appreciated.

(back to top)

## 🙏 Acknowledgments

- 🐾 I would like to thank for all those pets that inspired me to name this project.

(back to top)

## 📝 License

This project is [MIT](./LICENSE) licensed.

(back to top)