Questions tagged as 'chave-estrangeira'

2
answers

Is it good practice to keep foreign key columns redundant?

Consider that we have the models A , B , C and D , each referencing the previous one, ie A has many B s, B has many C if C has many D s: No redundancy A | id | ... | ------...
asked by 23.06.2014 / 19:56
2
answers

Mounting database, how do I make this relationship?

I am putting together the EER diagram of an ERP. Virtually all tables have a column named "id_company" that relates to the "companies" table. This is because the user can manage one or more company, and I want every record of the other tables to...
asked by 04.02.2015 / 21:30
1
answer

MySQL JOIN with or without foreign key?

What is the difference between relating 2 tables using and not using a foreign key? Regarding performance, is it advisable to use foreign key to make the relationship? In what situation would it be indispensable and in what situation would...
asked by 28.06.2015 / 06:57
2
answers

Foreign Key does not respect referential integrity

I'm trying to join tables and add a chave estrangeira , so that for example, a purchase table has referência of id of the buyers table. I did as follows: alter table compras add foreign key (compradores_id) references co...
asked by 15.12.2016 / 13:24
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

Referencing the table itself in Mysql is correct?

I'm working on a system where the previous programmer has structured a certain table of posts referencing itself (to be able to identify what would be the comment of the post) More or less like this: Posts -- id -- post_id => Referencia...
asked by 08.01.2015 / 17:54
3
answers

How do I work with tests and fixtures on a database that contains foreign key constraints in Rails?

I am using RubyOnRails 4.1 and PostgreSQL database and I use gem foreigner to create foreign key constraints in the bank. It turns out that this makes some tasks difficult with fixtures . When I try to run a test: spring rake test I...
asked by 21.08.2014 / 13:43
1
answer

Model-relational in firebird with C #

Developing a small C # project with Visual Studio, firebird and ibexpert. With the tables NOT RELATIONSHIP I run everything right. But I need to relate CLIENTE 1: N to BONUS E SAIDA . I am not able to develop the following re...
asked by 23.09.2014 / 05:02
1
answer

Error creating foreign key in MariaDB

When trying to create the toy table, the following error appears:    ERROR 1005 (HY000): Can not create table brinquedos . brinquedo   (errno: 150 "Foreign key constraint is incorrectly formed") Follow the code: CREATE TABL...
asked by 30.12.2016 / 16:33
4
answers

PostgreSQL - Remove tuple referenced by another table

I have a problem that I did not find anything on Google (maybe I did not know how to ask him) Imagine the following: I have 11 tables, one call tbl_pai and 10 other calls tbl_filha1 , tbl_filha2 , tbl_fila / em>. / li>...
asked by 27.01.2016 / 14:05