title: Prevent from adding row with same value within time window
body: <p>For the sake of clarity lets assume I have table with 3 columns:</p>
  <pre><code>ID | Value | DateTimeInserted
  </code></pre>
  <p>Now I need to prevent row insertion with the same Value, if DateTimeInserted is less than 7 days for existing row with same Value.
  Example:</p>
  <pre><code>ID | Value | DateTimeInserted
  1  | AAA   | 2021-12-16
  2  | BBB   | 2021-12-06
  </code></pre>
  <p>Expectation is that I can add row with GETUTCDATE() (=2021-12-17) for a row with Value = BBB, but database should prevent me from inserting Value = AAA and DateTimeInserted = 2021-12-17</p>
  <p>So far I was considering:</p>
  <ul>
  <li>Filtered unique index - won't work as filter would be non-deterministic</li>
  <li>Indexed view showing only records from last 7 days - reason same as above</li>
  <li>I wrote a constraint that checks whether such row already exists, but I think it works in-memory and fails to prevent if I run queries in parallel (running simultaneously 10 inserts gives me between 5 and 10 rows inserted, when there should be only one)</li>
  </ul>