Questions tagged [entity-relationship]

An entity-relationship model (ERM) is an abstract and conceptual representation of data, information aspects of a business domain or its process requirements. Ultimately ERM is being implemented in a database.

Entity-relationship modeling is a database modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database, and its requirements in a top-down fashion. Diagrams created by this process are called entity-relationship diagrams, ER diagrams, or ERDs.

The main components of the ER diagrams are the entities and the relationships that exist among them. For example with the original notation, in the relational databases tables are shown as boxes, its attributes as ovals and their relations with other tables with lines.

The three schema approach to software engineering uses three levels of ER models that may be developed:

  • Conceptual data model is the highest ER model, that contain least granular detail but establishes the overall scope of what to be included in the model set.

  • Logical data model contains more detail than the conceptual ER model. Operational and transcational data entities are defined.

  • Physical data model - one or more such models can be developed from each logical ER model. Normally developed to be instantiated as a database, therefore each physical model must contain enough detail to produce a database.

2962 questions
18
votes
9 answers

What's the point of a candidate key?

I'm fairly new to database management and this question never seems to be answered in more than one sentence. All other SO answers say "A candidate key is a minimal super key." That means nothing to me. A candidate key is supposed to specify…
18
votes
5 answers

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…
Camilo Díaz Repka
  • 4,805
  • 5
  • 43
  • 68
18
votes
4 answers

How are super- and subtype relationships in ER diagrams represented as tables?

I am learning how to interpret Entity Relationship Diagrams into SQL DDL statements and I am confused by differences in notation. Consider a disjoint relationship as in the following diagram: Would this be represented as: Vehicle, 2WD and 4WD…
xingyu
  • 312
  • 1
  • 3
  • 13
17
votes
9 answers

Recommendation for a good entity relationship diagram building tool for occasional usage?

Freeware is a plus. Could you also describe with one sentence why it should be good enough for occasional usage? Edit: You might check this cool link , providing more info about entity relationship diagrams and tools Edit: For the chosen answer…
Yordan Georgiev
  • 5,114
  • 1
  • 56
  • 53
17
votes
1 answer

SQLAlchemy - Multiple Foreign key pointing to same table same attribute

My data base structure.... class Person(db.Model): id = db.Column(db.Integer, primary_key=True) user = db.relationship("BankSlip", back_populates="person_user") reference = db.relationship("BankSlip",…
Dewsworld
  • 13,367
  • 23
  • 68
  • 104
17
votes
2 answers

EF4 code-first: defining object relationships, foreign keys

< RANT_MODE > EF code-first approach is meant to save lots of time but for the time being I've only seen toy examples and spent hours trying to understand how I can make it generate the db I want. But still hoping that Eureka moment :-) < RANT_MODE…
Dav
  • 1,102
  • 3
  • 10
  • 22
17
votes
2 answers

NSManagedObject can't get attributes from NSAtomicStoreCacheNode

I have one-to-one relationship between entity A and entity B (one sided), for example named bRel. I have subclasses of NSAtomicStore (MyStore) and NSAtomicStoreCacheNode (MyCacheNode). In the load: method of MyStore I create instances of MyCacheNode…
16
votes
2 answers

Implementing one-to-zero-or-one relation in SQL Server

I'm using Entity Framework 4.1 database first approach. I've used legacy database. In my edmx file which created entity classes based on tables in the legacy database, there is a one-to-zero-or-one association between some entities. Although I…
15
votes
4 answers

@ManyToOne mapping fails to save parent ID

I'm using JPA2 with EclipseLink implementation ![Simple table structure][1] Here are the two tables which I try to map and the JPA annotations. public class Story implements Serializable{ @Id @GeneratedValue(strategy =…
Ionut
  • 2,788
  • 6
  • 29
  • 46
15
votes
4 answers

how to model discount on items in a database?

I am building an ecommerce site and would like to offer discounts on certain items for a limited time. My Product table (MySQL) looks like this: Product - productId - Name - Weight - Price (price as on the cover of the item) Should…
brainydexter
  • 19,826
  • 28
  • 77
  • 115
15
votes
1 answer

How to add a Map in an entity class?

I want to add a mapping as Map personMap; inside an entity class, where Person is the entity. The Map is to identify the exact Person corresponding to the String (let it be a nickname of that person). The same person may have…
Naveed S
  • 5,106
  • 4
  • 34
  • 52
15
votes
1 answer

When is it appropriate to use a bidirectional association and when is it not?

Let's pretend that we want to build an eBay like app in which we have an entity named Customer and an entity named Order. From a relational perspective, I would model this as: Customer +----+-----+ | ID | ...…
15
votes
4 answers

How to generate SQLite entity relationship diagram from database file

I am trying to reverse engineering to a database file that an android application generates. It gives me a SQLite file in .db extension. I tried pass it through SQLite Browser and it gets me the tables, but no relationships also every table givesme…
jvargas
  • 713
  • 1
  • 5
  • 13
14
votes
2 answers

rails 3 scaffolding of relational model

are there any tutorials out there how to scaffolding a simple model that uses many-to-many relationships?
lurscher
  • 25,930
  • 29
  • 122
  • 185
14
votes
1 answer

is optionality (mandatory, optional) and participation (total, partial) are same?

As i know optionality means the minimum cardinality of a relationship which is denoted as optional to optional, mandatory to optional, mandatory to mandatory.. And Participation denoted as bold line and a normal line. In the Internet some refer…
glupeksha
  • 460
  • 1
  • 6
  • 14