Re: "Terms" in PHP



Yes it did say "unsigned"...thanks very much for your response and this
clears up a lot.

I guess my only question is on the difference between char(100) and
varchar(100)...does the "var" part mean it's a variable?

MC




ZeldorBlat wrote:
> >For the script reading:
> >
> >$query = 'CREATE TABLE blog_entries (
> >blog_id INT UNASIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
> >title VARCHAR(100) NOT NULL, entry TEXT NOT NULL,
> >date_entered DATETIME NOT NULL
> >)';
> >
> >Now, is there an actual definition for the "_id" part of "blog_id" or
> >is that just part of the name of the column of this table? (According
> >to the book I'm reading it is the first column but was wondering if
> >there was more significance behind the "_id" part...(if it means
> >something in PHP.)
>
> Just part of the column name...nothing to do with PHP. How you name
> the columns in the database is up to you. People tend to name their
> primary key columns that way, although there are a lot of alternatives:
>
> *_id
> *_Id
> *_ID
> *ID
> *Key
> etc...
>
> >Also, it mentions it's an unassigned integer, and that because of this
> >it has to be a positive whole number. Why does it have to be a
> >positive whole number?
>
> Do you mean *unsigned* integer?
>
> integer = whole number between negative infinity and infinity
> unsigned = has no sign, hence is positve
> unsigned integer = whole number that is positve (including zero)
>
> Most database systems (well, probably all) offer different datatypes
> for storing different types of data. Depending on what you're storing,
> they take up different amounts of space. So you typically choose a
> type that:
>
> a) stores the type data you want (integer, numeric, string, binary,
> etc.)
> b) is of an appropriate size
>
> If a particular column only needs to have positive integers, then use
> the unsigned integer type (or equivalent). In this way you don't waste
> the space that you would otherwise need if you were storing say,
> decimal values.
>
> Strings work the same way. varchar(100) and char(100) can contain up
> to 100 characters. As far as I know the main difference is that
> varchar has a small overhead to store the length of the string that's
> currently there, but it only stores the data you put in it. char(100)
> will store a single character as a 100 character string. So if the
> strings are short or all about the same length, use char, otherwise use
> varchar.
>
> I suppose I should reiterate that all of this really has more to do
> with the database you're using than PHP.

.



Relevant Pages

  • Re: "Terms" in PHP
    ... >blog_id INT UNASIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, ... the unsigned integer type. ... varchar has a small overhead to store the length of the string that's ... but it only stores the data you put in it. ...
    (php.general)
  • Re: Output of a program
    ... (You'll need to deal with the '\n' character that fgets() ... the string, and with its behavior if the input line is longer than ...
    (comp.lang.c)
  • Re: Output of a program
    ... (You'll need to deal with the '\n' character that fgets() ... the string, and with its behavior if the input line is longer than ...
    (comp.lang.c)
  • Re: checking for a particular string in a cell
    ... I want to search for the character "ABC Stores" ... in a cell and it may be caps or small it shud return a value. ... This will return the position of the first character in the string where 'Stores' appears, ...
    (microsoft.public.excel.worksheet.functions)
  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)