Composite Primary key vs additional “ID” column?

后端 未结 4 1045
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 00:24

If we had a table like this:

Books (pretend \"ISBN\" doesn\'t exist)

  • Author
  • Title
  • Edition
  • Year of publication
  • Price
4条回答
  •  广开言路
    2020-11-30 01:07

    There are many articles related to this. The problems with composite key in your case:

    1. hard to link books with other entities
    2. Hard to edit them in a grid as most grids are not supporting composite keys (e.g. kendo grid, jqgrid)
    3. You might misspell Author, Title, Edition

    It would be also good to normalize your data and store just an ID to the author like (dasblinkenlight) suggested. Worst case scenario, he/she will change his/hers name (e.g. she get's married, and she likes her new name).

提交回复
热议问题