Turn two database tables into one?

后端 未结 3 1236
借酒劲吻你
借酒劲吻你 2021-01-27 01:33

I am having a bit of trouble when modelling a relational database to an inventory managament system. For now, it only has 3 simple tables:

  1. Product

    
    
            
3条回答
  •  轮回少年
    2021-01-27 01:44

    Personally I prefer the first option, that is, separate tables for Sales and Receiving.

    The two biggest disadvantage in option number 2 or merging two tables into one are:

    1) Inflexibility
    2) Unnecessary filtering when use
    

    First on inflexibility. If your requirements expanded (or you just simply overlooked it) then you will have to break up your schema or you will end up with unnormalized tables. For example let's say your sales would now include the Sales Clerk/Person that did the sales transaction so obviously it has nothing to do with 'Receiving'. And what if you do Retail or Wholesale sales how would you accommodate that in your merged tables? How about discounts or promos? Now, I am identifying the obvious here. Now, let's go to Receiving. What if we want to tie up our receiving to our Purchase Order? Obviously, purchase order details like P.O. Number, P.O. Date, Supplier Name etc would not be under Sales but obviously related more to Receiving.

    Secondly, on unnecessary filtering when use. If you have merged tables and you want only to use the Sales (or Receving) portion of the table then you have to filter out the Receiving portion either by your back-end or your front-end program. Whereas if it a separate table you have just to deal with one table at a time.

    Additionally, you mentioned ORM, the first option would best fit to that endeavour because obviously an object or entity for that matter should be distinct from other entity/object.

提交回复
热议问题