Questions tagged as 'chave-composta'

3
answers

When is the recommended use of composite primary key?

   A simple key is associated with a single value, or field, of the record. A compound key corresponds to the combination of two or more keys, and may be necessary to eliminate ambiguity, forming a unique identifier. ( Wikipedia ) Let's...
asked by 15.05.2014 / 14:21
2
answers

What is the best way to create a conditional foreign key constraint?

In some cases, it is interesting to create a conditional foreign key reference , that is, it does not allow you to reference all the records in another table, but only those that assume a condition. For example: If you have a people table...
asked by 21.11.2014 / 19:12
2
answers

How to make an auto increment ID relative to another field in PostgreSQL "PostgreSQL"? [duplicate]

id_empresa | id_pedido 1 | 1 1 | 2 1 | 3 1 | 4 2 | 1 2 | 2 3 | 1 I already thought of doing only one trigger and procedure for all the tables, but I do not know how to...
asked by 03.12.2018 / 14:07
0
answers

Hibernate does not consider field to insert

I have a class Cliente that has composite key: @Entity @Table(name = "Clientes") @IdClass(ClientePK.class) public class Cliente implements Serializable { //@EmbeddedId //private ClientePK clientePK; @Id @Column(name = "...
asked by 24.10.2018 / 16:32
1
answer

Table with Compound Key without repeating

How do I make a table with a compound key, but I can not repeat the combination of values. I want to store FRIENDS , using a syntax similar to this: tb_amizades id_usuario_um id_usuario_dois SELECT * FROM tb_amizades WHERE id_...
asked by 30.10.2017 / 15:10
1
answer

Foreign key with 3 primary keys

Hi. I have this table with 3 primary keys and I need to reference it in another table. How? I was going to just put an id of type int in the monthly fee table to be the only primary key. But each monthly fee must be unique to a contract and h...
asked by 05.07.2018 / 04:56
0
answers

Auto increment ID relative to another field

Some time ago I was looking for something to solve this problem that I have encountered in other systems that I have developed, I would like to know a solution for how to do an auto increment id, but an auto increment related to another field, f...
asked by 23.08.2016 / 13:30
1
answer

Laravel / Eloquent: How to create a primary key composed of two foreign keys?

I am creating a simple system for school management and I will have a table named 'student_class', where the primary key must be composed of the student id and class id, which are foreign keys of the 'student' and 'class' tables respectively . I...
asked by 06.08.2017 / 19:11
1
answer

Fluid mapping composite nhibernate key with firebird bank

I am having difficulty in composing primary key mapping using fluent nhibernate. I have the following class: public class NotaItem { public NotaItem(){} public virtual int Id { get; set; } //chave primaria public virtual Int16 Nu...
asked by 02.02.2016 / 18:15
0
answers

Composite Key (Product Code and Product Lot) how to do it?

Good afternoon, I started a little in ACCCESS, and I am making a table that should include the product code and its production batch, as well as other data such as description, quantity, etc. I would like to do this so that the product code a...
asked by 24.05.2018 / 19:54