> Hi Anna, I suspect you don't have a great deal of
> experience with data
> bases.
Yes, I don't have much experience with dbs yet. But
I'm working on it. :)
>
> The ID that is being autogenerated by MySQL is known
> as a "surrogate"
> key. That is, a value that uniquely identifies each
> record, but has no
> relationship to that data other than to be an
> identity. There should be
> no reason for you to worry about any "gaps", and you
> should never base
> any query or sorting logic on the key - it should
> only be used to fetch
> a particular record.
>
> Think of a row of houses on a particular city
> street. If one house is
> demolished for any reason, there is no need to
> renumber any of the
> surrounding houses. Their address merely serves to
> uniquely identify
> them has an individual entity... it doesn't tell you
> anything about the
> house (who lives there, number of bedrooms, etc.).
>
> Mike
Good one. I think I understand it better now.
I have 1 more question though. :) now that I'm
thinking about it. the auto_increment value of that id
column.
Should I bother about the order of those values.
For example, <PEDANTIC MODE>my table has 10
records</PEDANTIC MODE>.
The AUTO_INCREMENT value is 11. I then delete 2 last
records. I have 8 recs left, and AUTO_INCREMENT value
is still 11, so I count the rows and add 1. Like this:
$numresults = mysqli_query($link, "SELECT bookmarkId
FROM bookmark");
$numrows = mysqli_num_rows($numresults);
$autoIncrement = $numrows + 1;
$fixAutoIncrementValue = 'alter table bookmark
AUTO_INCREMENT = '.$autoIncrement.'';
That fixed the AUTO_INCREMENT issue in this situation.
But what if i delete a record from the middle of the
recordset, do I need to look at the last record in
that database and then add 1 to that value?
Anna Vester
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Community email addresses:
Post message: php-list@yahoogroups.com
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
SPONSORED LINKS
Php mysql | Job postings |
YAHOO! GROUPS LINKS
- Visit your group "php-list" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.