Creating Tables

In Django, tables are made similarly to objects in Python, where they are defined within the code with the specified columns you want it to include, and then you can call it like a function to create rows with the data you want.

ER Diagrams

Manually Created ER Diagram

We created ER diagrams, or Entity Relationship diagrams, where we created a visual representation of each table, and the connections between them. Below shows the manually created ER diagram created for our ITE140 final project, showing each table and its relation using crows foot notation.

For crows foot notation, a circle means that one can exist without the other, for example a store can exist without a food court. In that same connection a store can have multiple food_court items, represented by the three lines going into the food_court table. However, each food_court item can only appear in exactly 1 store, so it is marked with two lines, showing it has to have at least one entry and can only have 1.

Image of the ER diagram for a Costco store.

PGAdmin Created ER Diagram

Once we created out tables through django, the web tool it also creates, called PGAdmin provides useful tools including a tool to generate an ER diagram, shown below. It uses the same crows foot notation as the manually created ER diagram.

Image of the automatically generated ER diagram from pgAdmin.

Comparison

While the core tables of both diagrams are the same, there are some differences.

The differences I found include that the automatically generated diagram includes the schema with each table, while the manual one does not, this is due to the generated diagram including all tables in the database, while the manually created ER diagram only shows one schema.

The two tables are extremely similar, both use almost the same crows foot notation, the only difference is that the manually generated ER diagram specifies whether a value has to have at least one, or if there can be no connection.

If I were to do a similar project in the future, I would use django, as I find it more intuitive. It is also easier to fill with data, as you can use for loops easier than the fake data for postgresql.

Faker

Faker is a program that can be used to generate fake data to populate databases with example data. Faker allows you to generate a variety of things, including names, addresses, or phone numbers.

This helps database creators to understand how their database will handle large amounts of data, as well as allowing bugs to surface on what data might get entered into the table.

Another benefit of using faker, is that it can be looped so that it is easy to change the amount of data generated, and large amounts of data don't take large amounts of lines of code to generate.