mysql - ER diagram - avoiding one-to-one relationship -


i've been working on er diagram university project. transport company. company particular jobs other companies , each job, there 3 types of documents needed, , documents have unique identifiers among other documents of same kind. did made these types of documents separate entities. when want join them(call them doc1, doc2, doc3) 1 entity(call job), made 1 job , no other. also, job has 1 of each of these documents, therefore looks relationships between documents , job one-to-one. however, when professor teaching er models, told should avoid drawing one-to-one relationships(that there should way make these documents kind of attributes of job). want know - correct draw identifiers of these documents attributes of job, , make them foreign keys referencing corresponding fields in documents' table(in relations model)? or there other, more elegant way connect them somehow avoiding these one-to-one relationships? also, if way, guess should make 3 columns representing documents' identifiers unique in job table, right? avoid making 2 jobs having, example, same doc1? thank you!

one-to-one relationships avoided, because signal entities joined relationship one. however, in case specified here, relationship not one-to-one. instead "one 0 or one", known "one-to-one optional".

an example relationship between home , lot. home must located on lot, , 1 home can located on given lot, lot can exist before home built. if modelling relationship, have "one 0 or one" relationship between lot , home. shown this:

enter image description here

in case have 3 separate dependencies, like:

enter image description here

physically, these relationships may represented in 2 ways:

  1. a nullable foreign key in "one" row (lot, in example above), or
  2. a non-nullable foreign key in "zero or one" row (home, in example above)

you can choose approach comfortable , efficient you, depending on direction in application navigates.

you may decide have database enforce uniqueness constraint (the fact 1 home can on lot). in databases, null value participates in uniqueness constraints (in other words, unique index can have 1 null entry). in such database, constrained second approach. in mysql, not case; uniqueness constraint ignores null values, can choose either approach. second approach more common.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -