Let's say I'm modeling phone numbers. I have one entity for PhoneNumber, and one for Person. There's a link table that expresses the link (if any) between the PhoneNumber and Person. The link table also has a field for DisplayOrder.
When accessing my domain model, I have several Use Cases for viewing a Person.
I can look at them with...
Hi,
I have a many-to-many mapping defined (only relevant fields included) with FluentNHibernate (v1.0.0.637):
// MODEL:
public class User : IPersistentObject {
public User() {
Permissions = new HashedSet<Permission>();
}
public virtual int Id { get; protected set; }
public virtual ISet<Permission> Permissions { ...
I need to create a many-to-many relationship in Grails.
I have a "Question" domain and a "Tag" domain.
A Question can have 0 or more tags. A Tag can have 0 or more Questions.
If I put a "hasMany" on each sides, it gives me an error saying I need a "belongTo" somewhere.
However, adding a belongsTo means that the owner must exist... ...
Hi,
What would the basic C# code look like to model a many-to-many relationship, where the relationship itself has attributes? And also in this case the many-to-many was referential. So a possible database model for this might look like the following (just to give an example of what I'm talking about)
Nodes
ID
Name
Description
Rel...
I have two tables with the many-to-many association.
— DB fragment:
loads
Id
Name
sessions
Id
Date
sessionsloads
LoadId
SessionId
— Hibernate mapping fragments:
/* loads.hbm.xml */
<set name="sessions" table="sessionsloads" inverse="true">
<key column="LoadId" />
<many-to-many column="SessionId" class="Session" />
</set>
...
Hi,
my question is near a parent-child problem, and may need some recursive query, but i didn't find any answers by browsing forums.
here is my problem: I've got 3 tables:
T1 (people) T2 (places) T3 (relationship betwenn A and B)
------- ------ --------
id1 (pk) id2 (pk) id3 (pk)
name city ...
Hello,
I have the following table in the model with a recursive structure (a page can have children pages)
class DynamicPage(models.Model):
name = models.CharField("Titre",max_length=200)
parent = models.ForeignKey('self',null=True,blank=True)
I want to create another table with ManyToMany relation with this one.
class...
Hello,
I'm creating a database with Access. This is just a test database, similar to my requirements, so I can get my skills up before creating one for work. I've created a database for a fictional school as this is a good playground and rich data (many students have many subjects have many teachers, etc).
Question 1
What is the differ...
In my goal to have a Many-to-Many relationship in my MySQL database I have arrived at another bridge to build.
Current Tables:
Users (id, name)
Tags (id, name)
User_Tags (user_id, tag_id)
Here is the goal:
I would like to have the ability to take a tag i.e: #fb and insert it into my Tags database which has a unique constraint on name a...
I have a SQL Server database with two table : Users and Achievements. My users can have multiple achievements so it a many-to-many relation.
At school we learned to create an associative table for that sort of relation. That mean creating a table with a UserID and an AchivementID. But if I have 500 users and 50 achievements that could ...
Hi everyone,
Can I have a column in my values table (value) referenced as a foreign key to knownValues table, and let it be NULL whenever needed, like in the example:
Table: values
product type value freevalue
0 1 NULL 100
1 2 NULL 25
3 3 1 NULL
Tab...
I am trying to refresh the @ManyToMany relation but it gets cleared instead...
My Project class looks like this:
@Entity
public class Project {
...
@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "PROJECT_USER",
joinColumns = @JoinColumn(name = "PROJECT_ID", referencedColumnName = "ID")...
Ok guys (and gals), this one has been driving me nuts all night and I'm turning to your collective wisdom for help.
I'm using Fluent Nhibernate and Linq-To-NHibernate as my data access story and I have the following simplified DB structure:
CREATE TABLE [dbo].[Classes](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](100) NOT...
I have a many-to-many field on one of my models and a ModelForm to represent it. I have it in a template but it shows up as a multiple select field. I need it to show up as a CharField so the user can put in comma-delimited values. Is there any way to do this?
...
Hi all,
I have a data model with a many-to-many relationship like EntityA <-->> EntityB <<--> EntityC. I used to query EntityA with different search criteria and I use NSCompoundPredicate with an array of NSPredicates. On one of the predicate I wanted to query EntityA using EntityC. I tried to use the following SUBQUERY but it did not w...
I've been trying to deal with this problem for a couple of hours now and haven't been able to come up with a clean solution. It seems I'm not too good with rails...
Anyway, I have the following:
In code:
class Article < ActiveRecord::Base
has_many :line_aspects
has_many :aspects, :through => :line_aspects
#plus a 'name' field
...
I asked a question about this previously but my database structure has changed, and while it made other things simpler, now this part is more complicated. Here is the previous question.
At the time, my EF Context had a UsersProjects object because there were other properties. Now that I've simplified that table, it is just the keys, s...
I'm trying to get the related_name of a many-to-many-field. The m2m-field is located betweeen the models "Group" and "Lection" and is defined in the group-model as following:
lections = models.ManyToManyField(Lection, blank=True)
The field looks like this:
<django.db.models.fields.related.ManyToManyField object at 0x012AD690>
T...
In Hibernate HQL, how would you query through a many-to-many association. If I have a Company with multiple ProductLines and other companies can offer these same product lines, I have a Company entity, a ProductLine entity and an association table CompanyProductLine. In SQL, I can get what I need like this:
select * from company c wh...
Hi All,
I have the following models:
class Message(models.Model):
date = models.DateTimeField()
user = models.ForeignKey(User)
thread = models.ForeignKey('self', blank=True, null=True)
...
class Forum(models.Model):
name = models.CharField(max_length=24)
messages = models.ManyToManyField(Message, through="M...