This project is part of the Relational Database Certification from freeCodeCamp.
The goal was to create a Bash script that queries a PostgreSQL database to retrieve information about chemical elements.
- Search elements by:
- Atomic number
- Symbol
- Name
- Validates user input.
- Displays detailed information:
- Atomic number
- Name
- Symbol
- Type (metal, nonmetal, metalloid)
- Atomic mass
- Melting point (°C)
- Boiling point (°C)
- Bash scripting (user input and queries).
- PostgreSQL (database management and data storage).
- Gitpod (for running the PostgreSQL in a virtual machine).
The PostgreSQL database is named periodic_table and contains three tables:
| Column | Type | Description |
|---|---|---|
atomic_number |
INTEGER (PK) | Unique identifier of the element |
symbol |
VARCHAR(2) | Chemical symbol (e.g., H, He, O) |
name |
VARCHAR(40) | Full element name |
| Column | Type | Description |
|---|---|---|
atomic_number |
INTEGER | Foreign key referencing elements |
atomic_mass |
NUMERIC | Atomic mass (amu) |
melting_point_celsius |
NUMERIC | Melting point in Celsius |
boiling_point_celsius |
NUMERIC | Boiling point in Celsius |
type_id |
INTEGER | Foreign key referencing types |
| Column | Type | Description |
|---|---|---|
type_id |
SERIAL (PK) | Unique identifier of the type |
type |
VARCHAR | Category (metal, nonmetal, metalloid) |
$ ./element.sh H
The element with atomic number 1 is Hydrogen (H). It's a nonmetal, with a mass of 1.008 amu. Hydrogen has a melting point of -259.1 celsius and a boiling point of -252.9 celsius.