one-to-many

Basic Database design. Use a another table or colum

I have a table that holds information about a particular Object, Say Item and has columns ItemID, ItemName, price, ItemListingType.....LastOrderDate One of the bits of information, ItemListingType could be one of 10 different types such as: private, gov, non-gov, business... etc (strings) and could be extended to more types in future....

NHibernate: Unable to cast PersistentBag...

This question was asked back in October (unable-to-cast-object-of-type-nhibernate-collection-generic-persistentgenericbag). Basically, I have a POCO that has a one-to-many relationship modeled by a List<ChildType>. When you try to get it/save it in NHibernate you get a type cast exception saying it's trying to cast from NHibernate.Colle...

LINQ One to Many, 3 levels Deep Question

I am trying to figure out what I am doing wrong in the below LINQ statement. It doesn't like the third SELECT. It finds tblAddresse.tblAdminCounty in Intelisense when I am typing the query but when I type the SELECT after it it freaks. Does it have to do with how tblAddress and tblAdminCounty are related? I would have thought that ...

One-to-many relationship using same SQL table

EDIT: Because my brain failed, I actually meant a one to many, not a many-to-many as I first wrote this. This makes it a bit easier :) I'm in the process of designing my database and one of the Tables (Tasks), needs to be able to have a one-to-many relationship with itself. This is because a task can have a number of sub-tasks that have...

(Fluent)NHibernate: Mapping an IDictionary<MappedClass, MyEnum>

I've found a number of posts about this but none seem to help me directly. Also there seems to be confusion about solutions working or not working during different stages of FluentNHibernate's development. I have the following classes: public class MappedClass { ... } public enum MyEnum { One, Two } public class Foo { ...

NHibernate one-to-many different between SQLITE and Oracle

I have a one-to-many mapping that works in sql lite, but then blows up in Oracle. If I make a slight change, it will work in Oracle, but not in SQLITE. Here's my mappings: This works in SQL Lite <many-to-one class="NHibernate.Spike.Data.Entities.ClientRecord, NHibernate.Spike.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nul...

Android: SQLite one-to-many design

Anyone has good advise on how to implement one-to-many mapping for SQLite using ContentProvider? If you look at Uri ContentProvider#insert(Uri, ContentValues) you can see that it has ContentValues param that contains data to insert. The problem is that in its current implementation ContentValues does not support put(String, Object) metho...

What is the convention for designating the primary relationship in a one-to-many relation between tables?

I understand how to design a database schema that has simple one-to-many relationships between its tables. I would like to know what the convention or best practice is for designating one particular relationship in that set as the primary one. For instance, one Person has many CreditCards. I know how to model that. How would I designate ...

How do I map a one-to-many relationship through a join table?

Hi all, How would I go about mapping the following in NHibernate? My entities and ERD are below. I know how to map a many-many relationship, but dont know how to map the joining table ReportTargets to the Datapoint table. You will notice that there is no ReportTargets entity model as it is not strictly a domain entity. What is the best ...

NHibernate collection not loading with data, but data is inserted into database.

Hi, Not sure what I am doing incorrectly here with NHibernate. I have two mapping files mapped to two tables. I can insert data through the mapping into the database, but calling the below code returns 0, even though I can see a child row populated in the table with the correct foreign key. Is this a lazy loading issue? Thanks. var res...

Going "behind Hibernate's back" to update foreign key values without an associated entity

Updated: I wound up "solving" the problem by doing the opposite! I now have the entity reference field set as read-only (insertable=false updatable=false), and the foreign key field read-write. This means I need to take special care when saving new entities, but on querying, the entity properties get resolved for me. I have a bidirect...

How to change one-to-one relationship to one-to-many relationship in MySQL?

I currently have a user's table which contains a one-to-one relationship for Youtube OAuth tokens. However, I now want to support multiple video sites and want to break this into a one-to-many relationship. I have setup the new tables: tokens - cols: id, site, username (the user's username on Youtube), oauth_token, oauth_secret ...

How to properly index a table two other tables have a one-to-many relationship to?

Imagine I have three tables, called "customers", "companies" and "phone_numbers". Both customers and companies can have multiple phone numbers. What would be the best way to index phone_numbers? Have both customer_id and company_id and keep one of them null? What if there are more than two tables with a one-to-many relationship with phon...

Using Entity Framework 4.0 with Code-First and POCO: How to Get Parent Object with All its Children?

I'm new to EF 4.0, so maybe this is an easy question. I've got VS2010 RC and the latest EF CTP. I'm trying to implement the "Foreign Keys" code-first example on the EF Team's Design Blog, http://blogs.msdn.com/efdesign/archive/2009/10/12/code-only-further-enhancements.aspx. public class Customer { public int Id { get; set; publi...

Value of 0 in Hibernate IndexColumn mapped with base=1

We are using Hibernate Annotations 3.4.0GA and Hibernate Core 3.3.2.GA (also known as the current stable versions) against an Oracle database We have a One-to-Many mapping with base=1 which worked fine for a loooong time, yet last week we found some entries in the database where the index column contained a value of 0 which caused all k...

How to Insert one to many relationship using checkboxlist in VB.NET, LINQ to SQL?

I have 3 tables: CustomerType CusID EventType EventTypeID CustomerEventType CusID EventTypeID How to Insert one to many relationship using checkboxlist in VB.NET, LINQ to SQL? dim newEventType = new EventType newEventType.EventID = 1 db.EventType.InsertOnSubmit(newEventType) db.submitchange() Then I want it to automatically ins...

nhibernate mapping does not save/insert keys of inserted subclasses

After having changed around my mappings a bit ( see my other question about cascade-delete for reasons) , i tried inserting a completely new object and all its subclasses. After this another problem emerged, an issue with the insertion of the keys into the database. Situation is as follows: I have an object with 2 tiers of subclasses, ...

Looking for an elegant way to store one-to-many relationship in coredata when order is important

I've been trying to come up with a way to solve my problem, but every solution I can think of is messy and makes me want to retch. I have a one-to-many relationship, consisting of a Team object that can have many Member objects. When I built my data model using Xcode, I was given the default NSSet in which to store the member objects, ...

How to link a table to a field a in MySQL server

I have this data from a xml file: <?xml version="1.0" encoding="utf-8" ?> <words> <id>...</id> <word>...</word> <meaning>...</meaning> <translation> <ES>...</ES> <PT>...</PT> </translation> </words> This forms the table named "words", which has four fields ("id","word","meaning" and "translation"). ...

How to select parent row only if has at least one child?

I have a simple one-to-many relationship. I would like to select rows from the parent only when they have at least one child. So, if there are no children, then the parent row is not returned in the result set. Eg. Parent: +--+---------+ |id| text | +--+---------+ | 1| Blah | | 2| Blah2 | | 3| Blah3 | +--+---------+ Childre...