Productlist

Productlist is a project I put together after learning the basics of PHP and Database Normalization. This application was the perfect way to explore Object Oriented Programming(OOP) and practice Database Normalization after learning about Procedural PHP and working with Databases.

placeholder image

Type

Solo Project

Documentation

Blog Post

Source code  

Live

View Site

Project Purpose and Goal

As the main purpose of this project was to explore Object Oriented Programming in PHP and Database Normalization. I spent a lot of my time understanding the best practices of writing Object Oriented Programming in PHP and how to tie things together when working with PHP, JavaScript and MYSQL.

Also, PHP has a mixed reputation out there in the wild (tech twitter). And what better way to see what all the fuss is than by building something with PHP 🤷🏽‍♂️.

PHP hate in the wild 😂

Database Normalization

The general values I had to consider were: SKU (unique for each product), Name, Price.

The product specific attributes: Size (in MB) for DVD-disk, Weight (in Kg) for Books and Dimensions (HxWxL) for Furniture.

I first transferred these values into table format in their Un-normalized form.

I then identified that there were no repeating groups. Therefore the data already satisfied the 1st Normal Form requirements.

There were also no partial dependencies therefore the data was already in 2nd Normal Form.

There were however, transitive dependencies. Which created an anomaly where if a product type that occurred only once were deleted, the product type information would be lost. I solved this anomaly by separating the table into two using the product type name as a Foreign key in the Products table to link the two tables.

The result of this normalization process is the two tables on the right.

Products Table

ID Product SKU Product Name Product Price Product Type Product Measurements
1 KDNONE939 Acme Disk 1.00 DVD-disk 700
2 OIEIN938 War and Peace 20 Book 2
3 TREI3890 Chari 40 Furniture 24x45x15

Product Types Table

ID Product SKU Product Name Product Price Product Type Product Measurements
1 KDNONE939 Acme Disk 1.00 DVD-disk 700
2 OIEIN938 War and Peace 20 Book 2
3 TREI3890 Chari 40 Furniture 24x45x15

Problems and Thought Processes

I am a big fan of lists. I work through my projects by creating lists like above or if in a team project, we might use a kanban or a shared doc to keep track of tasks. Here I have listed out some elements that my app needs to find solutions for. I also note a few challenges that came up as I tackled the project.

In this case, I needed to come up with a project brief with no prior experience with PHP and no mentor that I could work with to come up with one. I solved this by doing some research to find one that was intended as a challenge for a PHP job.

Another problem that came up was how to manage my ENV variables. I had first opted for the .htaccess file but I soon learnt that it needed to be checked into git. Meaning I couldn't store sensitive information into it. I eventually found out that I could use the httpd.conf locally and heroku's config vars in production

For routing, I customized a router I found on an opensource project on GitHub. I then paired it together with the .htaccess file to perform URL rewrites.

Lastly, to dynamically change the product form, I used AJAX and pulled the relevant form values from the MySql database and populate the form fields.

Conclusion

I still have a few features I would love to implement with this project. I envision this as a stock management application. I'd really like to have the ability to generate individual product pages where the admin can edit product information. I would also like to work in some authorization where only admin level employees can edit product information but all employees can add products.