Learning Documentation
This project was developed as part of the FreeCodeCamp's Relational Database certification. The main goal was to create an interactive Bash
program that uses PostgreSQL
to manage customers and appointments for a salon.
This diagram provides a visual representation of the database structure, including tables and the relationships between them.
The project includes a Bash
script (script/appointment-script.sh
) that interacts with the PostgreSQL
database. Here's a brief overview of what I learned from this script:
-
Database Interaction: The script uses the
psql
command-line interface to interact with thePostgreSQL
database. This includes executingSQL
queries toretrieve
,insert
, andupdate
data in the database. -
User Interaction: The script prompts the user for input and uses this input to perform various operations. For example, it asks the user to select a service, provide their phone number, and specify a time for their appointment.
-
Data Validation: The script includes checks to validate the user's input. For example, it checks if the selected service ID is a number and if it exists in the database.
-
Data Manipulation: The script uses SQL queries to manipulate data in the database. For example, it inserts a new customer into the
customers
table if the provided phone number does not exist in the database. -
Shell Scripting: The script demonstrates various shell scripting concepts, such as defining functions, using conditional statements, and reading user input.
This project provided valuable experience in using Bash scripting to interact with a PostgreSQL database, validating user input, and manipulating data based on this input.
$ ./appointment-script.sh
~~~~~ MY SALON ~~~~~
Welcome to My Salon, how can I help you?
1) cut
2) color
3) perm
10
I could not find that service. What would you like today?
1) cut
2) color
3) perm
1
What's your phone number?
555-5555
I don't have a record for that phone number, what's your name?
Emanoel
What time would you like your cut, Emanoel?
10:30
I have put you down for a cut at 10:30, Emanoel.
$ ./appointment-script.sh
~~~~~ MY SALON ~~~~~
Welcome to My Salon, how can I help you?
1) cut
2) color
3) perm
2
What's your phone number?
555-555-5555
What time would you like your color, Emanoel?
11am
I have put you down for a color at 11am, Emanoel.