B
beginwithl
Hi
I just started learning ADO.NET and Sql
1)
From SQL book:
“SQL, however, doesn’t allow for data to hold no value. Fields with no
specified value actually do have a value: NULL. NULL is not the same
thing as nothing; NULL represents the unknown.
But MSDN claims:
“The DBNull class represents a nonexistent value. In a database, for
example, a column in a row of a table might not contain any data
whatsoever. That is, the column is considered to not exist at all
instead of merely not having a value. A DBNull object represents the
nonexistent column.”
a) So MSDN essentially claims that Sql table may have a column in a
row that doesn’t have any value assign to it ( not even NULL ) and
thus column isn’t even considered to exist?
But Sql book claims that all fields in a DB must have a value assigned
to them. So which is true?
b) Perhaps this is just a matter of semantics, but according to SQL
book a column with value of NULL is conceptually still considered to
exist, and NULL here represents the unknown value. In other words,
column has a value, but we don’t know what that value is.
MSDN on the other hand claims DBNull represents non existing column,
that is a column that doesn’t even exist ( just conceptually doesn’t
exist? ) due to not having any value
* So which of the two quotes is correct?
* I assume if Sql book is correct, then DBNull instance represents an
unknown value?
2) “If a database field has missing data, you can use the
DBNull..::.Value property to explicitly assign a DBNull object value
to the field. However, most data providers do this automatically. “
Above quote suggests data providers would automatically assign null
value to the field located in a database itself. When would data
providers do this automatically?
Even when app would simply be just reading from a DB table and upon
encountering a field with no value they would simply put value NULL in
it?
Or would they do this only when app would be adding a row and if no
value was assigned to a particular field, then null will be
automatically added?
3) “DBNull is a singleton class, which means only this instance of
this class can exist.”
What is the reason for only allowing one instance of DBNull class to
exist? Couldn’t that cause potentional problems in multithreaded apps?
thank you
I just started learning ADO.NET and Sql
1)
From SQL book:
“SQL, however, doesn’t allow for data to hold no value. Fields with no
specified value actually do have a value: NULL. NULL is not the same
thing as nothing; NULL represents the unknown.
But MSDN claims:
“The DBNull class represents a nonexistent value. In a database, for
example, a column in a row of a table might not contain any data
whatsoever. That is, the column is considered to not exist at all
instead of merely not having a value. A DBNull object represents the
nonexistent column.”
a) So MSDN essentially claims that Sql table may have a column in a
row that doesn’t have any value assign to it ( not even NULL ) and
thus column isn’t even considered to exist?
But Sql book claims that all fields in a DB must have a value assigned
to them. So which is true?
b) Perhaps this is just a matter of semantics, but according to SQL
book a column with value of NULL is conceptually still considered to
exist, and NULL here represents the unknown value. In other words,
column has a value, but we don’t know what that value is.
MSDN on the other hand claims DBNull represents non existing column,
that is a column that doesn’t even exist ( just conceptually doesn’t
exist? ) due to not having any value
* So which of the two quotes is correct?
* I assume if Sql book is correct, then DBNull instance represents an
unknown value?
2) “If a database field has missing data, you can use the
DBNull..::.Value property to explicitly assign a DBNull object value
to the field. However, most data providers do this automatically. “
Above quote suggests data providers would automatically assign null
value to the field located in a database itself. When would data
providers do this automatically?
Even when app would simply be just reading from a DB table and upon
encountering a field with no value they would simply put value NULL in
it?
Or would they do this only when app would be adding a row and if no
value was assigned to a particular field, then null will be
automatically added?
3) “DBNull is a singleton class, which means only this instance of
this class can exist.”
What is the reason for only allowing one instance of DBNull class to
exist? Couldn’t that cause potentional problems in multithreaded apps?
thank you