Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meltrust/vet-clinic-database
https://github.com/meltrust/vet-clinic-database
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/meltrust/vet-clinic-database
- Owner: Meltrust
- License: mit
- Created: 2021-12-08T15:42:06.000Z (about 3 years ago)
- Default Branch: dev
- Last Pushed: 2021-12-09T02:10:54.000Z (about 3 years ago)
- Last Synced: 2024-10-18T06:52:36.721Z (3 months ago)
- Size: 396 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Vet clinic database
> A vet clinic database audited to improve its performance.
Vet clinic is a database that at first had performance problems when seeded with big amounts of data. Now it's lightning fast.
## Performance before-after when querying all visits where animal_id = 4
## Performance before-after when querying all visits where vet_id = 2
## Performance before-after when querying all owners by email
## Made with
- PostgreSQL
- VSCode## Future additions
- More optimizing
## Getting Started
To get a local copy up and running follow these simple example steps:
1. Under the repository name, click the Clone or download green button.
![clone](https://user-images.githubusercontent.com/53324035/73660989-4451aa80-4667-11ea-8a89-176f89d6548a.png)
2. Copy the URL given by clicking the clipboard button
3. Open a terminal window in your local machine and change the current directory to the one you want the clone directory to be made.
4. Type git clone and the paste the URL you previusly copied to the clipboard
5. Change the current directory to the newly created folder
6. PostgreSQL must be installed and running. Create the database `createdb vet-clinic` in your terminal, and access it through `psql vet-clinic`. Use the commands on the schema.sql file one by one to create the tables and data.sql to populate tables with the initial data.
7. Add the email column inside the owners table
```sql
ALTER TABLE owners ADD COLUMN email VARCHAR(120);
```
8. Insert data into your database with the following commands```sql
INSERT INTO visits (animal_id, vet_id, date_of_visit) SELECT * FROM (SELECT id FROM animals) animal_ids, (SELECT id FROM vets) vets_ids, generate_series('1980-01-01'::timestamp, '2021-01-01', '4 hours') visit_timestamp;insert into owners (full_name, email) select 'Owner ' || generate_series(1,2500000), 'owner_' || generate_series(1,2500000) || '@mail.com';
```
9. Auditing performance
```sql
explain analyze SELECT * FROM visits where vet_id = 2;explain analyze SELECT * FROM owners where email = '[email protected]';
explain analyze SELECT COUNT(*) FROM visits where animal_id = 4;
```
## Authors
👤 **Miguel Tapia**
- Github: [@meltrust](https://github.com/meltrust)
- Linkedin: [linkedin](https://www.linkedin.com/in/meltrust/)
- Or talk to me directly at: [email protected]👤 **Amal Hersi**
- GitHub: [Amal Hersi](https://github.com/Amalcxc)
- Twitter: [@Amalcx4](https://twitter.com/home?lang=en)
- LinkedIn: [Amal Hersi](https://www.linkedin.com/in/amal-hersi-a29583205/)## 🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check the [issues page](issues/).
## Show your support
Give a ⭐️ if you like this project!
## Acknowledgments
- Hat tip to anyone whose code was used
- Inspiration
- etc## 📝 License
This project is [MIT](lic.url) licensed.