C
C#14mo ago
Core

Database Design

Generic question. I cannot figure out how to design the database in the following scenario:
| Users |
-------
| Id PK |

and

| OtherTable |
------------
| Id PK |
| UserId FK |
| Value INT |
| Users |
-------
| Id PK |

and

| OtherTable |
------------
| Id PK |
| UserId FK |
| Value INT |
OtherTable is in relation with Users, but there is a default Value that should belong to all users. This can be solved by creating a resource with the same value for each user, but I feel like this is a bad practice. What other options do I have? I am using EF with Postgres, but I do not think that matters.
2 Replies
dan in a can
dan in a can14mo ago
You can use a default value for the column https://www.postgresql.org/docs/current/ddl-default.html
PostgreSQL Documentation
5.2. Default Values
5.2. Default Values # A column can be assigned a default value. When a new row is created and no values …
Core
CoreOP14mo ago
Thanks, this would be a good option

Did you find this page helpful?