1,105,578 Community Members

What if?

Member Avatar
luke.belleghem
Newbie Poster
16 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

LastMitch
Deleted Member
 
0
 

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?

I assume this is your first time creating a database:

Read this:

http://php.about.com/od/learnmysql/ht/create_database.htm

Read this (this has an example you can used) :

http://www.w3schools.com/php/php_mysql_create.asp

Member Avatar
JorgeM
IT Addict
6,414 posts since Dec 2011
Reputation Points: 581 [?]
Q&As Helped to Solve: 963 [?]
Skill Endorsements: 172 [?]
Moderator
Featured
Sponsor
 
0
 

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.

Member Avatar
luke.belleghem
Newbie Poster
16 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

Member Avatar
JorgeM
IT Addict
6,414 posts since Dec 2011
Reputation Points: 581 [?]
Q&As Helped to Solve: 963 [?]
Skill Endorsements: 172 [?]
Moderator
Featured
Sponsor
 
0
 

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.

Member Avatar
luke.belleghem
Newbie Poster
16 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

LastMitch
Deleted Member
 
0
 

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.

Member Avatar
luke.belleghem
Newbie Poster
16 posts since Feb 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

LastMitch
Deleted Member
 
0
 

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

Member Avatar
drjohn
Posting Pro
526 posts since Mar 2010
Reputation Points: 50 [?]
Q&As Helped to Solve: 106 [?]
Skill Endorsements: 4 [?]
 
0
 

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.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article