Questions tagged [foreign-keys]
Foreign keys are a data integrity feature of relational (and SQL) databases. A foreign key is a set of attributes in a relational table that is subject to a referential integrity constraint. The referential integrity constraint mandates that the values of the foreign key attributes in one table, A, must match with corresponding values in some specified table B (which may sometimes be the same table as A).
foreign-keys
11,403
questions
-1
votes
0
answers
13
views
Mysql error: Foreign key constraint is incorrectly formed [closed]
show create table in MariaDB 10.6.18 on Ubuntu server 22.04:
CREATE TABLE `transazioni` (
`id` char(16) NOT NULL,
`sistema` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB ...
0
votes
1
answer
19
views
Select Rows Based On Foreign Key In One-To-Many Relationships In SQL
I have a posts table and users table. And posts table has a column for author_id (foreign key). This is clearly an example of a One-To-Many relationship. I want to get all posts written by a specific ...
-2
votes
0
answers
22
views
How to set foreign key constraint order by JPA annotation? [closed]
I'm using JPA in a Spring-Boot application with JPA (jakarta.persistence Annotations).
The creation of my DB schema (hbm2ddl=create) failed with an:
⚡ Foreign key constraint is incorrectly formed ...
-1
votes
1
answer
23
views
test if any object refer to by a base model has a value specified in django orm
Well consider two models:
class School(models.Model):
name = models.TextField(default="hello world")
class Student(models.Model):
key = models.TextField(default="somedata")...
0
votes
1
answer
28
views
How to access set of objects in reverse Foreign Key in Django
I have 2 tables defined like this:
class Optimization(BaseModel):
name = models.TextField(unique=True, null=False)
is_active = models.BooleanField(null=False, default=True)
class Meta:
...
0
votes
0
answers
17
views
TypeORM - one-to-one relationship is null
First time using TypeORM, so i'm sorry if it's a very basic issue.
I have two entities: user and params:
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column({ ...
-1
votes
0
answers
17
views
Postgres relationship between inherits tables
I'm facing an issue when trying to add records to the joined_login_role table in PostgreSQL. I created a new entity tb_psychologist which inherits from tb_login, and when I create a new record in ...
0
votes
0
answers
32
views
I am trying to access a model using a foreign key in another model in the same models.py file. But I am getting a name "model_name" not defined error
class chaiVariety(models.Model):
CHAI_TYPE_CHOICE = [
('ML', 'MASALA'),
('GR', 'GINGER'),
('KL', 'KIWI'),
('PL', 'PLAIN'),
('EL', 'ELAICHI'),
]
name ...
-1
votes
0
answers
20
views
Tabulator.updateRow() with foreign key
I'm working with Delphi 10.3. On my form I create a tabulator object to display the data of my table. The fields "Datum" and "Menge" are related to the original table, and the ...
0
votes
0
answers
11
views
Error executing DDL for foreign key constraint in Hibernate with MySQL [duplicate]
I'm encountering an issue with Hibernate while trying to define a foreign key constraint for a MySQL database in my Spring Boot application.
I have three entities: Promoteur, Projet, and Bien. The ...
-1
votes
1
answer
47
views
Representing a plant with definite genus but unknown species
I want to represent plants in a database along with their genus/species. This was the schema that came to mind:
CREATE TABLE genuses (
id INTEGER PRIMARY KEY,
name TEXT UNIQUE NOT NULL);
...
0
votes
0
answers
31
views
Correct way to create a Games table with 2 player column?
There is a database with tables:
Users
Tournaments
Participants
Games
Avatar
Where, Users is the user model, avatar holds addresses to png files to set avatar for user.
Tournament holds tournament ...
-1
votes
1
answer
29
views
Foreign keys/Join columns and Join tables are not created by Doctrine in Symfony 5+
In the title I mentioned both Foreign keys and Join tables. In this case, to begin with, I am concerned with Foreign keys. But anyway a Join table is just multiple Foreign keys in a table. It seems ...
3
votes
0
answers
71
views
MySQL Workbench is accusing a MariaDB error but i don't have it installed [closed]
I'm trying to create a foreign key by the MySQL Workbench menu, but every time i try to apply it the Workbench says that the code is wrong and i should check my MariaDB manual. But i haven't installed ...
0
votes
1
answer
37
views
Entity Framework Core 8.0.6 Isn't Generating Properly Model Throught Foreing Key
I'm using Entity Framework Core using the Database Scaffold.
The project is from a social network, and initially we schematized the tables between user and follower as follows:
Logical Model of the ...