When the foreign key constrain is in place, why does
table designer allow to make that field allow nulls, but
property sheet doesn't? Is there specific reason to have
them behave inconsistently?
Thanks you,
IKI'm not certain which properties sheet you are referring to but most people
take it for granted that Enterprise Manager has a number of slightly quirky
features. In common with many others, I tend to avoid using EM and make
schema changes in TSQL code.
--
David Portas
SQL Server MVP
--|||Hi David,
In EM, "Table Properties" screen is shown by double click
on table or right-click/Properties. "Design Table" -
right-click/Design Table. As for me, it is a flaw in EM
Design Table feature to allow nulls for the field with
foreign key constraint, thus allowing orphan records in a
child table.
Best Regards,
IK
>--Original Message--
>I'm not certain which properties sheet you are referring
to but most people
>take it for granted that Enterprise Manager has a number
of slightly quirky
>features. In common with many others, I tend to avoid
using EM and make
>schema changes in TSQL code.
>--
>David Portas
>SQL Server MVP
>--
>
>.
>|||> As for me, it is a flaw in EM
> Design Table feature to allow nulls for the field with
> foreign key constraint, thus allowing orphan records in a
> child table.
No, that feature is by design. In ANSI/ISO Standard SQL, all columns can be
nullable except Primary Keys. That includes Foreign Keys. You can decide
either to allow or disallow NULLs depending on your requirements.
--
David Portas
SQL Server MVP
--|||That explained a lot, thank you. And I wish EM would be
more consistent in enforcing those standards across all
its features.
Best Regards,
IK
>--Original Message--
>> As for me, it is a flaw in EM
>> Design Table feature to allow nulls for the field with
>> foreign key constraint, thus allowing orphan records
in a
>> child table.
>No, that feature is by design. In ANSI/ISO Standard SQL,
all columns can be
>nullable except Primary Keys. That includes Foreign
Keys. You can decide
>either to allow or disallow NULLs depending on your
requirements.
>--
>David Portas
>SQL Server MVP
>--
>
>.
>
Friday, February 17, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment