[SQL] Question about index/constraint definition in a table

2013-10-09 Thread JORGE MALDONADO
t adding a constraint on these 2 fields is the solution. My question: Is this the correct way to go? Respectfully, Jorge Maldonado

Re: [SQL] Unique index VS unique constraint

2013-10-05 Thread JORGE MALDONADO
be the best decision and why? Regards, Jorge Maldonado On Fri, Oct 4, 2013 at 5:38 PM, David Johnston wrote: > JORGE MALDONADO wrote > > I have search for information about the difference between "unique index" > > and "unique constraint" in PostgreSQL withou

Re: [SQL] Advice on defining indexes

2013-10-04 Thread JORGE MALDONADO
y key" is "src_id + src_date". One "src_id" can exist for several "src_date". --- Table Lists --- 1. lst_id 2. lst_source (points to src_id) 3. lst_date 4. Other fields . . . Here, the "foreign key" is "lst

[SQL] Advice on defining indexes

2013-10-04 Thread JORGE MALDONADO
on because our database has additional tables with the same characteristics and maybe there would be many indexes. With respect, Jorge Maldonado

[SQL] Unique index VS unique constraint

2013-10-04 Thread JORGE MALDONADO
I have search for information about the difference between "unique index" and "unique constraint" in PostgreSQL without getting to a specific answer, so I kindly ask for an explanation that helps me clarify such concept. Respectfully, Jorge Maldonado

[SQL] Criteria to define indexes

2013-07-26 Thread JORGE MALDONADO
very possibility because it will have an impact on performance due to index maintenance. What would be a good way to define indexes in a case like this? With respect, Jorge Maldonado

[SQL] Unique index and unique constraint

2013-07-26 Thread JORGE MALDONADO
I guess I am understanding that it is possible to set a unique index or a unique constraint in a table, but I cannot fully understand the difference, even though I have Google some articles about it. I will very much appreciate any guidance. Respectfully, Jorge Maldonado

Re: [SQL] Advice on key design

2013-07-23 Thread JORGE MALDONADO
>> In your case it would be lpp_id as PK, and >> lpp_person_id,lpp_language_id as unique constraint >> >> Thanks, >> Anton Is there a reason to do it the way you suggest? Regards, Jorge Maldonado On Tue, Jul 23, 2013 at 5:02 PM, Anton Gavazuk wrote: > Hi Jo

[SQL] Advice on key design

2013-07-23 Thread JORGE MALDONADO
ial. My question is: what should I configure as the primary key, "lpp_person_id + lpp_language_id" or "lpp_id"? Is the role of a primary key different from that of a unique index? With respect, Jorge Maldonado

[SQL] Select clause in JOIN statement

2013-06-13 Thread JORGE MALDONADO
Is it valid to specify a SELECT statement as part of a JOIN clause? For example: SELECT table1.f1, table1.f2 FROM table1 INNER JOIN (SELECT table2.f1, table2.f2 FROM table2) table_aux ON table1.f1 = table_aux.f1 Respectfully, Jorge Maldonado

[SQL] Advice with an insert query

2013-06-07 Thread JORGE MALDONADO
I need to insert records into a table where one value is fixed and 2 values come from a SELECT query, something like the following example: INSERT INTO table1 fld1, fld2, fl3 VALUES value1, (SELECT fldx, fldy FROM table2) Is this valid? Respectfully, Jorge Maldonado

[SQL] Advice on re-writing a SELECT query.

2013-05-25 Thread JORGE MALDONADO
as follows? FROM listas_pre_titulos INNER JOIN temp_lista_titulos ON (listas_pre_titulos.lpt_titulo, listas_pre_titulos.tmd_album, listas_pre_titulos.lpt_fuente) NOT IN (temp_lista_titulos.tmt_titulo, temp_lista_titulos.tmt_album, temp_lista_titulos.tmt_fuente) WHERE listas_pre_titulos.lpt_tipo = 3 W

Re: [SQL] Select statement with except clause

2013-05-24 Thread JORGE MALDONADO
results. With respect, Jorge Maldonado On Thu, May 23, 2013 at 1:36 PM, David Johnston wrote: > JORGE MALDONADO wrote > > How does the EXCEPT work? Do fields should be identical? > > I need the difference to be on the first 3 fields. > > Except operates over the entire tuple

[SQL] Select statement with except clause

2013-05-23 Thread JORGE MALDONADO
he EXCEPT work? Do fields should be identical? I need the difference to be on the first 3 fields. Respectfully, Jorge Maldonado

[SQL] Order of execution

2013-05-05 Thread JORGE MALDONADO
records will be updated. Does field1 updates first, then field2 and, lastly, field3? or What is the order in which updates are executed? If I need fields to be updated in a certain order, should I use 3 UPDATE commands instead? Respectfully, Jorge Maldonado

[SQL] Table indexes in a SELECT with JOIN´s

2013-04-20 Thread JORGE MALDONADO
song_name Respectfully, Jorge Maldonado

[SQL] Advice for index design

2013-04-10 Thread JORGE MALDONADO
. Maybe compound indexes is better. I will very much appreciate your advice. Respectfully, Jorge Maldonado

[SQL] UPDATE query with variable number of OR conditions in WHERE

2013-03-14 Thread JORGE MALDONADO
ry using a programming language and, after that, I execute it. Is this a good approach to build such a query? Respectfully, Jorge Maldonado

[SQL] Conditional expression in an UPDATE statement

2013-02-06 Thread JORGE MALDONADO
Can I use a conditional expression in an UPDATE query like this: UPDATE table_1 SET field_1 = CASE WHEN (condition) THEN (COALESCE(query_1, -1)) ELSE (COALESCE(query_1, -2)) END With respect, Jorge Maldonado

Re: [SQL] Setting a default value for a select statement without results

2013-02-06 Thread JORGE MALDONADO
This solution gave me the result I need, but it seems the process takes longer when COALESCE is added. What do you mean with the comment of "and you are happy with its performance" ? Does it have to do with performance? Regards, Jorge Maldonado On Tue, Feb 5, 2013 at 10:07 PM, J

[SQL] Setting a default value for a select statement without results

2013-02-05 Thread JORGE MALDONADO
I have an UPDATE query with the following general structure: UPDATE table1 SET (SELECT field FROM table2 WHERE conditions ORDER BY order_field LIMIT 1) Is it possible to assign a default value in case no results are returned by the SELECT statement? Respectfully, Jorge Maldonado

[SQL] Query execution based on a condition

2012-12-29 Thread JORGE MALDONADO
condition UNION SELECT fields FROM tblTable WHERE condition UNION SELECT fields FROM tblTable WHERE condition Respectfully, Jorge Maldonado

[SQL] Help with a select statement design

2012-12-28 Thread JORGE MALDONADO
from id3 and price 3) id, price (record that comes from id4 and price 4) I will very much appreciate any suggestion. Respectfully, Jorge Maldonado

[SQL] Joining several rows into only one

2012-11-28 Thread JORGE MALDONADO
than one artist, and this is fine. What I would like to do is NOT to get several rows, one for each different artist, but to join all of the artists in one column and display only one row. Is this possible? Respectfully, Jorge Maldonado

Re: [SQL] Query with LIMIT clause

2012-09-09 Thread JORGE MALDONADO
is the choice, or one index composed of both initial and final date? Regards, Jorge Maldonado On Sun, Sep 9, 2012 at 12:45 PM, David Johnston wrote: > From: pgsql-sql-ow...@postgresql.org [mailto: > pgsql-sql-ow...@postgresql.org] > On Behalf Of JORGE MALDONADO > Sent: Sunday, Septem

[SQL] Query with LIMIT clause

2012-09-09 Thread JORGE MALDONADO
tried an ORDEY BY DESC but the result is the same. I will very much appreciate your comments. Respectfully, Jorge Maldonado

[SQL] How to html-decode a html-encoded field

2012-04-10 Thread JORGE MALDONADO
this table and get the values HTML DECODED and I wonder if there is a function that I can include in such a statement for this purpose, for example "SELECT htmldecode(fld1) FROM table1". I will appreciate anu comments about my issue. Respectfully, Jorge Maldonado

[SQL] Duplicate information in parent and child tables

2012-04-03 Thread JORGE MALDONADO
I have a parent table and a child table. In order to detect duplicate information I need to consider both tables. This means that a "duplicate record" consists of one parent record and one or more child records. Is there any standard approach to solve this issue? Respectfully, Jorge Maldonado