creating a DB

He has: 1,380 posts

Joined: Feb 2002

hey...i need some help, i created a db in MySQl, but i cant figure out how to name the fields and whatnot...i'm using phpMyAdmin...both are text fields...can you give me the specs i need please? thanks

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

How to name the fields? I think everyone has different methods. I usually name them by the tablename_fieldname. An id field would be tablename_id.

Is this what you are talking about or are you also talking about what type of field, text, varchar, date, int, etc, to name them. Anything greater than 255 characters should be a text field. Some common mistakes are making fields like phone numbers and zip codes int fields. This doesn't work if you try to put the - in phone or zip fields.

Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states

He has: 1,380 posts

Joined: Feb 2002

everything...i dont know what type or how to name...like i put in "name" as the name for the first one, and it said it wasnt acceptable...

they are plain text...2 fields: 1 name, 1 email address...i want each different entry to add itself to the db, and not overwrite the previous ones...so what are the different things i need to change for each field...thanks

Busy's picture

He has: 6,151 posts

Joined: May 2001

u_id - small int 4 auto increment primary index (adds to bottom of list) 4 can go up to 9999 if you want more make it 5 or 6
u_name - varchar 15 (not many names are longer than 15 but can be whatever)
u_email - varchar 20 (agin not many over 20 but can be anything)

there are some reserved words so if it says something like it wasn't acceptable add a extra letter or underscore.

many ways to do it

They have: 238 posts

Joined: May 2002

While this topic is here, what is null, not-null, varchar, int and all this other stuff? What exactly does each one mean? Thanks..

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

Varchar is a variable character field. Which means that the field can contain letters and/or numbers and it is variable in size so it saves some database space.
Char is similar except that it doesn't save database space.
Int is for Integer or a whole number.
Null means that the field doesn't have to have a value.
Not Null means that the field must contain a value.

Here is a whole list of column types.

Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states

He has: 1,380 posts

Joined: Feb 2002

i figured it out...thanks

They have: 238 posts

Joined: May 2002

Quote: Originally posted by mairving
Varchar is a variable character field. Which means that the field can contain letters and/or numbers and it is variable in size so it saves some database space.
Char is similar except that it doesn't save database space.
Int is for Integer or a whole number.
Null means that the field doesn't have to have a value.
Not Null means that the field must contain a value.

Here is a whole list of column types.

Thanks for that Wink

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.