Let $X = \mathbb{R} $, $D = \mathbb{Q}$ and $I = (0,1)$. We know that $X$ is a complete metric space and $D$ a countable dense subset, thus making $X$ separable.
First of all, I do know that a subspace of a separable metric space is itself separable. I have learned the proof using second countability, which also gives a construction of said dense subset (I think).
This question however is based on something else: In this particular case I feel like the first approach one would choose to construct a dense subset would be to just look at $I \cap D$. Now here I would argue that the closure $cl(I \cap D)=[0,1]$ which is not $I$ again, so is $I \cap D$ actually dense in $I$?
Furthermore if this construction works in this particular example, would it be possible to extend this to a proof? Naively translating this would not work, as if $I:=\{x\in\mathbb{R}: x \notin \mathbb{Q}\}$ the "purely" irrational numbers, then the intersection would just be empty...
$I \cap D$ is indeed dense in $I$ and in general that argument can show that any open subset of a separable (general) space is again separable: the intersection of the dense set with the open set is dense in the open set.