What if I set up a database table for an ad form that has optional fields. Do i need to select anything when creating rows for these fields other then the type?

Recommended Answers

All 9 Replies

If the fields are optional that is fine. In general regardless of the SQL implementation, you would set the corret data type and allow for NULL values to be stored in the event that no data is inserted in the particular field for the record.

If the fields are optional that is fine. In general regardless of the SQL implementation, you would set the corret data type and allow for NULL values to be stored in the event that no data is inserted in the particular field for the record.

How do I allow for NULL values to be stored. Do i select Null as DEFAULT or do I select the NULL check box when creating the row?

I beleive that for MySQL, the column allows for null values unless you specified not to allow (not NULL) null values when you create the table. If you did set it to not allow null values, you simple can use the alter statement to modify the field to allow null values.

I beleive that for MySQL, the column allows for null values unless you specified not to allow (not NULL) null values when you create the table. If you did set it to not allow null values, you simple can use the alter statement to modify the field to allow null values.

Sorry, im using phpMyAdmin to manage my tables. Are you familiar with phpMyAdmin? If so could you tell me what to select. Such as NULL under DEFAULT or select the NULL checkbox?

Member Avatar for LastMitch

Sorry, im using phpMyAdmin to manage my tables. Are you familiar with phpMyAdmin?

Did you read the links I provided.

There's query you can enter in the phpMyAdmin if you want to do it that way.

Did you read the links I provided.

There's query you can enter in the phpMyAdmin if you want to do it that way

I did but it still doesn't explain when to use NULL as DEFAULT or when to click the NULL checkbox in phpMyAdmin.

Member Avatar for LastMitch

NULL as DEFAULT or when to click the NULL checkbox in phpMyAdmin.

You have to be more specific what you are trying to do?

You keep mention regarding NULL as Default.

Either you want NULL or Not NULL?

When you create a table and you add 2 or 3 column then you have an option to check NULL or Not NULL.

Read this if you don't understand what is a NULL or NOT NULL:

http://www.sqlservergeeks.com/articles/sql-server-bi/5/how-does-sql-server-treats-null-values

If you are willing to let people leave a box empty/field on the form, then you can do either default null or select the null checkbox!
Both will give the same result.

If you check the not null box, it will fail to store the empty / null value that the form passes it. And report an error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.