StevenLeonCooper
Thinker
- Joined
- Jan 6, 2014
- Messages
- 133
Not sorry Many-to-one. I wrote it wrong and corrected it like 5 times on my phone so obviously I confused myself there. One customer, many invoices/orders.I don't really understand that part. Multiple customers on a given invoice?
But, generally speaking, disallowing nulls when a value is not yet known suggests to me a large number of tables to cater for every possible event where there might still be an unknown value, leading to some heroic table joins when all is finally done. Either that, or fill unknown values with defaults - e.g. 0 for the invoice id of an uninvoiced transaction. That would be horrible.
Yes, it requires a fair amount of joining but the benefit is that the database only contains extant data, no conceptual placeholders. In the long run I think it comes down to manageability and performance. Completely avoiding NULL values at all costs would probably light up the eyes of anyone passionate about relational theory but when you have to do 6 different joins just to find out what item a customer ordered on a certain date, it suddenly seems like it would be easier to sift through paper records than conceptualize the next Query you're going to need.
I would consider NULL values as more of a yellow flag to reconsider your schema. There may be a good reason to allow NULL values but generally I would assume there's equally-good or better reason not to.
ETA: Regarding that first part, it could go either way. Depending on how you run your business you might consider a customer a physical person and therefore you may have invoices that you do want to be linked to multiple customers.
John and Bob run a business together. John and Bob both buy supplies on a company card from you and likewise they buy supplies individually. It may be pertinent to maintain their individual identities for their individual invoices and also their combined invoice. Of course you could also distinguish between customers and businesses or by payment method ... there are many ways to skin that cat but I at least see a logical reason to have a many-to-many relationship between invoices and customers.
Last edited: