Re: [GENERAL] one more word about rules

2000-09-26 Thread Zeljko Trogrlic

ID shouldn't contain any additional informations (like order). It's ID. Use
another field for sorting.

At 16:33 22.9.2000 , Abe Asghar wrote:
>Hi everyone,
>
>I have built a database that uses int4 as the unique identifier for a news
>database.
>
>Therefore an article has a identifier 1, the next one has 2 etc.
>
>Then I order them when they are displayed on the web reversely so that the
>last article added is at the top of the list.
>
>I now face a major problem.  If we need to back dackdate an article - I
>can't.  This is because the all the indexes are taken up ie 1, 2, 3..75
>odd records.  If I want to add one between 50 and 51 ie 50.5, I cannot
>because the field is an int4.
>
>One idea I had to get around this was to create a new table with this column
>as a float and read and write all therecords in with a PHP script.
>
>Is there an easier way such as converting the column data type from a int4
>to a float.
>
>Thanks in advance.
>Abe.





Re: [GENERAL] one more word about rules (fwd)

2000-09-22 Thread John McKown


Well, how about just adding something other than 1 (such as 100) to the
value in the table? As for the existing table, perhaps, before moving it
to the new table, you could do something like:

UPDATE table SET article_number=article_number*100;

This would change all the current article numbers to higher values. If
these numbers are referenced in other columns, then do an equivalent
UPDATE command on those columns as well.

This is about all that I can come up with.

John

On Fri, 22 Sep 2000, Abe Asghar wrote:

> John,
> 
> The way I generate my article number is by having a table called unique_key.
> This table holds a number that is read and 1 is added to it to generate the
> next key and the last number is writted to back to the table.  So this table
> only contains one value.  That of the last article added.
> 
> Also the problem is that I already have a database that contains articles
> that I need that I am going to move to the new table.
> 
> Abe.
> - Original Message -
> From: "John McKown" <[EMAIL PROTECTED]>
> To: "Abe Asghar" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Friday, September 22, 2000 4:11 PM
> Subject: Re: [GENERAL] one more word about rules
> 
> 
> > Abe,
> > How do you generate your article number? If you are using a SERIAL, then
> > you could change it to use a specific SEQUENCE and step the SEQUENCE by
> > some value other than one. Something like:
> >
> > CREATE SEQUENCE article_sequence INCREMENT 100 MINVALUE 1 START 101;
> >
> > CREATE TABLE article (
> > article_number int4 default nextval('article_sequence')
> > );
> >
> > That would automatically generate article numbers 101, 201, 301, ...
> > thus leaving room for "inserted" articles.
> >
> > On Fri, 22 Sep 2000, Abe Asghar wrote:
> >
> > > Hi everyone,
> > >
> > > I have built a database that uses int4 as the unique identifier for a
> news
> > > database.
> > >
> > > Therefore an article has a identifier 1, the next one has 2 etc.
> > >
> > > Then I order them when they are displayed on the web reversely so that
> the
> > > last article added is at the top of the list.
> > >
> > > I now face a major problem.  If we need to back dackdate an article - I
> > > can't.  This is because the all the indexes are taken up ie 1, 2,
> 3..75
> > > odd records.  If I want to add one between 50 and 51 ie 50.5, I cannot
> > > because the field is an int4.
> > >
> > > One idea I had to get around this was to create a new table with this
> column
> > > as a float and read and write all therecords in with a PHP script.
> > >
> > > Is there an easier way such as converting the column data type from a
> int4
> > > to a float.
> > >
> > > Thanks in advance.
> > > Abe.
> > >
> >
> 





Re: [GENERAL] one more word about rules

2000-09-22 Thread Adam Haberlach

On Fri, Sep 22, 2000 at 03:33:46PM +0100, Abe Asghar wrote:
> Hi everyone,
> 
> I have built a database that uses int4 as the unique identifier for a news
> database.
> 
> Therefore an article has a identifier 1, the next one has 2 etc.
> 
> Then I order them when they are displayed on the web reversely so that the
> last article added is at the top of the list.
> 
> I now face a major problem.  If we need to back dackdate an article - I
> can't.  This is because the all the indexes are taken up ie 1, 2, 3..75
> odd records.  If I want to add one between 50 and 51 ie 50.5, I cannot
> because the field is an int4.

Perhaps you should store the date of the article in the database, and
then sort by that.  You can even set the default for the field to be now() so
that it automatically gets set on insert, and you can override it during
backdate inserts or with later updates...


-- 
Adam Haberlach| A billion hours ago, human life appeared on
[EMAIL PROTECTED]   | earth.  A billion minutes ago, Christianity
http://www.newsnipple.com | emerged.  A billion Coca-Colas ago was
'88 EX500 | yesterday morning. -1996 Coca-Cola Ann. Rpt.



Re: [GENERAL] one more word about rules

2000-09-22 Thread John McKown

Abe,
How do you generate your article number? If you are using a SERIAL, then
you could change it to use a specific SEQUENCE and step the SEQUENCE by
some value other than one. Something like:

CREATE SEQUENCE article_sequence INCREMENT 100 MINVALUE 1 START 101;

CREATE TABLE article (
article_number int4 default nextval('article_sequence')
);

That would automatically generate article numbers 101, 201, 301, ...
thus leaving room for "inserted" articles.

On Fri, 22 Sep 2000, Abe Asghar wrote:

> Hi everyone,
> 
> I have built a database that uses int4 as the unique identifier for a news
> database.
> 
> Therefore an article has a identifier 1, the next one has 2 etc.
> 
> Then I order them when they are displayed on the web reversely so that the
> last article added is at the top of the list.
> 
> I now face a major problem.  If we need to back dackdate an article - I
> can't.  This is because the all the indexes are taken up ie 1, 2, 3..75
> odd records.  If I want to add one between 50 and 51 ie 50.5, I cannot
> because the field is an int4.
> 
> One idea I had to get around this was to create a new table with this column
> as a float and read and write all therecords in with a PHP script.
> 
> Is there an easier way such as converting the column data type from a int4
> to a float.
> 
> Thanks in advance.
> Abe.
>