{"id":27012908,"url":"https://github.com/gappeah/fcc-periodic_table_db","last_synced_at":"2025-06-25T09:33:58.226Z","repository":{"id":284539549,"uuid":"850649237","full_name":"gappeah/fcc-periodic_table_db","owner":"gappeah","description":"This project is part of the FreeCodeCamp Relational Database certification. The objective was to build a database that stores information about the elements in the periodic table and create a Bash script that interacts with this database to retrieve and display data in a user-friendly format.","archived":false,"fork":false,"pushed_at":"2025-03-26T11:27:20.000Z","size":165,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T12:18:23.284Z","etag":null,"topics":["bash","bash-script","bash-scripting","git","postgresql","postgresql-database","shell","sql"],"latest_commit_sha":null,"homepage":"","language":"SQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gappeah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-01T11:47:52.000Z","updated_at":"2025-03-26T11:27:24.000Z","dependencies_parsed_at":"2025-03-26T12:41:26.694Z","dependency_job_id":null,"html_url":"https://github.com/gappeah/fcc-periodic_table_db","commit_stats":null,"previous_names":["gappeah/fcc-periodic_table_db"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gappeah/fcc-periodic_table_db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gappeah%2Ffcc-periodic_table_db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gappeah%2Ffcc-periodic_table_db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gappeah%2Ffcc-periodic_table_db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gappeah%2Ffcc-periodic_table_db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gappeah","download_url":"https://codeload.github.com/gappeah/fcc-periodic_table_db/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gappeah%2Ffcc-periodic_table_db/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261844813,"owners_count":23218440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","bash-script","bash-scripting","git","postgresql","postgresql-database","shell","sql"],"created_at":"2025-04-04T12:18:25.764Z","updated_at":"2025-06-25T09:33:58.184Z","avatar_url":"https://github.com/gappeah.png","language":"SQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Periodic Table Database\n\nThis project is part of the FreeCodeCamp Relational Database certification. The objective was to build a database that stores information about the elements in the periodic table and create a Bash script that interacts with this database to retrieve and display data in a user-friendly format.\n\n## Project Structure\n\n- **Database**: The database is managed using PostgreSQL.\n- **Script**: A Bash script (`element.sh`) was created to interact with the database.\n\n### Files\n\n- `periodic_table.sql`: Contains SQL commands to create the database, including the necessary tables and relationships to store the elements, their properties, and types.\n- `element.sh`: A Bash script to retrieve information from the database based on user input (either an element's name, symbol, or atomic number).\n\n## Database Schema\n\nThe database consists of the following tables:\n![diagram-export-02-09-2024-14_30_54](https://github.com/user-attachments/assets/748dca59-8ced-47b3-992a-89074b2fb8e5)\n\n\n### `elements` Table\n\n| Column Name    | Data Type | Constraints      |\n| -------------- | --------- | ---------------- |\n| `atomic_number`| INTEGER   | PRIMARY KEY      |\n| `symbol`       | VARCHAR   | UNIQUE, NOT NULL |\n| `name`         | VARCHAR   | UNIQUE, NOT NULL |\n\n### `properties` Table\n\n| Column Name            | Data Type | Constraints                            |\n| ---------------------- | --------- | -------------------------------------- |\n| `atomic_number`        | INTEGER   | REFERENCES `elements(atomic_number)`   |\n| `atomic_mass`          | DECIMAL   | NOT NULL                               |\n| `melting_point_celsius`| DECIMAL   | NOT NULL                               |\n| `boiling_point_celsius`| DECIMAL   | NOT NULL                               |\n| `type_id`              | INTEGER   | REFERENCES `types(type_id)`, NOT NULL  |\n\n### `types` Table\n\n| Column Name | Data Type | Constraints  |\n| ----------- | --------- | ------------ |\n| `type_id`   | INTEGER   | PRIMARY KEY  |\n| `type`      | VARCHAR   | NOT NULL     |\n\n## Usage\n\n### Prerequisites\n\n- **PostgreSQL**: Ensure PostgreSQL is installed and running on your machine. Connect to the database using:\n\n  ```bash\n  psql --username=freecodecamp --dbname=periodic_table\n  ```\n\n- **Database Setup**: The database should be created and populated using the provided `periodic_table.sql` file.\n\n### Running the Script\n\nThe `element.sh` script can be run from the command line:\n\n```bash\n./element.sh \u003celement_name_or_atomic_number\u003e\n```\n\n- **Argument**: The script accepts either the name, symbol, or atomic number of an element.\n- **Output**: The script returns detailed information about the element in a formatted sentence. For example:\n\n  ```bash\n  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.\n  ```\n\n### Error Handling\n\n- If the element is not found, the script will output: `I could not find that element in the database.`\n- If no argument is provided, the script will output: `Please provide an element as an argument.`\n\n## Project Completion\n\n### Fixing the Database\n\nThe database initially had a few issues that were resolved:\n\n1. The `weight` column was renamed to `atomic_mass`.\n2. The `melting_point` and `boiling_point` columns were renamed to `melting_point_celsius` and `boiling_point_celsius`, respectively.\n3. The `melting_point_celsius` and `boiling_point_celsius` columns were updated to not accept null values.\n4. The `UNIQUE` constraint was added to the `symbol` and `name` columns in the `elements` table.\n5. The `atomic_number` column in the `properties` table was set as a foreign key referencing the `atomic_number` column in the `elements` table.\n6. A `types` table was created to store the types of elements and was linked to the `properties` table.\n\n### Git Repository\n\nThe project folder was initialized as a Git repository:\n\n```bash\ngit init\n```\n\nThe repository was ensured to have a `main` branch with at least five commits, using conventional prefixes like `fix:`, `feat:`, `refactor:`, etc.\n\n### Bash Script\n\nThe `element.sh` script was developed to query and display information from the database. Example command:\n\n```bash\n./element.sh Hydrogen\n```\n\nExpected output:\n\n```bash\nThe 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.\n```\n\n### Notes\n\n- To back up the database:\n\n  ```bash\n  pg_dump -cC --inserts -U freecodecamp periodic_table \u003e periodic_table.sql\n  ```\n\n- To restore the database:\n\n  ```bash\n  psql -U postgres \u003c periodic_table.sql\n  ```\n\n## Installation\n\n1. Clone this repository.\n2. Set up the database:\n   - Log in to PostgreSQL:\n     ```bash\n     psql --username=freecodecamp --dbname=postgres\n     ```\n   - Run the SQL commands in `periodic_table.sql` to create and populate the database:\n     ```sql\n     \\i periodic_table.sql\n     ```\n3. Make sure the `element.sh` script has execution permissions:\n   ```bash\n   chmod +x element.sh\n   ```\n\n4. Run the script as described above.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgappeah%2Ffcc-periodic_table_db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgappeah%2Ffcc-periodic_table_db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgappeah%2Ffcc-periodic_table_db/lists"}