How far to go with database constraints?

前端 未结 2 1703
清歌不尽
清歌不尽 2020-12-10 21:38

This question is related to another question I asked. In my other question I ask peoples opinions about 3 different ways I could construct a database. The cleanest way I ca

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 21:59

    Why not have:

    Alert [Table]
    - Id [PK]  
    - SensorReadingId [FK]  
    - LoggerReadingId [FK]  
    

    And then you fill either the SensorReadingId or the LoggerReadingId. I suppose your structure is a simplified one, but often a table with nothing else then one PK is redundent.

提交回复
热议问题