Skip to main content

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).

0 votes
0 answers
18 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: ...
Peter Kronenberg's user avatar
-3 votes
0 answers
58 views

Why was the ability to reference part of a composite key as a foreign key removed in MySQL 8.4.0? [closed]

In MySQL versions prior to 8.4.0, it was possible to create foreign keys that referenced only part of a composite key. Starting from MySQL 8.4.0, this functionality was restricted by default through ...
Shantanu Kudva's user avatar
0 votes
0 answers
15 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({ ...
Kaneda's user avatar
  • 132
-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 ...
ceszkraft's user avatar
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 ...
Vibekananda Champati's user avatar
-1 votes
0 answers
18 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 ...
user26017333's user avatar
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 ...
Mohamed Hassany's user avatar
-1 votes
1 answer
46 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); ...
axblount's user avatar
  • 2,644
0 votes
0 answers
29 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 ...
Andor Gunczer's user avatar
-1 votes
1 answer
28 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 ...
Hachem Benyahia's user avatar
3 votes
1 answer
69 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 ...
gagabriel's user avatar
0 votes
1 answer
35 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 ...
Sami Daniel's user avatar
0 votes
1 answer
54 views

ASP.NET Entity Framework Core - one-to-many relationship foreign key constraint blocking PUT request

I have a relationship on project and employee entities. I need have added a one-to-many relationship using Entity Framework Core (one employee have many projects, but one project has one employee). ...
salinda yasas's user avatar
0 votes
2 answers
84 views

Type Error while populating a model in Django with UniqueConstraint

I'm trying to build up my first project in Django and I'm having some issues while creating an entry into my model Prevision (including sales forecasts), which has a uniqueConstraint to ensure that ...
grover999's user avatar
  • 227
0 votes
2 answers
65 views

Create a PostgreSQL foreign key reference with default value of NULL

Consider the following table definition: CREATE TABLE containers ( id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL, parent_id SERIAL REFERENCES containers(id) ); When I INSERT INTO ...
galah92's user avatar
  • 3,823

15 30 50 per page
1
2 3 4 5
761