In this project I build a database schema that could be used to organize an inventory of mechanical parts. The schema will keep track of all the parts, their manaufacturer, category, location in storeroom, available inventory, and other relevant information.
A database like this might be updated and queried by an inventory management application that accepts input from many users who might not be familiar with the database structure. I will make sure that there are sufficient data quality checks to ensure that only valid data can be entered into the database.
This project comes from a list of projects available within the Data Engineer Career Path.
To review the Database Schema please refer to Database folder. To review Database Constraints, please refer to the file inside of the folder, as well.
To review the CSV files associated with this project, please refer to the Asset_Files folder.
We ensure the following steps of the project is completed:
- Ensure the
codecolumn in parts is unique and not empty. - Backfill the
descriptioncolumn in parts with ‘None Available’. - Add a
NOT NULLconstraint to thedescriptioncolumn. - Test the
NOT NULLconstraint by attempting to insert a row with an emptydescription. - Ensure
price_usdandquantityinreorder_optionsareNOT NULL. - Add a check constraint to ensure
price_usdandquantityare positive. - Add a constraint to limit the price per unit to between 0.02 USD and 25.00 USD.
- Ensure
reorder_optionshas a foreign key relationship withparts. - Add a constraint to ensure
qtyinlocationsis greater than 0. - Ensure
locationsrecords only one row for each combination oflocationandpart. - Ensure parts in
locationsmust already be inparts. - Ensure all
partsin parts have a valid manufacturer. - Insert a new manufacturer with
id=11and name ‘Pip-NNC Industrial’. - Update old manufacturers’
partsin parts to reference the new company.
- PostgreSQL: Database creation, querying and manipulation.
- VSCode: IDE
In specific, the most recent lesson was in regards to constraints. The most common:
- Data types — Are your first line of defense.
NOT NULLconstraintsCHECKconstraints — Give you more control over what rules you’d like to apply to your tables. These constraints will allow you to reject a row if it fails the criteria you’ve defined.UNIQUEconstraints — Help with defining unique values in a table, they also create an index which can improve query and join performance.PRIMARY KEYconstraints — A column or combination of columns that uniquely identify a row and are bothNOT NULLandUNIQUE.PRIMARY KEYs are unique to a table, and will often be used in joins between tables.FOREIGN KEYconstraints — Allow you to maintain referential integrity between two tables by validating the entry in one also appears in the other. Referential integrity depends onFOREIGN KEYconstraints.
