entity-relationship

Suitable E-R notation for introductory DB design course? Good/free diagram tools?

I've taught a database design course for a few years now, starting off each time using the Crow's Foot diagram notation for our entity-relationship models. I can't believe anyone seriously uses the Chen notation (especially for attributes), and I don't find the IDEF1X relationship symbols intuitive at all, particularly for students new t...

Many to Many Relationship in MS Dynamics CRM 4.0 - How to?

Hi I'm working on a MS CRM server for a project at my university. What I'm trying to do is to let the user of the CRM to tag some contacts, I thought of creating an entity to archive the tags an to create an N:N relationship between the tag entity and the contact one. I've created and published the new entity and the relationship, but I...

CakePHP multi-model view

Heyall, I am creating a website in CakePHP and I am kind of new on it. I couldn't find good resources on this matter, so there you go: I have a three table structure for registering users: Users, Addresses and Contacts. I have to build a view with info of all three tables like: Full Name: [ ] (from Users) Shipping Ad...

CakePHP hasAndBelogsToMany using save() vs. saveAll()

Heyall, I am using a very intrinsic database with a CakePHP application and so far my multi-models views and controllers are working fine. I have a singular table (Entity) that have it's id on several other tables as the Foreign Key entity_id Some tables are one to one relations (Like a Company is one Entity) and some are one to many (...

Database schema to track random settings in website for marketing

I have Flex based consumer website where I would like to change various look and feel type settings based on random and other criteria, and then track these through to what results in the most sales. For instance I might completely switch out the homepage, show different things depending upon where people come from. I might show or hid...

How to combine cascading updates/deletes between SQL Server and NHibernate?

I am writing an application with a hand-crafted domain model (classes) and a hand-crafted data model (tables/relationships), and letting NHibernate take care of the mapping. Is it best to tell the database to perform cascading updates or deletes or to tell NHibernate to do it (cascade="all-delete-orphan")? Can they both be set up to do ...

Generate an E-R Diagram by reverse-engineering a database

Note: Originally this question was asked for PostgreSQL, however, the answer applies to almost any database which has a JDBC driver that can detect foreign-key associations. Querying PostgreSQL data dictionary for foreign-keys and relationship between tables is very straightforward, but how can I use that information to generate a gr...

JPA - many to many relationship of a table with a compound-key with itself

I would like to create a many to many relationship of a table (RoutePlace) with itself using JPA anotations. The singularity of the table I want to join with itself is that it has a compound-key. example: http://h4losw2.files.wordpress.com/2008/10/tables.png Any suggestions? Thanks in advance ...

Customized naming of columns in JPA relationships

When I make relationsships with JPA using hibernate, some terrible long and ackward column names are generated. Eg. I have the following actionPlan_actionPlanPK, which means that the column actionPlan is a FK that points to actionPlanPK. To make it look just a little bit more neat in the DB I would like if I could give it a name myself, ...

Entity Relationship Diagram for MS Access

I've worked with MySQL and MSSQL for some time and have used a variety of CASE and UML tools when designing some of my more complex projects. I was recently asked by a colleague if I could provide an Access database for his department. The application itself isn't too complicated, and Access actually looks like the ideal tool for the ta...

Same fields in most tables

In a database prototype, I have a set of fields (like name, description, status) that are required in multiple, functionally different tables. These fields always have the same end user functionality for labeling, display, search, filtering etc. They are not part of a foreign key constraint. How should this be modeled? I can think of t...

How to define structure in a tag-based organization?

[former title: Is there a way to force a relationship structure on a tag-based organizational methodology?] I have some entities, and they have a series of attributes. Some of the attributes affect what other attributes the entity can have, many of the attributes are organized into groups, and occasionally entities are requited to have ...

How to deal with a Many-To-Many Relation in my API

I have two entities Foo and Bar with a Many to Many relationship between them. Let's say there is no semantic argument for why Foo might be "responsible" for the many to many relationship, but we arbitrarily decide that Foo is responsible for the relation (I.e., in NHibernate we would mark Bar as Inverse) That's all well and good from ...

Best relationships between one table and some other tables, each of them depending on n datasets of the first table?

I have one table that saves comments for a varied set of content types. These are saved in other tables (news, articles, users). I wonder what's the best way to connect these tables? In previous projects I used a second table for each kind of content. They held the id of the certain content mapped to ids of the comments table. So for ea...

Entity Framework - how do I use the entity associations?

When I have tables in my database that have PK/FK relationships (int) and when they are modeled by the Entity Framework designer everything seems as it should be. I can write the code below and everything seems like it's going to work fine as well but then when I run the code I get an error on the project.Status.StatusName saying the Ob...

Entity Framework - how do I use the entity relationships in my extended classes?

I am trying to extend the partial classes that the entity framework creates so that I can more easily work with objects like in the code below (please let me know if there's a better or more exceptable way of doing this with the entity framework) Public Sub New(ByVal ProjectID As Integer) Dim proj As Project = (From p In db....

What is the best way to represent a many-to-many relationship between records in a single SQL table?

I have a SQL table like so: Update: I'm changing the example table as the existing hierarchical nature of the original data (State, Cities, Schools) is overshadowing the fact that a simple relationship is needed between the items. entities id name 1 Apple 2 Orange 3 Banana ...

MySQL: Finding rows that don't take part in a relationship

I have two tables: 'movies' and 'users'. There's an n:m relationship between those, describing what movies a user has seen. This is described with a table 'seen' Now i want to find out for a given user, all the movies he has not seen. My current solution is like this: SELECT * FROM movies WHERE movies.id NOT IN ( SELECT seen.movie...

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

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 ...

2x one-to-many relationships in OO

Imagine these relationships: 1 A has many B's 1 B has many C's... In reverse: C has 1 B B has 1A By transitivity, C has 1 A To model this relationship in DB, we have: TableA a_id TableB b_id a_id (fk to TableA) TableC c_id b_id (fk to TableB) To model this relationship in OO, we have: objA objB objC And... - objB has re...