Questions tagged as 'foreign-key'

1
answer

PostgreSQL - Partial Foreign Key of Composite Primary Key

Talk to people, I need to create a structure template in which all my tables have a primary key consisting of id and version, so I can have multiple versions for each id. Problem: CREATE TABLE table1 { id BIGSERIAL,...
asked by 30.08.2018 / 15:04
1
answer

mysql workbench error [closed]

I'm trying to make a database for an academic project, I'm doing the model in the workbench and then I try to synchronize with phpmyadmin, it happens that when I do the foreign keys, the same error always happens, but I can not figure out what t...
asked by 31.12.2018 / 17:23
2
answers

I can not get a foreign key in PHPMYADMIN

I have my bank already created in phpmyadmin, there are two tables, payments and students. I've seen several tutorials and read various ways how to put a foreign key ( fk_alunos ) of student_id in my payments table, nothing works. Tabl...
asked by 18.09.2018 / 16:42
1
answer

How to insert ON DELETE and ON UPDATE

I have a MySQL database structure ready, but ALTER TABLE of FOREIGN KEY's has not specified settings for ON DELETE and ON UPDATE . How do I enter these settings now, with the tables and keys already created?   ...
asked by 31.03.2018 / 14:08
2
answers

SQL Server foreign key is giving null value when entering data in main table

Good! I am learning sql about a week ago and I have some problems understanding how foreign keys work, specifically creating inserts in an application where the foreign key is receiving null value. (and each table id is receiving its respective...
asked by 01.12.2018 / 22:44
0
answers

You have a syntax error in your SQL next to 'T FOREIGN_KEY_CHECKS = 0' on line 1 [closed]

I do not handle a lot of database, so my knowledge in sql is minimal. A friend gave me a db so I could edit and update the data of this (which seems simple), but when trying to import via phpMyAdmin the following error occurs and therefore I can...
asked by 02.11.2018 / 12:02
2
answers

Foreign key for different tables (MySql)

At the time of executing the error query stating that it is not possible to create the foreign keys, I looked in the documentation and did not understand whether this code is possible or not. create table autor( cod_autor integer, nome...
asked by 21.08.2018 / 05:24
1
answer

can not add or update a child row a foreign key constraint fails laravel

I'm having this error in my laravel system: cannot add or update a child row a foreign key constraint fails laravel It informs you that the ID does not exist, only that it exists. Even when I try to perform the insertion manually this error...
asked by 09.07.2018 / 17:20
1
answer

ERROR 1215: Can not add foreign key constraint (MySQL Workbench)

Hello, I'm trying to add a foreign key to a table but I get error 1215. I've already checked the attributes and all are compatible, the wallet field is a primary key, I do not understand why it's not possible to add the key. ALTER TABL...
asked by 18.04.2018 / 08:41
0
answers

Difficulty in doing Foreign key with two char fields in Mysql

I am not able 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 error is:    ALTER TABLE hardware...
asked by 11.12.2018 / 12:05