entity-relationship

Disable associations when a foreign key do not exist

只愿长相守 提交于 2019-12-25 16:54:42
问题 I've created an edmx for my database. In it Entity framework removed a table and instead created an association between two tables because it matches a column name with the primary key in the other table. I do not want that as there is no real association between those tables. How can I remove that association and get a class for the middle table instead? Example: SomeTable Id int pk MiddleTable SomeTableId int fk SomeCode int OtherTable SomeCode int pk It's the MiddleTable which do not get a

Entity and Relationship Set

北慕城南 提交于 2019-12-25 14:05:07
问题 I am confused about "entity set" and "relationship set". I am aware of "entity" and "relationship". Is there any clear example for entity set and relationship set which shows the real use cases of these terms? ___________ /\ ___________ | | / \ | | | Teacher |-------- /Tea \--------| Student | |___________| \che / |___________| \s / \/ In the above diagram Teacher and Student are entities and Teaches is a relationship. 回答1: Originally in Entity-Relationship Modeling: An entity is an

How can I improve this database model?

可紊 提交于 2019-12-25 06:37:36
问题 I'm trying to model the relationship of dvd sales and dvd rentals to a customer. Although I dont think my transction table is correct. If anyone can let me know if I'm goin in the right direction with the design that would be great. 回答1: Here is one way you can design this. I am not a database expert. I have designed databases for small sized applications with few tables. I try (emphasis on try, sometimes I fail to) to be more generic as possible so I am not confined to a corner when there is

Entity Framework 4 CTP 5 POCO - Many-to-many or Lookup table?

喜你入骨 提交于 2019-12-25 04:44:16
问题 I'm building a personal blog app with Entity Framework 4 CTP 5 POCO only, where a Post can have many Tags and a Tag can be in many Posts . My question is whether to build a many-to-many model, or to have a lookup table. At first I was trying to use many-to-many, but I don't know how to do insertion, each time a new post is posted (with many tags selected), I'm not sure what to do so that the tags should be associated with the post (and wouldn't insert a new tag if the tag name already exists.

How to eagerly fetch a single “default” entity from a collection in EJB3/JPA

眉间皱痕 提交于 2019-12-25 04:34:18
问题 I have a Person entity with multiple phone numbers. @OneToMany(mappedBy="person", cascade=CascadeType.ALL) public Set<PhoneNumberOfPerson> getPhoneNumbers() { return phoneNumbers; } Now I would like to implement a "get default phone number" method for Person that is eagerly fetched. This default phone number is one of the phone numbers in the phoneNumbers set. Is there any way to do this? The reason I'm trying to implement this is to have this default phone number listed on a page that lists

Converting an ER diagram to relational model

☆樱花仙子☆ 提交于 2019-12-25 02:50:14
问题 I know how to convert an entity set, relationship, etc. into the relational model but what i wonder is that what should we do when an entire diagram is given? How do we convert it? Do we create a separate table for each relationship, and for each entity set? For example, if we are given the following ER diagram: My solution to this is like the following: //this part includes the purchaser relationship and policies entity set CREATE TABLE Policies ( policyid INTEGER, cost REAL, ssn CHAR(11)

How to properly manage associated JPA entities with OneToOne BiDirectional relation?

雨燕双飞 提交于 2019-12-25 02:46:07
问题 Let's say 2 entities are given: master and dependant. They are defined in DB usually like dependants.master_id -> masters.id , i.e. the dependant entity holds the reference to the main entity. In JPA one2one BiDirectional association in this case usually looks like: class Master { @OneToOne(mappedBy="master") Dependant dependant } class Dependant { @OneToOne @JoinColumn("master_id") Master master } And this approach causes the necessity to deal with both sides of relation like: Master master

What table structure to use (hibernate)

孤街浪徒 提交于 2019-12-24 22:06:28
问题 I hava two entities: PhisicalPerson (PP), JuredicalPerson (JP). And I want to create Phone object. JP has many phones and PP has many phones (one to many relation). So in Phone object I have to create 2 columns for this relations: class Phone { @JoinColumn(name="ppId",nullable=true) @ManyToOne public PhisicalPerson getPhisicalPerson() {...} @JoinColumn(name="jpId",nullable=true) @ManyToOne public JuredicalPerson getJuredicalPerson() {...} // number, city code, additional number and other

Doctrine2, Symfony2 - oneToOne with multiple entities?

…衆ロ難τιáo~ 提交于 2019-12-24 18:57:58
问题 I have a user entity, and multiple profile entities. What I'm trying to do is dynamically create a oneToOne relationship based on the user role. So picture my 3 tables: users (core table, username, pass, role etc, used for authentication) users_admin users_client Then in my User.orm.yml I have: oneToOne: --profile: ----targetEntity: \UserBundle\Entity\Profile ----mappedBy: user The problem is I need the targetEntity to either be: AdminProfile ClientProfile Based on role. Is there any links or

ActiveRecord relation using an array of foreign keys

扶醉桌前 提交于 2019-12-24 17:02:39
问题 Is that possible to establish a relationship between Tree and Branch such as: class Tree < ActiveRecord::Base has_many :branches end class Branch < ActiveRecord::Base belongs_to :tree end But with an array of foreign keys branch_ids stored in Tree? I know it's the opposite of the default process, but I want to do so (just for testing). Many thanks for any help. 回答1: As Lichtamberg mentioned it is a bad schema. Since you said "just for testing", if branch ids will be a column with comma