Designing ERDs within DDL (Create Table Statement)

  • Thread starter Thread starter WWGD
  • Start date Start date
  • Tags Tags
    Designing Table
Click For Summary

Discussion Overview

The discussion revolves around the possibility of using Data Definition Language (DDL) to express relationships between tables in a database schema, specifically focusing on creating Entity-Relationship Diagrams (ERDs) without relying on graphical user interfaces (GUIs). Participants explore various methods and tools for automating ERD generation from DDL statements.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant inquires about adding functionality to DDL statements to automatically express table relationships (1:1, M:1, M:N) and generate ERDs.
  • Another participant suggests the use of auto-increment features in table definitions.
  • Some participants mention that keys can be defined as unique or nullable, and question whether the focus is on schema design or understanding database programming.
  • A participant proposes using metadata tables in Oracle to create ERDs through SQL statements, emphasizing the utility of metadata for generating ERDs from existing applications.
  • Another participant expresses skepticism about the practicality of ERDs for complex systems, suggesting they may be cumbersome and less useful beyond a certain scale.
  • One participant acknowledges confusion regarding the specific database system being discussed and reflects on the limitations of DDL in fully implementing ERD designs.
  • A later reply introduces the concept of using constraints to link foreign keys in relationships and mentions tools that can create ERDs from schemas.

Areas of Agreement / Disagreement

Participants express varying opinions on the feasibility and practicality of using DDL for ERD generation, with no consensus reached on the best approach or tools available.

Contextual Notes

Limitations include the dependence on specific database systems (e.g., MySQL, MSSQL, Oracle) and the unresolved nature of how fully DDL can encapsulate the design of an ERD.

WWGD
Science Advisor
Homework Helper
Messages
7,804
Reaction score
13,107
Hi again,
just curious as to whether it is possible to use DDL (Data definition, i.e., non-GUI ); more specifically to add something to the usual create table statements to express the relation between tables, i.e., these tables being either in 1:1, M:1 or M:N relation (so that a new, bridge table with default primary keys would be created )?

We seem to already have gone a good part along the way, having info on FKeys and what fields
they reference in other tables. Is there additional code to allow for this, i.e., to allow for the description of these relations and to ultimately have as an output the ERD of the relation?

Thanks.
 
Technology news on Phys.org
  • Like
Likes   Reactions: WWGD
You can specify that keys are unique or not in the table and you can specify whether fields can be null or not.

Are you designing a database schema or trying to understand database programming?

Have you looked at star schema design?
 
jedishrfu said:
You can specify that keys are unique or not in the table and you can specify whether fields can be null or not.

Are you designing a database schema or trying to understand database programming?

Have you looked at star schema design?
Hi, both actually, I am trying to understand in general and use for designing schemas. It would be great to hve a full ERD as output without the need to use GUIs.
 
You can use metatdata tables (in Oracle example: all_tab_columns, all_tables, etc.) to use the 'start with connect by' tree creation SQL statement to create an ERD.

You've essentially asked the same question multiple times. Question== "I want to automagically create an ERD".

Answer:
I do not know mysql (what you seem to use) from beans. But, I do know there are free tools to analyze table metadata out there. Start googling, some terms:
database, metadata, analysis, entity relationships.

Personally, I find most ERD's for commerically produced database application systems to be a digression. As well as requiring a huge wall to display the darned thing on paper. Whenever something trancends normal human perception limits, its usefulness is quite limited.

There is a reason for metadata tables other than to keep the db engine amused: ERD information is one select statement. How do you suppose, for an existing application, someone created an ERD to start with?
 
jim mcnamara said:
You can use metatdata tables (in Oracle example: all_tab_columns, all_tables, etc.) to use the 'start with connect by' tree creation SQL statement to create an ERD.

You've essentially asked the same question multiple times. Question== "I want to automagically create an ERD".

Answer:
I do not know mysql (what you seem to use) from beans. But, I do know there are free tools to analyze table metadata out there. Start googling, some terms:
database, metadata, analysis, entity relationships.

Personally, I find most ERD's for commerically produced database application systems to be a digression. As well as requiring a huge wall to display the darned thing on paper. Whenever something trancends normal human perception limits, its usefulness is quite limited.

There is a reason for metadata tables other than to keep the db engine amused: ERD information is one select statement. How do you suppose, for an existing application, someone created an ERD to start with?
Sorry, I was thinking of MSSQL2014 . I just thought that since DDL statements go so far towards laying out the needed specs for an ERD, that it may be possible to go all the way and implement a design. But, yes, for reasonable ERDs with, say, less than 10 tables.
 
Not quite sure what you are getting at: are you familiar with the concept of a CONSTRAINT? You can use a CONSTRAINT to link the foreign key column in the 'many' side of the relationship to the key column on the 'one' side. You can then use a tool to create an ERD from the schema (e.g. SqlServer's Diagrammer).
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K