1

After reading several articles on n-ary database relationships I'm still in the dark on some aspects of them.

I draw the ER diagram below myself and I purposedly used fake, made-up English words that cannot convey any semantics:

enter image description here

Does it mean that:

  1. Each abacot kimes at most once with a gimble, and with many dords and wabes?
  2. Similarly, each gimble kimes at most once with an abacot, and with many dords and wabes?
  3. Each kiming relationship may include several dords and/or wabes?
  4. Will I need three tables to represent this relationship, or one will suffice?

But above all, is it possible to generate a database schema with this diagram alone, without any extra explanations? The database exercises I see in books don't include anything else besides the diagram.

This is how I see it so far:

CREATE TABLE kiming (
    kiming_id INT PRIMARY KEY NOT NULL,
    abacot_id INT NOT NULL REFERENCES abacot (abacot_id),
    gimble_id INT NOT NULL REFERENCES gimble (gimble_id),
    UNIQUE (abacot_id), -- is this necessary?
    UNIQUE (gimble_id)  -- is this necessary?
);

CREATE TABLE kiming_wabe ( -- do I need this table?
    kiming_id INT REFERENCES kiming (kiming_id),
    wabe_id INT REFERENCES wabe (wabe_id)
);

CREATE TABLE kiming_dord ( -- do I need this table?
    kiming_id INT REFERENCES kiming (kiming_id),
    dord_id INT REFERENCES dord (dord_id)
);
Joe DiNottra
  • 836
  • 8
  • 26
  • You are giving us a diagram you found, what does it say about the meaning of the diagram where you found it? PS Mapping Chen ER to DDL is a faq. PS Follow a published academic textbook on information modelling, the relational model & DB design. (Manuals for languages & tools to record & use designs are not such textbooks.) (Nor are wiki articles or web posts.) Ask 1 specific researched non-duplicate question where 1st stuck/unsure. Beware that following a poor reference likely makes an answer a frame challenge pointing out the 1st reference nonsense & referring you to a proper reference. – philipxy Sep 23 '21 at 17:27
  • Thank you. I draw that diagram myself and decided to use made-up words that don't have any sense in English (even the verb in the relationship) to avoid conveying any semantic with it. What you say has the subtext that diagram does not convey all the information needed to understand the relationship, and also that some extra "notes" in some other form are required to understand it. Thank you again. – Joe DiNottra Sep 23 '21 at 17:38
  • 1
    [Explanation of ER model to functional dependencies solution](https://stackoverflow.com/a/61316402/3404097) [Mapping a ternary relationship to the relational model (Employes, Customer, Project)](https://stackoverflow.com/a/47217197/3404097) [Relational Schema to ER Diagram /Cardinalities difference](https://stackoverflow.com/a/53224495/3404097) SO-search my answers re (Chen) ERDs, ternary relationships & cardinalities. But follow a (good) (many are poor) textbook. PS Diagram iconography says how to read it. Here: 4 entities, 1 relationship/association & 4 participations; 5 tables & 4 FKs. – philipxy Sep 23 '21 at 17:47
  • Please [use text, not images/links, for text--including tables & ERDs](https://meta.stackoverflow.com/q/285551/3404097). Paraphrase or quote from other text. Give just what you need & relate it to your problem. Use images only for what cannot be expressed as text or to augment text. Include a legend/key & explanation with an image. PS Sure for an ERD give an image but give its design content in text. Which typically is given trivially, can be considered DDL pseudo-code & obvioulsy forms certain parts of full DDL. – philipxy Sep 23 '21 at 17:54
  • @philipxy I'm sorry to bother again but I'm still thinking about this. I think the point I was trying to understand is that if the diagram alone can be used by itself to "produce" the database schema. It seems the answer is a "no". But, on the other side, the exercises I see don't have any other explanation besides the diagram. Sigh. – Joe DiNottra Oct 05 '21 at 00:44
  • The links I gave you tell you how to mechanically map to a DB & those are just some posts by me, I told you that how to do it is a faq & I told you in my comment what it maps to. Here is part of my standard comment re (re)searching: Please before considering posting read the manual & google any error message & many clear, concise & precise phrasings of your question/problem/goal, with & without your particular names/strings/numbers, 'site:stackoverflow.com' & tags; read many answers. Reflect your research. [ask] [Help] PS **Follow a published academic textbook** – philipxy Oct 05 '21 at 01:18
  • But also as you can see from how your guesses differ from my linked Q&A & comment re what the diagram says & maps to, you totally misunderstand how to interpret the diagram let alone map to the corresponding DB tables & constraints. Also you seem to confuse relation(ship)s/associations with constraints. Maybe you have read my links & just can't believe what they say because of your misconceptions? You really need to read a textbook. (But such Chen true ERD interpretation & mapping to DBs is a faq.) – philipxy Oct 05 '21 at 01:27
  • It is pointless to give a diagram unless you tell us what published method was followed in drawing it. Because otherwise we have to guess what method--if any. Moreover if you don't say how it followed the method we can't know what was meant by it & we can only tell you, given a method, how it maps to a DB. But if you know the method, a reasonable presentation--ie one justifying that you reasonably researched before you considered posting a question--tells you how to map. So ask only re being stuck/unsure. (This is all implicit in my comment "Include a legend/key & explanation with an image.") – philipxy Oct 05 '21 at 07:38
  • How does the very first link I gave you not answer your question? What exactly is your 1 question? What book doesn't explain its notation? – philipxy Oct 11 '21 at 23:24

2 Answers2

0

To your question of is it possible to generate a database schema with this diagram alone" - the answer is NO.

The diagram is unclear. There is no way to know how the 1's and N's relate to each other. If all I had to go on was the diagram, I could argue for at least 6 different interpretations. The diagram doesn't use a recognizable scheme for representing relationships of this type, so it's all guesswork.

Chris Johnson
  • 20,650
  • 6
  • 81
  • 80
  • The question diagram is clearly notation from Chen's original paper that introduced Entity-Relationship Modeling & ERDs. Granted the question doesn't say what method it's using, but then it should be closed, not answered. – philipxy Oct 11 '21 at 23:18
-1

For understanding of you diagram one to one and one to many relationship solution as below. Table schema you will change as required.

CREATE TABLE abacot (
        abacot_id INT PRIMARY KEY NOT NULL,
        abacot_details_columns varchar);

CREATE TABLE gimble (
        gimble_id INT PRIMARY KEY NOT NULL,
        gimble_details_columns varchar);

CREATE TABLE wabe (
        wabe_id INT PRIMARY KEY NOT NULL,
        wabe_details_columns varchar);

CREATE TABLE dord (
        dord_id INT PRIMARY KEY NOT NULL,
        dord_details_columns varchar);

CREATE TABLE kiming (
        kiming_id INT PRIMARY KEY NOT NULL,
        kiming_details_columns varchar 

    CREATE TABLE kiming_relationship_table (
        kiming_id INT PRIMARY KEY NOT NULL,
        abacot_id INT NOT NULL REFERENCES abacot (abacot_id),
        gimble_id INT NOT NULL REFERENCES gimble (gimble_id),
        UNIQUE (abacot_id), -- is this necessary? Yes 
        UNIQUE (gimble_id) , -- is this necessary? Yes 
        wabe_id INT REFERENCES wabe (wabe_id),
        dord_id INT REFERENCES dord (dord_id)
    );    
M Danish
  • 480
  • 2
  • 5
  • This misinterprets the 1s. The ERD does not say that those entities are 1 per table. Also this post does not justify this DDL. – philipxy Oct 06 '21 at 11:18
  • "Learn about Chen/true ER design. Including what boxes, diamonds & lines mean, and what cardinality annotations on lines mean." "Also this post does not justify this DDL." – philipxy Oct 07 '21 at 06:18