not-null

Empty string in not-null column in MySQL?

I used to use the standard mysql_connect(), mysql_query(), etc statements for doing MySQL stuff from PHP. Lately I've been switching over to using the wonderful MDB2 class. Along with it, I'm using prepared statements, so I don't have to worry about escaping my input and SQL injection attacks. However, there's one problem I'm running in...

How liberal should I be with NOT NULL columns?

I'm designing a database schema, and I'm wondering what criteria I should use for deciding whether each column should be nullable or not. Should I only mark as NOT NULL only those columns that absolutely must be filled out for a row to make any sense at all to my application? Or should I mark all columns that I intend to never be null...

SQL Server ALTER field NOT NULL takes forever

I want to alter a field from a table which has about 4 million records. I ensured that all of this fields values are NOT NULL and want to ALTER this field to NOT NULL ALTER TABLE dbo.MyTable ALTER COLUMN myColumn int NOT NULL ... seems to take forever to do this update. Any ways to speed it up or am I stuck just doing it overnight dur...

How should an empty title be checked in a database?

I am doing my first database project. I would like to know why you should use NOT NULL in the following query ... TITLE nvarchar(60) NOT NULL .. Context CREATE TABLE Questions ( USER_ID integer FOREIGN KEY REFERENCES User_info(USER_ID) PRIMARY KEY ...

Is there a way in Hibernate to set not-null to true on save but not delete in a mapping config?

<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt; <hibernate-mapping package="org.lexiclan.orm.dao"> <class name="Address" table="ADDRESSES" lazy="false"> <id name="addressId" column="ADDRESS_ID"> <generator...

How do you add a NOT NULL FOREIGN KEY column to an existing (populated) table in MS SQL?

I need to add a NOT NULL column to an existing (populated) table that will be a foreign key to another table. This brings about two problems: When you add the column, its value cannot be null - using a default is not an option (unless it is removed later on) because the database logic is used in the server side validation when a user e...

NHibernate IUserType convert nullable DateTime to DB not-null value

I have legacy DB that store dates that means no-date as 9999-21-31, The column Till_Date is of type DateTime not-null="true". in the application i want to build persisted class that represent no-date as null, So i used nullable DateTime in C# //public DateTime? TillDate {get; set; } I created IUserType that knows to convert the entity ...

Fluent Nhibernate Automap convention for not-null field

Hi, Could some one help, how would I instruct automap to have not-null for a cloumn? public class Paper : Entity { public Paper() { } [DomainSignature] [NotNull, NotEmpty] public virtual string ReferenceNumber { get; set; } [NotNull] public virtual Int32 SessionWeek { get...

Concise C# code for gathering several properties with a non-null value into a collection?

A fairly basic problem for a change. Given a class such as this: public class X { public T A; public T B; public T C; ... // (other fields, properties, and methods are not of interest here) } I am looking for a concise way to code a method that will return all A, B, C, ... that are not null in an enumerable collec...

NHibernate not-null attribute has no effect

Hi, I'm trying to add a column to an existing table. I added a property to the mapping : <property name="SelectionId" column="selection_id" not-null="true"/> When I open the session, the new column is created, however the not-null attribute is not taken into account : the new column is nullable. I realize you need to specify a defau...

using fluent-nhibernate, is there convention to make the foreign-key column in one-to-many relation not null ?

I'm using fluent-nhibernate conventions to map my entityies: public class HasManyConvention : IHasManyConvention { public void Apply(FluentNHibernate.Conventions.Instances.IOneToManyCollectionInstance instance) { instance.Key.Column(instance.EntityType.Name + "ID"); instance.Cascade.AllDelete...