ZakBibi / PracticePython

A repository of my practice python projects.
0 stars 0 forks source link

Make CustomerPostgresDao and ProductPostgresDao use an auto-incrementing column for their primary keys. #116

Open BasilBibi opened 5 years ago

BasilBibi commented 5 years ago
  1. Change table definition to use an auto incrementing integer primary key column.
  2. Change the create* method to return the newly created Dto containing the newly generated id.

This article should be a big help : Using PostgreSQL SERIAL To Create Auto-increment Column

Definition Of Done

  1. A standup presentation from you showing how this is done.
  2. Code changes and supporting tests that prove the refactoring was a success.
ZakBibi commented 5 years ago

I have a comment about this: if we change the PKs to auto-incrementing, while that is all well and good, won't we have to change the JSON as well?

BasilBibi commented 5 years ago

That's a great observation Sufi and well done for pushing back on the issue to get more clarification. To be clear it is typically when we store things in a relational database that we declare primary and foreign keys in the table DDL. Json is really just a way of serialising data that it can be passed between systems. In reality we would not build json daos because we would take the json and either use it immediately (see your work on the OxfordOnlineDictionary) or we would use the json to populate a relational or columnar (more on that at some future stage) database. I wanted you to build json daos first because that are easy and because it would help cement (pun intended) the OO concepts you have learned about abstract and concrete classes, polymorphism, encapsulation and inheritance.You also got to see some of the weaknesses of OO - the json daos are forced to implement methods that are 'inappropriate' for them e.g. create_customer