Questions tagged as 'chave-estrangeira'

1
answer

Should I use foreign_key in both has_many and belongs_to?

I have two models. Office and Employee. Employee has office_id as foreign key. So which one is correct? class Office < ActiveRecord::Base has_many :employees, foreign_key: 'office_id' end class Employee < ActiveRecord::Base belongs...
asked by 04.03.2016 / 19:53
1
answer

Insert for foreign keys SQL

I'm learning a programming language and I set out to develop a budgeting program. My first hurdle is being to add the values of the primary keys in the foreign keys of the respective tables. This code below works well for this, but after copying...
asked by 15.11.2015 / 18:38
1
answer

Questions about the datagridview

Hello, I have some questions about the datagridview of visual studio, I would like to know how I can change the values of the columns that appear to the foreign key of the sql server by the value of the table that is referenced to the primary key...
asked by 10.07.2015 / 02:56
0
answers

Is correct foreign key with null field? PostgreSQL

I was building an entity relationship model (MER) from a database for a rual association, it's a work for TABD stuff. But I came across an atypical situation for me, a relationship 0, n for 0.1. As you can see in the figure. It turns out t...
asked by 13.08.2018 / 05:15
0
answers

How to put an attribute as foreign and primary key at the same time?

I use MySQL Workbench and I have to represent a DER in the physical model. I come across a specialization: TABELA_PESSOA cpf* nome sexo TABELA_CLIENTE cpf_pessoa* email...
asked by 21.10.2017 / 20:40
2
answers

Code 1215 in SQL "Can not add foreign key constraint"

When creating this code always comes the error:    1215 "Can not add foreign key constraint" I have tried everything, checked the foreign key constraints and nothing. Can someone help me? create table alunodisc ( codigodisc int,...
asked by 22.10.2017 / 13:29
0
answers

Doubt in the order of the table fields in case of foreign keys of less importance hierarchically

Hello, fellow programmers! I'm just a beginner in the programming world and in StackOverflow and need to ask a question! I'm making some adjustments to a database I'm working on after finding great tabs for standardizing fields and tables. As...
asked by 26.05.2017 / 15:24
0
answers

Hibernate query (HQL) in Java with foreign key ... ERROR!

I need help with my code, I have two tables: -CDF (Employee Registry) CREATE TABLE public.cdf( ativo character varying(1) COLLATE pg_catalog."default", reg integer NOT NULL, nome character varying(30) COLLATE pg_catalog."default" N...
asked by 23.03.2017 / 22:12
0
answers

Data entry - Foreign keys in Java

I'm having a bit of trouble implementing foreign keys in my project. DAOProduto.java public class DAOProdutoImpl implements DAOProduto { private GerenciadorDeConexao gc; public DAOProdutoImpl(){ gc = GerenciadorDeConexaoMysql.getInsta...
asked by 01.12.2015 / 16:31
1
answer

foreign key problems when selecting items

Well, I'm trying to select all items from two separate listings, but without success, I'm using:    Query select t*, d.id as id_discvinculada from textos as t join disciplinas as d on t.id_discvinculada = d.id    Function function li...
asked by 10.07.2017 / 21:40