Re: "Terms" in PHP



>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
    ... > 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. ... > will store a single character as a 100 character string. ...
    (php.general)
  • Re: Code is failing on empyt recordset
    ... Set rst = CurrentDb.OpenRecordset ... primary key field for TST_FR_CASE_OTHERS. ... > fieldnames (even a query alias), ... >> Function RecordsInTable(Tablename As String, ...
    (microsoft.public.access.forms)
  • Re: Unmatch query?
    ... i.e. a single primary key field. ... Sub CompareTables(BaseTable As String, KeyField1 As String, _ ... Free subscription: ... For example an Employee table that have ...
    (microsoft.public.access.queries)
  • How random are randomly generated numbers ?
    ... I have a table that has a string primary key, consisting of 25 numbers, ... Dim i As Integer ... got the duplicate key message. ...
    (microsoft.public.access.formscoding)
  • Re: Intel Memory Ordering White Paper
    ... "Code dependent upon sequential store ordering should not use the string ... rep movsb ... no it's worse than that -- intel fast string stores can become globally ... core could see the zeroes out of order with another core performing some ...
    (Linux-Kernel)