Questions tagged [one-to-one]

Refers to the quantity of an entity as a relationship to another entity. Meaning that for every instance of an entity, there is a single related instance of another entity.

Refers to the quantity of an entity as a relationship to another entity.

Meaning that for every instance of an entity, there is a single related instance of another entity.

1496 questions
-1
votes
1 answer

Is it a bad practice to have two one-to-one relationships between the same tables?

I'm designing a database and found myself in the situation described bellow. I feel like it may be a bad practice, at the same time I can't find a reason why it would be bad, aside from it looks "weird". I have limited experience in the field. I…
-1
votes
1 answer

Can't get a one-to-one relation working in Laravel

I try to get the Author of an Article, which is a One-To-One relation, but i can't get it. My foreign key author_id is in the Article. So i define in my Article Model the relation : public function author() { return…
nikubik
  • 21
  • 7
-1
votes
1 answer

How to do one-to-one inner join

I've a transaction table of purchased and returned items, and I want to match a return transaction with the transaction where that corresponding item was purchased. (Here I used the same item ID and amount in all records for…
-1
votes
1 answer

Composite key configuration in EF6 code first model

I have 3 tables, 2 tables are the principal ones and 3rd is the dependent table, following is the structure. public class Class1 { public int Id; public string Name; public Class3 Class3Property; } public class Class2 { public…
Abbas
  • 4,948
  • 31
  • 95
  • 161
-1
votes
1 answer

Doctrine: can the same attribute make a relation to two different destination attributes?

Is this OneToOne relation possible with Doctrine (in Symfony)? User Time +----------+ +-------+ | ... | | ... | | time_id |o-----+-----o| user | | | | | ... | | time2_id…
circulosmeos
  • 424
  • 1
  • 6
  • 19
-1
votes
1 answer

Relational databases/SQL: What are typical use cases for one-to-one parent-child (non-inheritance, tree-like to self/super table) relationships?

Possible Duplicate: When we need to use 1-to-1 relationship in database design? Relational databases/SQL: What are typical use cases for one-to-one parent-child (non-inheritance, tree-like to self/super table) relationships? Of course, this would…
Kawu
  • 13,647
  • 34
  • 123
  • 195
-1
votes
1 answer

Accessing one-to-one table field value in Django

I have a Django model which creates a one-to-one-field relationship with Django sites from django.contrib.sites.models import Site class SiteSettings(models.Model): site = models.OneToOneField(Site, related_name="settings",…
Rutnet
  • 1,533
  • 5
  • 26
  • 48
-1
votes
1 answer

How to connect django model using foreignkey to a unique object in another model

Please how do I connect a model to a particular object in another model using either onetoonefield or foreignkey. Example class Post(models.Model): title = models.TextField(max_length=100, null=True) caption =…
Nelson Kehinde
  • 233
  • 2
  • 10
-1
votes
1 answer

One to one relationship in EF Core throws

I am trying to define a one to one relationship ,where one side has a nullable foreign key, using EF Core and i keep getting the following error: 'The child/dependent side could not be determined for the one-to-one relationship between…
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152
-1
votes
3 answers

hasOne with null-able in laravel not working

I have a customer table which has a field called 'policy_id', where policy_id points to policy table. It is a null-able field, ie. Some customers may not have a policy. I have a relationship code like this in Customer.php public function policy()…
Harikrishnan
  • 3,664
  • 7
  • 48
  • 77
-1
votes
1 answer

I need some helping starting this discrete math using java. I'm at a complete loss

Your task is to generate all possible functions from X={a, b, c} to a set Y. Set Y contains integers 1, …, n for some integer n≥1. The value of n is provided by the user. To define a function you need to specify what it outputs for each element of…
-1
votes
2 answers

why does bidirectional mapping give infinate loop?

I am working on a project. I want to give one to one bidirectional relationship. I am getting infinate loop json. why i do not know. I refereed in internet. i could not get it clearly. please give me a solution. @GetMapping(value =…
Kumaresan Perumal
  • 1,926
  • 2
  • 29
  • 35
-1
votes
1 answer

C#: I'm getting a "MySqlException: Cannot add or update a child row: a foreign key constraint fails" when i am Adding an object in my database

Ok Guys, This is absolutely a weird one. So, i am fetching game information data from IGDB, and i am saving it in my database Whenever the user click on it to view more information about the game. Give more Details: I have an object model call…
Aaron Dasani
  • 73
  • 1
  • 1
  • 9
-1
votes
1 answer

Can anyone explain why my database would be one-to-one, one-to-many, many-to-one, or many-to-many?

I am struggling to figure out the relationship between ingredient and shampoo table. I have a join table between these tables called Shampoo_Ingredients. How do I figure out if these tables would be one-to-one, one-to-many, many-to-one, or…
Ice Wind
  • 11
  • 1
  • 5
-1
votes
2 answers

Rails one-to-one works for belongs_to but not for has_one

I have 2 tables scenarios and rental_details. The relationships are: rental_details belongs_to scenarios scenarios has_one rental_detail In the rental_details table I have the scenario_id as a column (note this is as data type INTEGER and not…
DAR_ad
  • 59
  • 1
  • 6