entity-relationship

Returning related elements in a single query (Is my query bad?)

Hey, I have a table called products that has a relationship with itself. This table stores products, their sub-products, and then sub-sub-products. When a user searches for the top-most product, this query is supposed to return the parent, its children, and its children's children. Now, my query works, but I am new to the entity framewor...

C# - Serializing and Deserializing Linq Tables whilst maintaining Relationships

Hi All, I want to Test my code! A noble goal I'm sure you agree. I need to mock out DataContexts for my Regression tests, running the test will verify that for any code change, given the same input we produce the same output. I'm using Moles to mock out my data contexts. It's awesome and simple, I recommend it, I might move to Moq if ...

Database design problem - keeping relationships at a minimum

I have a database design that's normalized well enough, but now I need to add a new table (entity, since I'm actually using Core Data) and I'm running into some issues. Landscape has many Assessment Assessment has one AssessmentType AssessmentTree has one Assessment AssessmentTree has one each of 12 other entities, omitted for space. ...

ER inheritance modeling

A supply farm can have a transportation document. If present it can be one of two types: internal or external. Both documents share some common data, but have different specialized fields. I though of modeling this in a OO-ish fashion like this: In the document table, one of the two doc_*_id is null, the other is the foreign key with...

MySQL joins? What are they? When to use them?

I am probably going to get slaughtered for this, and told to read the manual (which I have, but it has not helped my understanding). I working with MySQL more and more at the moment, but I cannot get my head around joins, I know there are multiple types of join, i.e Inner, Outer, Left, Right but I do not what the differences are between...

MVC 2 Application with a relational DB and object wrappers - how to get relational data into views?

I've recently refactored my application with the following: Linq to SQL db connection Objects to wrap the linq to sql classes Mappers to map back and forth between objects and Linq to Sql entitys Service layer to call the repository, handing up objects to the UI. Before I was just using Linq to SQL objects in my UI (I know). But when d...

ER modelling - Generating patient ID every visit

Hi I am doing an assignment on ER modelling and there is a part that I'm stuck on, here is an extract: Patient is a person who is either admitted to the hospital or is registered in an outpatient program. Each patient has a patient number (ID), name, dob, and tele. Resident patients have a Date Admitted. Each outpatient is scheduled for...

one-to-many entity referencing itself in hibernate

This seems to work, but is this the proper way for an entity to have a child set of the same entities? <hibernate-mapping> <class name="com.example.Person" table="Person"> <id name="id" column="Id" type="int"><generator class="native"/></id> <many-to-one name="childOf" class="com.example.Person" column="Child_of_Id"/...

What is the meaning of double circles and double squares in EER-modeling?

I´m trying to understand some EER-models and I can't figure out what the difference between a normal circle/square/diamon and a double circle/square/diamond is. What is the original writer trying to tell me? ...

Database Modeling an Email List and Report Types

I'm having a huge problem in modeling this problem. I'm writing a exam taking application (in MS-Access, but this isn't really relevant) and there are a few reports that need to be sent out. The first report is sent out automatically after a person completes an exam. The second report is sent out every 2 weeks (or whatever they want to ...

EntityFramework - changing multiplicity from 1 to 0..1 changes FK location

I have a model: Customer - Address. Customer inherits from Person (if this is important). So, the idea here is that there should be a nullable FK from Customer to Address. Is it at all possible? I am wondering because if the relationship is 1-1 then I can get the FK to Customer table. Yet if I change the multiplicity of address to 0..1 t...

JPA - manytoone cascading

Hi there, I've got two entities ServiceDownload.java @Entity public class ServiceDownload implements Serializable { private static final long serialVersionUID = -5336424090042137820L; @Id @GeneratedValue private Long id; @Length(max = 255) private String description; private byte[] download; private String fileName; @ManyToOne...

software or service to collaborate on a data model?

I'm trying to find a tool where a lot of people can work on a data model collaboratively (doesn't have to be at the same time, a checkout mechanism can work too). Embarcadero has an ER application called ER/studio which apparently comes with a repository system that acts like typical version control software. That sounds great except ER/...

make a entity class rows read-only in JPA

I m able to get values using JPA when i have only mapped one table Now when i have gone for mapping related tables i get the error Only one may be defined as writable, all others must be specified read-only. Mapping: org.eclipse.persistence.mappings.OneToOneMapping[userId1] I m using [EclipseLink-0] (Eclipse Persistence Services...

A referential integrity constraint violation occurred

Hi All, I have a entity model and on it i have a object with name Person that this object have 1 ti 1 relation with NaturalPerson and LegalPerson. therefore the Person is a abstract class and Naturalperson and LegalPerson inherited from Person, but when i try to add NaturalPerson in DAL i got this error A referential integrity constrain...

Query to find table relationship types.

Using Oracle, is there any way I can execute a query to determine what relationship a specific table has with any other tables in my database? I'm fiddling with the all_constraints table as of now. ...

How to setup a relationship so that more than one type of object can be in a set with Spring Roo

My domain thus far looks like: ~.domain.RenderJob ~.domain.RenderLayer ~.domain.ImageLayer extends ~.domain.RenderLayer ~.domain.ColorLayer extends ~.domain.RenderLayer I'd like to add a set field to RenderJob named 'layers'. Elements in the set can be either of type ImageLayer or ColorLayer, both of which extend RenderLayer. Is there...

Does an associaton behave differently than a relationship?

I'm using the entity framework My customer class has an AccountID property that includes account information from other tables (such as address and specific account info) by loading the other tables into the property based on their relationships. like this: tblAccount acct = new tblAccount(); tblCust cust; tblAddress addr; public Cus...

Database design too repetitive?

I'm working on a database schema that's driving me a little mad at the moment because I seem to be repeating the same tables to reproduce behaviour for different types. Basically the system consists of live sensors that are monitored over a network, and loggers that are collected via a handset. The sensors and loggers are divided up in...

Is this a valid use of NULL foreign keys?

Hi. Consider this very small contrived subset of my schema: SensorType1 ID : PK SensorType2 ID : PK Reading Timestamp Value SensorType1_ID FK -> SensorType1 SensorType2_ID FK -> SensorType2 Some readings are for SensorType1, some are for SensorType2. I would probably add a constraint to ensure exclusively one of those FK's is alway...