entity-relationship

Where to expose the results of a specific SQL query in the domain model.

Hi - Which of these examples would be the best way to expose a collection of Orders for a specific Person that contain a specific Product and why? Or maybe there is a better way to do this alltogether? (Sorry I am new to domain modeling). The Orders list is pulled from the database with an SQL query and turned into a List collection. A ...

Foreign key creation issue in MySQL

I have followed this article: http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html to create a foreign key between two tables. Every single attempt fails. Is there anything that I am missing?! It's really frustrating and I never expected to encounter this issue at all! Thanks. ...

What are some of your most useful database standards?

I have some ideas, but I really want to know what makes things go smoothly for you when modeling database: Table name matches Primary Key name and description key Schemas are by functional area Avoid composite primary keys where possible (use unique constraints) Camel Case table names and field names Do not prefix tables with tbl_, or...

Entitry Framework Add To Intersection Table

Hi Every one, I have just started jumping into EF and cant seem to do something that seems simple. Here is my question and supporting info. Any help or suggestions will be greatly appropriated. I have a user table and a group table. Between these is a UserGroups Intersection table to allow a user to belong to any number of groups. T...

How to make E-R diagram with 500 tables?

In our company we have a huge project with lots of tables. When I mean a lot it is about 500. Maybe it is something normal. Some of these tables have more than 200 fields. I find that trying to make an E-R Diagram for the whole system will be confusing, tiring and useless. Just including the tables would result in a frightening list of b...

Entity relationship modeling: how to implement entity "roles"?

I've done a bit of reading on data modeling recently and have a question about roles that an entity may play. Consider a simple case where you've got a Company, and a Company can be a Supplier, Customer, Distributor, etc. or a combination of these roles. So company X might be both a Supplier and a Customer. Down at the data level you ...

Standard database neutral XSD to describe a relational database schema.

Hi All, Is anyone aware of a vendor neutral XSD to describe a relational database schema? Our system needs to grab information about the structure of a database: Tables Columns and types Primary and Foreign Keys Constraints Indexes etc in a vendor independent manner and store it in an XML file for later processing. Before we...

How are ER modeled subtypes implemented in the database?

Sorry if this is too simple, but I've found a lot of documentation on ER-modeling recently, but all of it seems to skip over the actual implementation and I just want to clarify. Is a subtype just a second table with a foreign key to the supertype along with the properties belonging to the subtype? This is what would make most sense to...

How do I use Navigational Properties as Primary Keys in Entity Framework (.Net 4.0)?

I'm trying out the Model First approach introduced in Entity Framework with VS2010/.Net 4.0, and now I don't really know how to do this. I start out with the following Entities: Contact Event ******* ***** Id (Int32, not null, pk) Id (Int32, not null, pk) Name (Name, not null)...

How does the Entity Framework tell whether a multiplicity of "one" or "zero or one" should be used on a relationship?

I'm programmatically creating an edmx file as part of our code generation process and I'd like to know how the designer decides to use "1" or "0..1" for a relationship when you "Update model from database". Any insight on this? Thanks Edit: Ok, I think it uses "0..1" when the "many" side is a nullable foreign key and "1" if it's not nu...

Modeling a complex relationship in Django

I'm working on a Web service in Django, and I need to model a very specific, complex relationship which I just can't be able to solve. Imagine three general models, let's call them Site, Category and Item. Each Site contains one or several Categories, but it can relate to them in one of two possible ways: one are "common" categories, wh...

SQL Server to er model

Is there a program that converts a SQL Server database diagram to er model, or create er model of a database from SQL Server server? ...

SQL Delete if the row is not affected by constraints

First note that I have seen this question:TSQL delete with an inner join I have a large table and several foreign key relations, each of which have data of a given age. We need to remove data older than a given data on a regular basis to stop the DB from growing without bound. I'm writing a query that will delete from each point on th...

Multiple relationship binding with EntityDataSource

I have an ADO .Net Entity Data Model for my database. In this Model I have three related tables: "Users" Table containing UserId and other details. "Run" Table that contains RunId, ApproverId and other details "RunToUser" that contains UserId and RunId columns The relationships are as follows: Users.UserId is a one to one relationship ...

How to add/remove many-to-many relation with entity framework by entity key?

I tried: using (Entities e = new Entities()) { EntityKey key = new EntityKey("Entities.Users", "UserId", 20); User user = new User { EntityKey = key}; Role role = e.Roles.FirstOrDefault(); //role.Users.Attach(user); //throws (when uncommented...) InvalidOperationException: //The object being attached to the source ob...

Entity Framework: Find EntityKey Values for One-to-Many

In EF, it is possible to write the following line: orderLine.OrderReference.EntityKey.EntityKeyValues[0].Value Wich results in the ID of the associated OrderReference. What would be the solution if I wanted to know the ID's of the orderLines associated with an order? ...

Core Data simple relationship in code

Hi, I am a cocoa newbie trying to create an iPhone app including Core Data. My problem is this: I have a little app running now with a single entity called Playlist that I display in a table view and can add and delete entries in. I have these in my PlayerAppDelegate: playlistManagedObjectModel playlistListManagedObjectContext play...

Update EntityKey Reference in Entity Framework

I created an application that uses Asp.net, Entity Framework and Windows Workflow Foundation and everything works as expected. My asp.net page should start a Workflow that executes and update an entity passed to the workflow from the page. Everything works ok: i used Unit Of Work pattern to share the context between asp.net and WWF and...

Oracle optional relationship

What is the proper way to define an oracle table who has an optional foreign key relationship with another table? For instance, some employee records have defined the country they are from (a FK from countries table), and some have not. ...

Sorting records in a 1:n (one-to-many) relationship

I've got 2 tables: +-----------+ +------------------------------------+--------------+ + persons | | photos | +-----------| +---------------------------------------------------+ + id | name + | id | person_id | path | title | +-----------+ +---------------------------...