Most voted "foreign-key" questions
It is usually used to describe a problem or question directly related to the link between tables in databases. DO NOT USE THIS TAG simply because your table has a foreign key, but when the key is part of the core of the question.
Learn more…120 questions
Sort by count of
-
1
votes1
answer243
viewsForeign key with 3 primary keys
Hi. I have this table with 3 primary keys and I need to reference it in another table. It’s like? I was just going to put an int-type id in the monthly table to be the only primary key. But each…
-
1
votes1
answer503
viewsIs foreign key correct with null field? Postgresql
I was building a relationship entity model (MER) from a database to a rual association, it is a work for TABD matter. But I came across an atypical situation for me, a 0.n to 0.1 relationship. As…
-
1
votes2
answers1607
viewsI can not put foreign key in PHPMYADMIN
I have my bank already created in phpmyadmin, are two tables, payments and students. I have seen several tutorials and read various ways of how to put a foreign key (fk_alunos) id_students in my…
-
1
votes0
answers302
viewsYou have a syntax error in your SQL next to’T FOREGN_KEY_CHECKS=0' in line 1
I don’t know much about databases, so my knowledge of sql is minimal. A friend passed me a db so that I could edit and update the data of this (something that seems simple to me), but when trying to…
-
1
votes2
answers210
viewsSQL Server foreign key is giving null value when entering data in the main table
Good! I’ve been learning sql for about a week now and I’m having some problems understanding how Foreign Keys work, specifically by creating Inserts in an application where Foreign key(foreign key)…
-
1
votes2
answers68
viewsForeign Key (foreign key) referencing utility in the database
I have a question in jobs with databases. Exemplifying, as the image below: Well, I know I should include in the table agendar_consulta the user who needs a consultation and the doctor who will…
-
1
votes1
answer144
viewsHow to do this kind of relationship in Django?
I have the models "Subscriber": class Assinante(models.Model): name = models.CharField("Nome", max_length=32, null=False, blank=True) phone = models.CharField("Telefone", max_length=11, null=True,…
-
1
votes1
answer148
viewsIs there a performance problem in using many foreign keys (FK)? If so, is it bad to have foreign attributes without being FK?
To clarify how much can be "many foreign keys", I will explain the context: In a system, I want to store by whom a certain record has been edited ( updatedBy) or raised (createdBy). This can happen…
-
1
votes1
answer168
viewsError adding foreign key, how to proceed?
I am trying to reference the column id of a table in another table in my database, but I am told an error that is not very specific. The engine being used is Innodb and the database is in Mysql. It…
-
1
votes1
answer75
viewsReturn name instead of foreign key ID
I’m developing a Python system and wanted to return data from the specific database, only instead of the foreign key id I wanted to return the name of that person. The creation of tables:…
-
1
votes0
answers22
viewsUse 1 field with foreign key to identify multiple tables
What I would like is: Create a log table In the Logs table have a field ex: FK_ID, where this field would identify any data from any table. Because the table logs will have the logs of all tables in…
-
0
votes1
answer583
viewsForeign keys in database modeling
A primary key can have two foreign keys in different tables? For example:
-
0
votes2
answers176
viewsAs foreign key reference alternating tables
I have a City, State and Country Database. But I want to add Cities to my table and it doesn’t always contain a state to be referenced. However, every city is located in a country. My question is:…
-
0
votes1
answer59
viewsTags in a table for each?
I have the table "news"and I will make a system of tags, these tags will have to have a table for each or just a table ?
-
0
votes1
answer342
viewsCircular Foreign Key
I often see database modeled so that foreign keys close a circular reference, to exemplify I used a model with cidade,bairro and cliente. Follows the ER model: I understand that in this format,…
database software-architecture relational-model foreign-keyasked 7 years, 3 months ago Rovann Linhalis 14,881 -
0
votes0
answers304
viewsDuplicate values in column that is foreign key
When trying to insert a new data into a given table (employee), I have a column called "manager ID" which is FK from the table itself "employee". During the registration I send the ID of another…
-
0
votes1
answer362
viewscannot add or update a Child Row a Foreign key Constraint fails Laravel
Guys, I have this error in my system: cannot add or update a child row a foreign key constraint fails laravel It informs that the ID does not exist, only that it exists. Even when I try to manually…
-
0
votes0
answers668
viewslocal.ERROR: SQLSTATE[23000]: Integrity Constraint Violation: 1452
Expensive, You can help me with this mistake: local.ERROR: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails…
-
0
votes0
answers554
viewsUsing Foreignkey to save to BD Django
I cannot do Data’s relationship with Teacher, I have to save Teacher and pass his id to Data foreign key and save, when I execute the code id is not passed Forms.py class…
-
0
votes1
answer278
viewsError adding ON DELETE CASCADE two Foreign Keys from the same table
I am deploying a table to save the messages, in this table I have source users (sender) and destination user(recipient) from the same table: user. When trying to add the constraints to the message…
-
0
votes1
answer31
viewsWhy don’t you create Foreign Key?
I ran the commands in Mysql Workbench, but did not create the Foreign Key connection, which is wrong in querys? create table Computador ( ID int NOT NULL primary key AUTO_INCREMENT, Nome varchar(45)…
mysql database mysql-workbench foreign-key primary-keyasked 5 years, 5 months ago Felippe Jaqson Chemello 3 -
0
votes1
answer85
viewscreation of a composite KP
I have two tables: tbl1 and tbl2. In the tbl1 I own a pk and in the tbl2 I own a FK which refers to PK of tbl1 and a pk. With this, I can make a pk composed for the tbl2 with these 2 fields ? EX:…
-
0
votes2
answers791
viewsDjango Models - Foreignkey how to call method within the class by Admin
Good afternoon Galera, My situation is as follows. I have a nested class structure for a solution and I’m stuck in the following situation: I have these class structure: class…
-
0
votes1
answer123
viewsError in adding foreign key
I am having trouble creating a foreign key. I am doing the project in Mysql Workbench. The generated SQL script is as follows: DROP TABLE IF EXISTS `comercio`.`cliente` ; CREATE TABLE IF NOT EXISTS…
-
0
votes0
answers79
viewsInvalid value: For input string:
Error while updating, the value of the field must be the FK code referring to a foreign key, in the form INPUT comes out the value br.com.tkcsapcd.model.bean.Projectionicio@7adacc20, no…
-
0
votes0
answers319
viewsTable does not display name relative to PHP Foreign Key Table
I need to make a query in the table and return to Date in first column, Name (FK) in the second column, and other FK-dependent data in their respective columns. I have tried the various forms of…
-
0
votes0
answers25
viewserror in foreign key creation
I’m studying bank and my foreign key does not create, I know I’m doing something wrong, but I can not understand what there is. these are the tablets I want to call' create table tb_cardapio(…
-
0
votes3
answers118
viewsLogic for using foreign key - a user’s notes
I am aware of a problem in the use of foreign key. I cannot find the logic for a system: The problem: the user gives a note for each question, each one being a table field, and at the end the…
-
0
votes1
answer25
viewsforeign 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…
-
0
votes1
answer2169
viewsBest way to register two foreign keys in a table
I have 3 tables, being them: personal, pesso_juridical and addressee. Both the tebela pessoa_fisica, as for tebela pessoa_juridica use the table endereco. I would like to add two foreign keys in the…
-
0
votes1
answer1574
viewsTrying to get Property 'name' of non-object Laravel Eloquent Error when pulling foreign key data
I am trying to use relationships to show data on screen but I get the following error: Trying to get Property 'name' of non-object In this command…
laravel laravel-eloquent laravel-blade foreign-key modelasked 6 years, 9 months ago Gabriel Alves 41 -
0
votes1
answer140
viewsProblem creating foreign key in Entity
I’m trying to create a Primary key composed, until everything well. With this I need to make a Foreign key composed. I have more or less the following scenario (it is a hypothetical scenario but…
-
0
votes0
answers70
viewsError 1215 Mysql
First of all, I would like to say that I have checked several questions about this here and no solution has worked. I am giving alter table in the working table to add two Foreign Keys...one of them…
-
0
votes1
answer811
viewsERROR 1215: Cannot add Foreign key Constraint (Mysql Workbench)
Hello I am trying to add a foreign key to a table but I get error 1215. I have already checked the attributes and all are compatible, the portfolio field is a primary key, I do not understand why it…
-
0
votes2
answers215
viewsProblem inserting data into a table containing foreign keys
Hello, everybody! Well... here’s my problem: I have a Mysql database that has 3 tables (Client, Event, Equipment). The event table has two foreign keys, the first of them referencing the id of the…
-
0
votes2
answers1251
viewsForeign key for different tables (Mysql)
When executing the error query stating that it is not possible to create the Foreign Keys, I looked in the documentation and did not understand right if this code is possible or not. create table…
-
0
votes1
answer287
viewsInsertion of foreign keys by the kettle
I need to load some data that are in spreadsheets in a relational database, but I have been facing some challenges regarding the insertion of foreign keys. In these images you can see that I first…
-
0
votes0
answers285
viewsCreate a Foreign key with two varchar fields
I’m finding it very difficult to create a foreign key between two tables, whose type is varchar: ALTER TABLE netmap ADD CONSTRAINT fk_IP FOREIGN KEY ( IP ) REFERENCES ipvalidos (IPS); The mistake…
-
0
votes1
answer107
viewsDoubt with foreign key
To register the matches of a football championship the following tables were defined: Time ( id int primary key, nome char(20), pontos int, nroVitorias, golsMarcados int, golsSofridos int ) Jogo (…
-
0
votes0
answers105
viewsDifficulty making Foreign key with two char fields in Mysql
I am unable to create a Foreign key between two tables, whose type is CHAR: ALTER TABLE hardware ADD CONSTRAINT fk_INC_LOCALIDADE FOREIGN KEY ( INC_LOCALIDADE ) REFERENCES localidade (INC); The…
-
0
votes3
answers131
viewsHow to relate questions to a question
This question is not directly linked to code, but and the basic part of my project, I am currently divided into 2 options (which I will describe in detail below). Currently the UML is this way,…
-
0
votes2
answers542
viewsDjango - Questions with Foreignkey
I’m trying to make a form in Django, in which I will save the versions of the projects. Exemplo: Empresa x Projeto 1 Versão 1 Versão 2 Projeto 2 Versão 1 Empresa Y Projeto 1a Versão 1 ... It happens…
-
0
votes0
answers30
viewsDefine foreign key between tables
I need to make a Mysql database, Escola, with entities aluno, professor and disciplina, linked via foreign key. I made mine script, but it’s making a mistake. Could you help me? Follow what I did:…
-
0
votes1
answer49
viewsProblems declaring a foreign key using Ibernate
Hello.I need help declaring a foreign key using Hibernate in a project with JSF, I consulted several websites and handouts and could not find a solution. Where I have the classes already mapped…
-
0
votes1
answer100
viewsMultiple references to a FK in the same column/row
Good afternoon colleagues, I would like a help to model a comic, the doubt is as follows: Is it possible to have more than one FK ID on a tuple? EX: tabela teste1 |id_teste1|id_teste2|teste|teste01|…
-
0
votes0
answers41
viewsForeign key in phpMyAdmin brings duplicate record
Problem I have a table called "entidades_category-script" (let’s call 'A') that has the following keys: It turns out that it references another table called entidades_category-script-type (let’s…
-
0
votes0
answers213
views#1215 - You cannot add a foreign key constraint
Good night, I can’t figure out why error #1215. I’m a few hours away and still can’t figure it out. Can anyone help me? Thanks! CREATE TABLE IF NOT EXISTS `imovelweb`.`cadastro` ( `id_cadastro` INT…
-
0
votes1
answer404
viewsForeignkey of two tables in Django
Fala, Povo! I have the following problem: I am developing a site for a store that also performs services. Then I have the Shopping and Sales Table (Saleorbuy) and the Services Table (Service) For…
-
0
votes0
answers47
viewsError in creating FK
Operation failed: There was an error while Applying the SQL script to the database. Executing: ALTER TABLE prouni.ies ADD INDEX local_idx (local ASC) VISIBLE; ; ALTER TABLE prouni.ies ADD CONSTRAINT…
-
0
votes0
answers28
viewsERROR 1215 (HY000): Cannot add Foreign key Constraint (MYSQL)
Good evening, you guys, I am trying to create a table with two foreign keys, but is giving the error of Cannot add Foreign key Constraint, I do not understand why, follows below the SQL statement.…