Search Results

Search found 2412 results on 97 pages for 'relationship'.

Page 8/97 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Model a Zero or One to Many Relationship

    - by John
    How should I model a zero or one to a many relationship in the database? For example, a user record may or may not have a parent. So should my user table have a t_user.parent_id or should I have an associative table called t_user_hierarchy with the columns t_user_hierarchy.parent_id and t_user_hierarchy.user_id?

    Read the article

  • Can't destroy record in many-to-many relationship

    - by Dmart
    I'm new to Rails, so I'm sure I've made a simple mistake. I've set up a many-to-many relationship between two models: User and Group. They're connected through the junction model GroupMember. Here are my models (removed irrelevant stuff): class User < ActiveRecord::Base has_many :group_members has_many :groups, :through => :group_members end class GroupMember < ActiveRecord::Base belongs_to :group belongs_to :user end class Group < ActiveRecord::Base has_many :group_members has_many :users, :through => :group_members end The table for GroupMembers contains additional information about the relationship, so I didn't use has_and_belongs_to_many (as per the Rails "Active Record Associations" guide). The problem I'm having is that I can't destroy a GroupMember. Here's the output from rails console: irb(main):006:0> m = GroupMember.new => #<GroupMember group_id: nil, user_id: nil, active: nil, created_at: nil, updated_at: nil> irb(main):007:0> m.group_id =1 => 1 irb(main):008:0> m.user_id = 16 => 16 irb(main):009:0> m.save => true irb(main):010:0> m.destroy NoMethodError: undefined method `eq' for nil:NilClass from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/active_support/whiny_nil.rb:48:in `method_missing' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/persistence.rb:79:in `destroy' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/locking/optimistic.rb:110:in `destroy' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/callbacks.rb:260:in `destroy' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-3.0.4/lib/active_support/callbacks.rb:413:in `_run_destroy_callbacks' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/callbacks.rb:260:in `destroy' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/transactions.rb:235:in `destroy' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/transactions.rb:292:in `with_transaction_returning_status' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/transactions.rb:207:in `transaction' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/transactions.rb:290:in `with_transaction_returning_status' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-3.0.4/lib/active_record/transactions.rb:235:in `destroy' from (irb):10 This is driving me crazy, so any help would be greatly appreciated.

    Read the article

  • Why One-to-one relationship dosen't work?

    - by eugenn
    I'm trying to create a very simple relationship between two objects. Can anybody explain me why I can't find the Company object via findBy method? class Company { String name String desc City city static constraints = { city(unique: true) } } class City { String name static constraints = { } } class BootStrap { def init = { servletContext -> new City(name: 'Tokyo').save() new City(name: 'New York').save() new Company(name: 'company', city: City.findByName('New York')).save() def c = Company.findByName('company') // Why c=null????! } def destroy = { } }

    Read the article

  • Appengine Model SelfReferenceProperty and parent child relationship

    - by GeekTantra
    I have a scenario in which I need a self reference property as follow: class Post(db.Model): creator = db.UserProperty() post_title = db.StringProperty(required=True) post_status = db.StringProperty(required=True, choices=['draft', 'published']) post_parent = db.SelfReferenceProperty() Now, I want ensure that an entity shouldn't be its own parent and a child of an entity cannot be its parent. How can I ensure this kind of a relationship in the PostForm model form and the Post model.

    Read the article

  • What is the relationship between a R.V N(0,1) and others continuous random variables

    - by calejero
    Hello. I have a question. I need to kwon what is the relationship between a Random Variable with Normal distribuation (N(0,1)) and others continuous random variables. Can you write to me an example? Thank You Hola a todos. Necesito saber qué relación existe entre una variable aleatoria Normal (0,1) y cualquier variable aleatoria continua. Además, me vendría bien un ejemplo. Gracias por vuestra ayuda

    Read the article

  • What is the relationship between programming and music?

    - by pheze
    Who here is both a musician and a programmer? I would also be curious to know which instruments you play, the ages at which you started programming and playing music, your personal experiences, etc. Perhaps we can find a relationship between these two things. I'll begin: Piano since 10, Computer since 12, I am 21. Note: Question originally from pheze.myopenid.com. Related: Jazz Programmer

    Read the article

  • The Relationship Between Activities and View Objects - Android

    - by Greenhouse Gases
    I am attempting to learn how to develop on the Android platform but do not quite understand the relationship between Activities and Views, because according to the documentation an Activity is link to a UI object that the user can interact with, but if this is the case where does the whole idea of Views come in? There is probably a very basic explanation but I would appreciate a few pointers all the same. Thanks

    Read the article

  • Relationship problem?

    - by dilip
    I have four tables Tag=id,tag_name Image=Id,Image_name TagImage=Id,tag_id,Image_id ImageStudent=id,Image_id,student_id And I want to find a record using student id and tag name. What relationship do I use?

    Read the article

  • insert with many to many relationship

    - by Luca Romagnoli
    hi, i have 2 object: user, group that have a relationship many to many i want create a user and associate some groups to it. How can i do it? thanks I've tried with this. but it's wrong: user = new User(); List<int> gruppi = new List<int>() {1,2}; utente.Group =db.Group.Where(p => gruppi.Contains(p.GruppoID)

    Read the article

  • acts_as_list with has_and_belongs_to_many relationship

    - by mculp
    I've found an old plugin called acts_as_habtm_list - but it's for Rails 1.0.0. Is this functionality built in acts_as_list now? I can't seem to find any information on it. Basically, I have an artists_events table - no model. The relationship is handled through those two models specifying :has_and_belongs_to_many How can I specify order in this situation?

    Read the article

  • ruby on rails- nested attributes for 'has_one' relationship

    - by Kum
    Hello, I need some help concerning nested attributes in models with 'has_one' relationship. Model Survey has 1 question Model Question has 1 answer How do i build the 'answer' in the code below def new @survey = Survey.new @survey.build_question # build one question @survey.question.answer.build #this part is not working end Please can anybody tell me how to build the answer as the code "@survey.question.answer.build" is not correct. Many many thanks for your help

    Read the article

  • Why is this Exception?- The relationship between the two objects cannot be defined because they are

    - by dev-1787
    I m getting this Exception-"The relationship between the two objects cannot be defined because they are attached to different ObjectContext objects." I ve user table and country table. The countryid is referred in user table. I am getting the above Exception when I am trying to add entry in user table. This is my code- using (MyContext _db = new MyContext ()) { User user = User .CreateUser(0, Name, address, city, 0, 0, email, zip); Country country = _db.Country.Where("it.Id=@Id", new ObjectParameter("Id",countryId)).First(); user.Country = country; State state = _db.State.Where("it.Id=@Id", new ObjectParameter("Id", stateId)).First(); user.State = state; _db.AddToUser(user );//Here I am getting that Exception _db.SaveChanges(); }

    Read the article

  • How to change Fluent NHibernate reference column name on a HasMany relationship using IHasManyConven

    - by snicker
    Currently I'm using Fluent NHibernate to generate my database schema, but I want the entities in a HasMany relationship to point to a different column for the reference. IE, this is what NHibernate will generate in the creation DDL: alter table `Pony` add index (Stable_ID), add constraint Ponies_Stable foreign key (Stable_Id) references `Stable` (Id); This is what I want to have: alter table `Pony` add index (Stable_ID), add constraint Ponies_Stable foreign key (Stable_Id) references `Stable` (EntityId); Where Stable.ID would be the primary key and Stable.EntityId is just another column that I set. I have a class already that looks like this: public class ForeignKeyReferenceConvention : IHasManyConvention { public void Apply(IOneToManyCollectionInstance instance) { instance.Cascade.All(); //What goes here so that I can change the reference column? } } What do I have to do to get the reference column to change?

    Read the article

  • DataMapper and Codeigniter - how to fully manage a many-to-many relationship

    - by user252160
    I have the following relationship CType has many Field Field has many Ctype and of course the tables used are fields, ctypes, and ctypes_fields. Normally, the ctypes_fields table should contain only ids referencing the other two tables. However, i'd like to put there a "options" field that will contain some content for the concrete instance only. I walked through all DataMapper tuts but I could'n find relevant info on how I could extract these specific values (the ones in the relation table) Should I create a separate model for this relation table or there is a clever way to do this ?

    Read the article

  • Database theory - relationship between two tables

    - by iansinke
    I have a database with two tables - let's call them Foo and Bar. Each foo may be related to any number of bars, and each bar may be related to any number of foos. I want to be able to retrieve, with one query, the foos that are associated with a certain bar, and the bars that are associated with a certain foo. My question is, what is the best way of recording these relationships? Should I have a separate table with records of each relationship (e.g. two columns, foo and bar)? Should the foo table have a column for a list of bars, and vice versa? Is there another option that I'm overlooking? I'm using SQL Server, if that makes a difference.

    Read the article

  • JPQL check many-to-many relationship

    - by Juriy
    Just a quick question: There's the entity (for example User) who is connected with the ManyToMany relationship to the same entity (for example this relation describes "friendship" and it is symmetric). What is the fastest way in terms of execution time to check if User A is a "friend" of user B? The "dumb" way would be to fetch whole List and then check if user exists there but that's obviously the overhead. I'm using JPA 2 Here's the sample code: @Entity @Table(name="users") public class UserEntity { @ManyToMany(fetch = FetchType.LAZY) private List<UserEntity> friends; .... }

    Read the article

  • Drupal Views Duplicate values being returned when using a relationship

    - by Linda
    I am having a problem with views. I have a view and am passing it a taxonomy term by name to it. I then have a relationship to a related node. For my output fields I am returning the related Title and related Body. I however have duplicates in my results. I have turned distinct to yes but believe this is working on the nodes being return and not the related node. Any ideas how I can remove the duplicates? Update Below is the query being run when I only get the title SELECT DISTINCT(node.nid) AS nid, node_node_data_field_wine_company.title AS node_node_data_field_wine_company_title, node_node_data_field_wine_company.nid AS node_node_data_field_wine_company_nid FROM node node LEFT JOIN content_type_wine node_data_field_wine_company ON node.vid = node_data_field_wine_company.vid INNER JOIN node node_node_data_field_wine_company ON node_data_field_wine_company.field_wine_company_nid = node_node_data_field_wine_company.nid LEFT JOIN term_node term_node ON node.vid = term_node.vid INNER JOIN term_data term_data ON term_node.tid = term_data.tid WHERE term_data.name = 'test' GROUP BY nid It looks like I should be grouping by node_node_data_field_wine_company_nid or selecting distinct values from there. Any ideas?

    Read the article

  • VB FFT - stuck understanding relationship of results to frequency

    - by WaveyDavey
    Trying to understand an fft (Fast Fourier Transform) routine I'm using (stealing)(recycling) Input is an array of 512 data points which are a sample waveform. Test data is generated into this array. fft transforms this array into frequency domain. Trying to understand relationship between freq, period, sample rate and position in fft array. I'll illustrate with examples: ======================================== Sample rate is 1000 samples/s. Generate a set of samples at 10Hz. Input array has peak values at arr(28), arr(128), arr(228) ... period = 100 sample points peak value in fft array is at index 6 (excluding a huge value at 0) ======================================== Sample rate is 8000 samples/s Generate set of samples at 440Hz Input array peak values include arr(7), arr(25), arr(43), arr(61) ... period = 18 sample points peak value in fft array is at index 29 (excluding a huge value at 0) ======================================== How do I relate the index of the peak in the fft array to frequency ?

    Read the article

  • Maintaining both sides of self-referential many-to-many relationship in Grails domain object

    - by Ali G
    I'm having some problems getting a many-to-many relationship working in grails. Is there anything obviously wrong with the following: class Person { static hasMany = [friends: Person] static mappedBy = [friends: 'friends'] String name List friends = [] String toString() { return this.name } } class BootStrap { def init = { servletContext -> Person bob = new Person(name: 'bob').save() Person jaq = new Person(name: 'jaq').save() jaq.friends << bob println "Bob's friends: ${bob.friends}" println "Jaq's friends: ${jaq.friends}" } } I'd expect Bob to be friends with Jaq and vice-versa, but I get the following output at startup: Running Grails application.. Bob's friends: [] Jaq's friends: [Bob] (I'm using Grails 1.2.0)

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >