Re: [SQL] pg & Delphi

2007-08-28 Thread Josh Tolley
On 8/28/07, Richard Huxton <[EMAIL PROTECTED]> wrote: > Kitter Georgiy wrote: > > Good day. > > > > I want to enter Postges into project, > > which has so rectriction, that client should be written on Delphi > > (CBuilder). > > Please, prompt me how to adjust Delphi to use Postgres. > > You sh

Re: [SQL] pg & Delphi

2007-08-28 Thread sergio carrasco
--- Kitter Georgiy <[EMAIL PROTECTED]> escribió: > Good day. > > I want to enter Postges into project, > which has so rectriction, that client should be > written on Delphi (CBuilder). > Please, prompt me how to adjust Delphi to use > Postgres. > You can to use: ZeoslibDBO (free, but it h

Re: [SQL] Was: fetch first rows of grouped data

2007-08-28 Thread Sebastian Ritter
Sorry my last post isnt complete. This would have to be part of a sub select. It would be more lilke: SELECT * from cities LEFT OUTER JOIN (SELECT c.id as city_id, event.id FROM cities c LEFT OUTER JOIN events e ON (c.id = e.city_id) WHERE c.id = cities.id ORDER BY e.date DESC LIMIT 2) as x ON (c

[SQL] Was: fetch first rows of grouped data

2007-08-28 Thread Guy Fraser
Hi there I have a list of events that take place in a certain city at a certain date. Now I would like to have the first two (ordered by date) events for each city. Is there a way to do this with one query? I am using PostgreSQL 7.4.

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
Thanks guys, Sebastian On 8/28/07, Bart Degryse <[EMAIL PROTECTED]> wrote: > > Im using Django as my Object relational Mapper so im pretty sure I > can not add a constraint such as ... > Then you should seriously consider changing your mapper. > > >>> "Sebastian Ritter" <[EMAIL PROTECTED]> 2007-

Re: [SQL] Database normalization

2007-08-28 Thread Bart Degryse
Im using Django as my Object relational Mapper so im pretty sure I can not add a constraint such as ... Then you should seriously consider changing your mapper. >>> "Sebastian Ritter" <[EMAIL PROTECTED]> 2007-08-28 16:37 >>> Thanks for the information. Both tables would be exactly sames apart fr

Re: [SQL] Database normalization

2007-08-28 Thread Andrew Sullivan
On Tue, Aug 28, 2007 at 04:15:01PM +0100, Sebastian Ritter wrote: > > I'd put it in its own table, probably, unless you're going to use it > > frequently. > > Why would frequency of use change whether or not I use one or two tables? If you have a possibly-large field that does not get used very

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
Hi, On 8/28/07, Andrew Sullivan <[EMAIL PROTECTED]> wrote: > > On Tue, Aug 28, 2007 at 03:37:22PM +0100, Sebastian Ritter wrote: > > Thanks for the information. > > > > Both tables would be exactly sames apart from the foreign key relation > to > > clients or services. > > Hmm. Are the services

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
Hi, The views option sounds best in my opinion but sadly i cant play with things like inheritance or views as Im using Django as my ORM and since its relatively new, it doesnt yet support such database operations. Id like the ids for each "entity" to be serial and hence there would be overlap bet

Re: [SQL] Database normalization

2007-08-28 Thread Andrew Sullivan
On Tue, Aug 28, 2007 at 03:37:22PM +0100, Sebastian Ritter wrote: > Thanks for the information. > > Both tables would be exactly sames apart from the foreign key relation to > clients or services. Hmm. Are the services or clients tables different? A useful rule of thumb is that, to the extent

Re: [SQL] Database normalization

2007-08-28 Thread Erik Jones
On Aug 28, 2007, at 6:47 AM, Sebastian Ritter wrote: Hello, I have a fairly basic question about database design where im not sure which approach is considered correct. I have two different entities: Clients and Services. Both allow users to add progressive updates about the two entities.

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
Thanks for the information. Both tables would be exactly sames apart from the foreign key relation to clients or services. I agree that it seems strange to have one column that is always null. Im using Django as my Object relational Mapper so im pretty sure I can not add a constraint such as : CH

Re: [SQL] Database normalization

2007-08-28 Thread Andrew Sullivan
On Tue, Aug 28, 2007 at 12:47:45PM +0100, Sebastian Ritter wrote: > > The update/message format is exactly the same for both. Should I make two > > different tables: > > one table with extra columns : is_client, client_id, service_id, where > > either client_id or service_id would be null depend

Re: [SQL] fetch first rows of grouped data

2007-08-28 Thread hubert depesz lubaczewski
On Tue, Aug 28, 2007 at 08:00:42AM -0500, Michael Glaesemann wrote: > >you can try to use "distinct on". > I considered that as well, but couldn't think of a way to return more you're right and i was wrong. i simply missed the word "two" in original question. sorry. depesz -- quicksil1er: "po

Re: [SQL] Database normalization

2007-08-28 Thread Asko Oja
Hi I would create one table to log updates with type field and one id filed that contains either client id or service id according to type. On such a table i would forget about foreign keys (thay are better to be avoided anyway if you have millions of records in tables). That way you can share cod

Re: [SQL] fetch first rows of grouped data

2007-08-28 Thread Michael Glaesemann
On Aug 28, 2007, at 4:14 , hubert depesz lubaczewski wrote: On Mon, Aug 27, 2007 at 06:36:47PM +0200, Claudia Kosny wrote: Is there a way to do this with one query? I am using PostgreSQL 7.4. you can try to use "distinct on". I considered that as well, but couldn't think of a way to return

Re: [SQL] Database normalization

2007-08-28 Thread Sebastian Ritter
Hello, > > I have a fairly basic question about database design where im not sure > which approach is considered correct. > > I have two different entities: Clients and Services. Both allow users to > add progressive updates about the two entities. > > The update/message format is exactly the same

Re: [SQL] fetch first rows of grouped data

2007-08-28 Thread hubert depesz lubaczewski
On Mon, Aug 27, 2007 at 06:36:47PM +0200, Claudia Kosny wrote: > Is there a way to do this with one query? > I am using PostgreSQL 7.4. you can try to use "distinct on". depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly paid DBA. here's my CV!" :) http://www.d

Re: [SQL] pg & Delphi

2007-08-28 Thread Richard Huxton
Kitter Georgiy wrote: Good day. I want to enter Postges into project, which has so rectriction, that client should be written on Delphi (CBuilder). Please, prompt me how to adjust Delphi to use Postgres. You should be able to connect via ODBC. Googling "PostgreSQL Delphi" seems to give so

Re: [SQL] Request into several DBMS simultaneously on DDL and DML

2007-08-28 Thread Richard Huxton
Kitter Georgiy wrote: (1)Let's allow to __connect into several DBMS__ at once, last of them becomes DBMS 'by default'. ... It's necessary to not signalize about break of foreign key, if remote database will not connected in next time. But that's the vital bit. Without being able to extend rel

Re: [SQL] pg & Delphi

2007-08-28 Thread Daniel Drotos
On Tue, 28 Aug 2007, Kitter Georgiy wrote: which has so rectriction, that client should be written on Delphi (CBuilder). Please, prompt me how to adjust Delphi to use Postgres. We use pgExpress driver from http://vitavoom.com It is commercial, but cheep and works well. You can try ODBC as we