On 11-11-2017 11:13, m_brahi...@yahoo.fr [firebird-support] wrote:
> I need to know please if it is allowed that a primary key has multiple 
> integer fields ? and only that. For example a PK that has seven integer 
> fields will it decrease the performance table ? I am using FB 3. Thanks

Of course you can do that. See 
https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-ddl-tbl.html

<tconstraint> ::=
   [CONSTRAINT constr_name]
   {   PRIMARY KEY (col_list) [<using_index>]
     | UNIQUE      (col_list) [<using_index>]
     | FOREIGN KEY (col_list)
         REFERENCES other_table [(col_list)] [<using_index>]
         [ON DELETE {NO ACTION | CASCADE | SET DEFAULT | SET NULL}]
         [ON UPDATE {NO ACTION | CASCADE | SET DEFAULT | SET NULL}]
     | CHECK (<check_condition>) }"

<col_list> ::= colname [, colname ...]

In other words, a table constraint, including a primary key, can consist 
of multiple columns (contrary to a column constraint, which is only on a 
single column).

Will it decrease performance? Of course it will, more columns means a 
larger key, which means bigger indexes, and thus a decrease in 
performance on insert and likely also on lookup. A key of seven integers 
means a key of 7 * 4 bytes = 28 bytes (+ maybe some bytes overhead, I 
keep forgetting implementation details like that). The decrease in 
performance is probably not excessive, but if the decrease in 
performance is acceptable or not is up to you.

Mark
-- 
Mark Rotteveel
  • [firebird-support... m_brahi...@yahoo.fr [firebird-support]
    • Re: [firebir... Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
    • Re: [firebir... Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
      • Re: [fir... m_brahi...@yahoo.fr [firebird-support]
        • Re: ... Dimitry Sibiryakov s...@ibphoenix.com [firebird-support]
        • Re: ... Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
          • ... m_brahi...@yahoo.fr [firebird-support]

Reply via email to