A database SQL file for vet clinic visitors and pets
In this exercise we are implementing performance improvements on the sql databases
- postgreSQL
- SQL
- Pg Admin
To get a local copy up and running follow these simple example steps.
- Postgres
- PG Admin
- Terminal
Clone the project by typing in your terminal git clone https://github.com/SunnySparks/Vet-clinic-database.git
.
-
Change directory
cd
into the folder just created from the project. -
Open postgreSQL
-
Create the database using the
schema.sql
file -
Add the email column inside the owners table by typing
ALTER TABLE owners ADD COLUMN email VARCHAR(120);
-
Populate your database by adding the following commands
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;
andinsert into owners (full_name, email) select 'Owner ' || generate_series(1,2500000), 'owner_' || generate_series(1,2500000) || '@mail.com';
-
To check the performance, run
explain analyze SELECT COUNT(*) FROM visits where animal_id = 4;
explain analyze SELECT * FROM visits where vet_id = 2;
explain analyze SELECT * FROM owners where email = '[email protected]';
๐ค Sunny Dรญaz
- GitHub: @SunnySparks
- Twitter: @JosfranT6
- Instagram: @webdev.sunnydiaz
- Portfolio: sunnydiaz.com
- LinkedIn: LinkedIn
๐ค Rocio Martinez
- Github: @Rocio01
- Twitter: @rugiada8801
- Linkedin: zulma-rocio-martinez
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
Give a โญ๏ธ if you like this project!
- Use of SQL databases
- Improvement on database queries performance
This project is MIT licensed.