Re: [SQL] partitions versus databases

2011-12-10 Thread Jasen Betts
On 2011-12-08, chester c young wrote: > have an db with about 15 tables that will handle many companies. no data > overlap between companies. is it more efficient run-time to use one database > and index each row by company id, and one database and partition each table > by company id, or to

Re: [SQL] Question on imports with foreign keys

2011-12-10 Thread Jasen Betts
On 2011-12-08, Andreas wrote: > Hi, > > suppose you need to import a csv with standard ciolums like name, > adress, phone, ... and some additional text columns that need to be > split off into referenced tables. ... > How is the easiest way to to find the customer.id of the new customers > so I

Re: [SQL] conditional FROM

2011-12-10 Thread Jasen Betts
On 2011-12-10, Richard Klingler wrote: > Good day... > > I'm trying to build a query for PGSQL 9.1 where a table has two > references with only one being used depending of the type of entry.. > > For example, the table has following simplified structure: > > portid primary key >

Re: [SQL] Subselects to Joins? Or: how to design phone calls database

2011-12-10 Thread Viktor Bojović
Hi Mario, over - partition by will help. Iy that syntax is uncomfortable you can use multiple joins, using maximum length or max(prefix::int) but that will slow down the process. select over - partition by is fastest solution i think. On Sat, Dec 10, 2011 at 11:24 PM, Mario Splivalo wrote: > I

[SQL] Subselects to Joins? Or: how to design phone calls database

2011-12-10 Thread Mario Splivalo
I have a table called 'calls' which holds 'call detail records'. Let's assume the table looks like this: CREATE TABLE cdr ( call_id serial, phone_number text ); And I have a table with country call prefixes, that looks like this: CREATE TABLE prefixes ( prefix text,

Re: [SQL] conditional FROM

2011-12-10 Thread Bèrto ëd Sèra
I guess this is what you mean: create table node( id bigint primary key); insert into node values (1); insert into node values (2); create table card( id integer primary key); insert into card values (1); insert into card values (2); create table port_activity ( portid integer primary k

Re: [SQL] conditional FROM

2011-12-10 Thread Andreas Kretschmer
Richard Klingler wrote: > This seems to do the trick... > > select arp.ip, arp.mac, arp.port2time, arp.time, arp.hostname, arp.vlan > from arp, port, node > where > arp.arp2port = port.portid and port.name = 'Fa1/0/1' > and port.port2node = node.nodeid > and node.name like 'no

Re: [SQL] conditional FROM

2011-12-10 Thread Richard Klingler
This seems to do the trick... select arp.ip, arp.mac, arp.port2time, arp.time, arp.hostname, arp.vlan from arp, port, node where arp.arp2port = port.portid and port.name = 'Fa1/0/1' and port.port2node = node.nodeid and node.name like 'nodename%' union select arp.ip, arp.ma

Re: [SQL] conditional FROM

2011-12-10 Thread David Johnston
On Dec 10, 2011, at 11:03, Richard Klingler wrote: > Good day... > > I'm trying to build a query for PGSQL 9.1 where a table has two > references with only one being used depending of the type of entry.. > > For example, the table has following simplified structure: > >portidprima

Re: [SQL] conditional FROM

2011-12-10 Thread Andreas Kretschmer
Richard Klingler wrote: > Good day... > > I'm trying to build a query for PGSQL 9.1 where a table has two > references with only one being used depending of the type of entry.. > > For example, the table has following simplified structure: > > portid primary key > port2no

[SQL] conditional FROM

2011-12-10 Thread Richard Klingler
Good day... I'm trying to build a query for PGSQL 9.1 where a table has two references with only one being used depending of the type of entry.. For example, the table has following simplified structure: portid primary key port2node index to table node por