Questions tagged as 'chave-estrangeira'

2
answers

How to reference foreign keys in registration forms?

I am making a website from a library as a college work, which has the following table in the database: MyproblemisthatIdonotknowhowtohandlethephpcodeandtheformoffieldsthatreceiveforeignkeys.Forexample,intheloanfileIneedtoreferencethebookthati...
asked by 17.11.2015 / 01:41
3
answers

Is it worth putting two foreign keys in a table?

having the tables: Companies Customers company_id: foreign key Sales client_id: foreign key where the relations are: Companies and Clients = > 1: N Customers and Sales = > 1: N Considering that I will need to...
asked by 24.07.2018 / 22:28
1
answer

What is the foreign key (SQL) [duplicate]

As I've been researching, when it comes to pulling information from two tables in a database, you use JOIN, which has nothing foreign key in it. So what's the use of declaring a field as a foreign key? I see no point. Can someone explain me...
asked by 01.11.2017 / 12:38
1
answer

When should I create a constraint as DEFERRED?

As far as I know, creating a constraint (such as a foreign key or a check) as DEFERRED causes it to only be validated at the end of the transaction. Why is this used? And when should it not be used?     
asked by 18.03.2015 / 13:24
2
answers

How to add a foreign key to a table already created

I am a beginner in mysql and can not add a fk to a table I created. I have two tables (person, object) and I want to create a 'fk_person' in an object that receives the value of the 'id' attribute of the person. The tables are already configured...
asked by 29.01.2016 / 21:20
1
answer

Error deleting data in Mysql by Java

In the database I have three tables, where one of them holds the foreign keys. Error Displayed: Error: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Can not delete or update parent row: a foreign key constraint fail...
asked by 13.05.2018 / 21:32
1
answer

Foreign key relationship problem in PhpMyAdmin - Wamp

I have 'problem' in my Wamp, more precisely in the latest version (Wampserver 3.0.6 64 bit x64). When I create 2 tables, example: CREATE TABLE categoria( id_categoria INT NOT NULL AUTO_INCREMENT, nome VARCHAR(100) NOT NULL, PRIM...
asked by 11.08.2017 / 13:19
1
answer

Error creating MySql foreign key in phpMyAdmin?

I'm having trouble creating foreign keys in mysql through phpmyadmin . I have these tables CREATE TABLE 'cidade' ( 'idCidade' int PRIMARY KEY AUTO_INCREMENT, 'nome' varchar(25), 'Uf' CHAR(2) ); CREATE TABLE 'aeroporto' ( 'idAe...
asked by 22.05.2016 / 19:27
1
answer

Filling tables with multiple foreign keys [closed]

I have a database with the following tables: Airport Airport Cause_Cancelation (CodeCanceling PK , description) Manufacturer (ManufacturerName PK , manufacturername) Template (Template ID PK , template_name, FK...
asked by 09.08.2015 / 19:25
1
answer

Using foreign key with cascade

On my system, when deleting a publication, all comments that have id_publicacao equal that of the publication are deleted from a table named comentarios_publicacao . And I do this by simply doing a type check: if(deletar a publica...
asked by 03.05.2015 / 07:19