Table with 2 fields but only one can be used at a time

后端 未结 2 417
情歌与酒
情歌与酒 2021-01-16 08:08

How would you design a database that has a table with 2 fields and just one of them can be set at a time, without too much redundancy? For example a file system:

Let

2条回答
  •  野的像风
    2021-01-16 08:42

    One table with id, name, parentid, and (if you want) type. Folders and files all point to their parent with parentid. Disks do not have a parentid. The only field that is NULL is the parentid field of the (relatively few) records that are of type Disk.

提交回复
热议问题