Families of ideal sheaves: What's the correct definition? I'm looking at Bridgeland's paper "Flops and Derived categories" and I got confused on what he meant by a family of ideal sheaves.
Let $Y$ be a scheme, and let $S$ be another scheme. A family of sheaves $\mathcal E_Y$ on $Y$ over $S$ is a sheaf on $S\times Y$, flat over $S$. Two such families are equivalent if they differ by tensoring by pullback of a line bundle on $S$.
When we talk about ideal sheaves $\mathcal{I}$ of $Y$, usually an inclusion to the structure sheaf $\mathcal{O}_Y$ is taken as part of the data. Now when we talk about a family of ideal sheaves, what do we really mean by that hidden part of the data? At least a family of sheaves which are flat over $S$, but there should be more. More specifically, when we say "let $\mathcal E_Y$ be a family of ideal sheaves on $Y$ over $S$", is there an inclusion of $\mathcal E_Y$ into $\mathcal O_{S\times Y}$ given part of the data?
(EDIT: according to MartinG's answer, this attempt of definition doesn't seem to be right, some functoriality is missing. Now let me replace my question by the following:


*

*What is the functor $M_I(X)$? What's the definition and why is it functorial? (I'm guessing MartinG's suggestion is right, namely rank 1 sheaves with trivial determinant line bundle, but I'm not 100% sure.)


*Why does $M_I(X)$ exist as a scheme under that definition? (In the paper he seems need this fact in a crucial way.)


*What's the relation between $M_I(X)$ and $\text{Hilb}(X)$?

End of EDIT)
 A: [This is now an answer to the edited question(s), with some details added.
My answer to the original question is kept at the very end.]
Firstly: The question is a good one, and it is not easy to find references on
this. I had spent too much time pondering about the failure of the double dual
argument (see below) before I finally heard the arguement given in the last
section below, indirectly from Fantechi, via Faber.
Assume $X$ is smooth projective.
Definition: An $S$-valued point in $M_I(X)$ is an $S$-flat coherent sheaf on
$S\times X$, with stable fibres of rank one, and with determinant line bundle
isomorphic to $\mathcal{O}_{S\times X}$, modulo isomorphism.
(I do not know if this is what Bridgeland meant, but to me this is resonably
standard.)
Comment: Stability for rank one means torsion free.
Existence: Let $M(X)$ be the (Simpson) moduli space for stable rank one
sheaves. Then $M_I(X)$ is the fibre over $\mathcal{O}_X$ for the determinant
map $M(X) \to \mathrm{Pic}(X)$. This map sends a sheaf $I$ (stable rank one
fibres) on $S\times X$ to the determinant line bundle $\det(I)$, and it is
trivial as a point in $\mathrm{Pic}(X)$ if it is of the form $p^*L$ with
$L\in\mathrm{Pic}(S)$. Then $I\otimes p^*L^{-1}$ is equivalent to $I$
in $M(X)(S)$, and it has trivial determinant. This shows that $M_I(X)$
indeed is a fibre of the determinant map.
Of course the determinant of an ideal $I_Y\subset \mathcal{O}_X$ is nontrivial
if $Y$ is a non principal divisor, so you cannot map such ideals to $M_I(X)$.
In any case, the ideal of a divisor, without the embedding, would only
remember the linear equivalence class.
For brevity, let $\mathrm{Hilb}(X)$ be the part of the Hilbert scheme
parametrizing subschemes $Y\subset X$ of codimension at least $2$.
Then there is a natural map $F: \mathrm{Hilb}(X) \to M(X)$ that sends an ideal
$I_Y\subset\mathcal{O}_{S\times X}$ to $I_Y$, forgetting the embedding. Since $Y$ is
flat, so is $I_Y$, and its fibres are torsion free (by flatness again) of rank
one. By the codimension assumption, the determinant of $I$ is trivial.
Theorem: $F$ is an isomorphism.
Comment: In the literature one sometimes finds the argument that if $I$ is a
rank one torsion free sheaf with trivial determinant, then $I$ embeds into its
double dual, which coincides with its determinant $\mathcal{O}_X$. This
establishes bijectivity on points. (For Hilbert schemes of points on surfaces
this is enough to conclude, since you can check independently that both
$\mathrm{Hilb}(X)$ and $M_I(X)$ are smooth, and that the induced map on tangent
spaces is an isomorphism.) I do not know how to make sense of this argument in
families.
Sketch proof of theorem: The essential point is to show that every $I$ in
$M_I(X)(S)$ has a canonical embedding into $\mathcal{O}_{S\times X}$ such that the
quotient is $S$-flat.
Let $U\subset S\times X$ be the open subset where $I$ is locally free. Its
complement has codimension at least $2$ in all fibres. By the trivial
determinant assumption, the restriction of $I$ to $U$ is trivial. By codimension $2$,
the trivialization extends to a map $I\to \mathcal{O}_{S\times X}$. This map is injective,
in fact injective in all fibres: The restriction to each
fibre $\{s\}\times X$ is nonzero (as $U$ intersects
all fibres) and hence an embedding ($I$ is torsion free in fibres). It
follows that the quotient is flat. There are some details to check, but
this is the main point, I think.
[End of new answer, here is the original one:]
If we attempt to define $M_I(X)(S)$ as the set of $S$-flat ideals $I_Z$ in
$\mathcal{O}_{S\times X}$, then that would not be functorial in $S$, as the 
inclusion $I_Z \subset \mathcal{O}_{S\times X}$ may not continue to be injective after
base change (in the counter example in the other answer, restriction to the problematic fibre gives the zero map). We could impose
"universal injectivity", but that is just another way of requiring the
quotient $\mathcal{O}_Z$ to be $S$-flat, so then we have (re)defined the Hilbert
scheme. 
Another common way of defining moduli of ideals is as the moduli space for rank
one stable sheaves (i.e. torsion free) with trivial determinant line bundle.
The resulting moduli space is isomorphic to the Hilbert scheme of subschemes of
codimension at least 2.
A: I suppose one issue is that in those two things different objects are required to be flat (if anything). 
For $\mathrm{Hilb}(X)$ you want the family of the objects defined by the ideals to be flat, while for $\mathscr M_I(X)$ you may (only) want the family of the ideals to be flat, or even less.
In other words, you have a short exact sequence,
$$
0\to \mathscr I_Z\to \mathscr O_{S\times X}\to \mathscr O_Z\to 0,
$$
and this gives an $S$-valued point in $\mathrm{Hilb}(X)$ if $\mathscr O_Z$ is flat over $S$ and an $S$-valued point in $\mathscr M_I(X)$ if $\mathscr I_Z$ is flat, or even under more general conditions.
If $\mathscr O_Z$ is flat over $S$ then so is $\mathscr I_Z$, but not vice versa.
Here is a simple example:
Let $X=S=\mathbb P^1$ and $Z\subset S\times X=\mathbb P^1\times \mathbb P^1$ the union of one member of each of the rulings of $S\times X$. Then $\mathscr I_Z$ is a line bundle and hence flat over $\mathscr O_{S\times X}$ and hence over $S$, but $\mathscr O_Z$ and accordingly $Z$ is not flat. This shows why we like $\mathrm{Hilb}(X)$ much more than $\mathscr M_I(X)$.
Of course if $S$ is a closed point, then this issue does not arise.
A: Bridgeland uses another point of view on moduli spaces. His definition of a moduli functor (Def. 3.7) does not uses any assumption of flatness. Instead, he considers DERIVED restriction of the family object to fibers, and the condition which replaces flatness is that these derived restrictions are PURE in the t-structure he considers. If the t-structure is the usual one then this definition is equivalent to the standard definition (flatness = no higher derived pullbacks). 
The moduli space $M_I(X)$ of ideal sheaves is defined by the functor which associates to any scheme $S$ the set of (equivalence classes of) all sheaves on $S\times X$ which after (derived) restriction to fibers over $S$ are ABSTRACTLY isomorphic to sheaves of ideals. On a contrary, the Hilbert scheme functor associates to a scheme $S$ the set of sheaves on $S\times X$ with a FIXED EMBEDDING into $O_{S\times X}$ (again up to an appropriate embedding). Forgetting the embedding we obtain a morphism $Hilb(X) \to M_I(X)$. 
Of course, if $S$ is a closed point, and $I$ is isomorphic to an ideal sheaf, then there is a unique (up to a constant) embedding of $I$ into $O_X$. This shows that the map above is
a bijection on closed points. On the other hand, globally it is not clear why a family of sheaves isomorphic to ideal sheaves has an embedding into $O_{S\times X}$. I think that Bridgeland just does not want to deal with this subtle question, which has nothing to do with his goal, so he just ignores it.
