one-to-one

One to One database relation?

In my free time I started writing a small multiplayer game with a database backend. I was looking to separate player login information from other in game information (inventory, stats, and status) and a friend brought up this might not be the best idea. Would it be better to lump everything together in one table? ...

NHibernate one-to-one mapping where second table data can be null.

I have an existing database with the table Transactions in it. I have added a new table called TransactionSequence where each transaction will ultimately have only one record. We are using the sequence table to count transactions for a given account. I have mapped this as a one-to-one mapping where TransactionSequence has a primary key o...

A Proper One-to-One Mapping Table

I want to make a table that simply has two integer columns to serve as a mapping table between two different data sets and I wish to put the correct constraints on it. I initially set the two columns as a compound primary key, but then realized that represents a many to many, only keeping duplicate many to many mappings from occurring. ...

Is there ever a time where using a database 1:1 relationship makes sense?

I was thinking the other day on normalization, and it occurred to me, I cannot think of a time where there should be a 1:1 relationship in a database. Name:SSN? I'd have them in the same table PersonID:AddressID? Again, same table. I can come up with a zillion examples of 1:many or many:many (with appropriate intermediate tables), bu...

Basic Rails Question: One-to-One relationships

My comprehension of RoR is sadly lacking. I have three one-to-one relationships that I want to maintain in one view. I have the following models: class Ood< ActiveRecord::Base has_one :female_trait has_one :male_trait end class Female_Trait < ActiveRecord::Base belongs_to :ood end class Male_Trait < ActiveRecord::Base belon...

NHibernate, one-to-one mapping, cascade insert

I have a one-to-one relationship between a Company class and a CompanySettings class. When I create a new Company object, (a CompanySettings object is created in Company's constructor for its Settings property), and then SaveOrUpdate(session, companyObject) I expect the INSERT to cascade from the Company to the CompanySettings. Howeve...

Lazy One-to-One using Proxy not working

I've got a one-to-one relation between a dealer and a seller which should be lazy using a proxy. For the side on which the foreign key is defined (the seller, references the dealer), this works fine. But it doesn't work from the other side - the seller is always loaded eagerly. I set constrained="true" as described in "Some explanations ...

A question about storing data that should have been in the same table

The software I'm working with has 2 tables, lead and customer. When we sell our product to someone, a record is created in the customer table with data from the lead table (as well as some additional data). Currently there is no relationship between the two tables. The best that exists now is the lead object has a function that will do ...

How to lazy load a one-to-one composition via hql

If have an entity A with a bidirectional one-or-zero-to-one mapping with entity B. The mapping is as follows: <class name="EntityA" table="TABLE_A" mutable="true" lazy="true"> <id name="idA" type="long" column="pk_a" unsaved-value="null"> <generator class="sequence"> <param name="sequence">pk_a_seq</param> ...

Hibernate getting on my nerve. Delete question on One To One relationship.

Hi all, I have these classes. @Entity @Table(name ="a") class A{ private Integer aId; private B b; @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id_a") public Integer getAId() { return aId; } @OneToOne(mappedBy = "a", cascade={CascadeType.ALL}) public B getB() { return b; } } @Entity @...

DataMapper has_one problem

Hello. I`m having trouble associating models in DataMapper. Its really simple, but i just can get the idea. So, i have 2 tables: 1. Books -> id -> title -> publisher_id 2. Publishers -> id -> title The classes: class Book property :id, Serial property :title, String property :publisher_id, Integer end class Publisher prope...

How to do Insert New Result At the same Table by one-to-one Relation using Fluent

At Same table I Have 2 Objects: Product, ProductDetail public class Product { public virtual int ID {get;set;} public virtual string Name {get;set;} public virtual Detail {get;set;} } public class ProductDetail { public virtual int ID {get;set;} public virtual string Title {get;set;} public virtual Product P...

Person -> Details with lazy loading

Yesterday I`ve asked a question Person -> Details database structure Now I need to make a NHibernate mapping, where the details are lazy loaded. so my person map is: <class name="Employee" table="Employee"> <id name="Id" column="EmployeeId"> <generator class="native" /> </id> <property name="FName" column="FName"/> ...

Correct NHibernate mapping for a specific scenario (one-to-many/one-to-one)

I had a following structure: User has many books in his history which was translated to the following class User { ICollection<Book> History } // C# User -> UserHistory (UserId, BookId) -> Book // DB Now I want to add a date to the history, creating the following class structure: class User { ICollection<Read> History } ...

hibernate subclass one to one mapping

hi all, i got a complicate mapping, i think it suppose to work...but why it compile A.d column is not existed??? public abstract Class A { private Integer Id; .. ... } public Class SubA extend A { private D d; } public Class D { private SubA subA; } A.hbm.xml <class name="A" table="A" abstract="true"/> ... <subclass ...

Castle ActiveRecord: one-to-one

While playing around with one-to-one associations in castle activerecord I stumbled upon the following problem: I'm trying to model a one-to-one relationship (user-userprofile in this case). I already learned that this may not be a best practice, but let's ignore that for a moment (I'm still trying to understand what's going on). [Acti...

Castle ActiveRecord OneToOne and JoinedBase/Key all together, No SQL Relations Created

I'd like to model the following relationship. [JoinedBase] MasterForm{ Guid MasterFormId {get;set;} /* some base properties like modifiedBy etc... */ } [ActiveRecord] TerminationForm{ [PrmaryKey(Foreign)] Guid MasterFormId {get; set;} /* Some more properties specific to terminations */ } [ActiveRecord("TermStaffing")] ...

Hibernate one-to-one entity association with shared PK between 3 classes

I want a unidirectional one-to-one relationship between objects of 3 java classes: Person to Heart, and Person to Liver. I want the objects to share the same PK i.e. every person has a corresponding heart and liver, where person.person_id = heart.heart_id = liver.liver_id. I do not want to merge the 3 tables into 1 because each has loads...

Linq 2 SQL One to Zero or One relationship possible?

Is it possible to create a one to zero or one relationship in Linq2SQL? My understanding is that to create a one to one relationship you create a FK relationship on the PK of each table. But you cannot make the PK nullable, so I don't see how to make a one to zero or one relationship work? I'm using the designer to automatically crea...

How should I build this Django model to do what I want

This is what I had before (but realized that you can't obviously do it in this order: class MasterAdmin(models.Model): """ A permanent admin (one per Account) that shouldn't be deleted. """ admin = models.OneToOneField(AccountAdmin) class Account(models.Model): """ A top-level account in the system. """ ...