DEV Community

Discussion on: Entity Relationship Diagrams explained by Sonic the Hedgehog

Collapse
 
qcgm1978 profile image
Youth

I love what you describe and your words. The following is a code demo by js:

// Conceptual Data Model
const EntityRelationshipDiagrams = {
  Zones: class {
    // Logical Data Model
    constructor() {
      this.ZoneId = EntityRelationshipDiagrams.PhysicalDataModel.getId(105);
      this.voice = "truths";
    }
    // Physical Data Model
    speak() {
      return `${this.ZoneId} ${this.voice} as work`;
    }
  },
  Boss: class {
    // Logical Data Model
    constructor() {
      this.BossId = EntityRelationshipDiagrams.PhysicalDataModel.getId(0);
      this.voice = "barks";
    }
    // Physical Data Model
    speak() {
      return `${this.BossId} ${this.voice} in the meeting`;
    }
  },
  // external Physical Data Model
  PhysicalDataModel: {
    getId(num) {
      return num < 100
        ? this.getRandomInt(0, 100)
        : this.getRandomInt(num, 1000);
    },
    getRandomInt(min, max) {
      min = Math.ceil(min);
      max = Math.floor(max);
      return Math.floor(Math.random() * (max - min + 1)) + min;
    }
  }
};

Some comments have been hidden by the post's author - find out more