Difference between revisions of "Database structure"

From iDempiere en
m (Add category)
(IDEMPIERE-6592)
 
(17 intermediate revisions by 6 users not shown)
Line 1: Line 1:
−
This page will describe the database structure.
+
See the database structure in
 +
* [https://globalqss.com/idempiere/11_20231224/schemaspy/ this SchemaSpy analysis of an iDempiere database] generated on 2023-12-24
 +
* [https://globalqss.com/idempiere/6.2_20190709/schemaspy/ this SchemaSpy analysis of an iDempiere database] generated on 2019-07-09
 +
* [http://hsharp.software/idempiere-db/ this SchemaSpy analysis of an iDempiere database] generated on 2017-12-21. <small>([https://github.com/hsharpsoftware/idempiere-db The generated database structure source code is on GitHub.])</small>
  
−
* [[Accounting Tables]]
 
  
 +
This is made by schemaspy,you can made it by yourself,but it has some different, it is group by idempiere domain knowledge.  See [[Tables by Module]]
  
 +
You can fill the comments on postgresql database executing the following code:
 +
<syntaxhighlight lang="SQL">
 +
DO $$
 +
DECLARE
 +
    rec RECORD;
 +
cmd varchar;
 +
BEGIN
 +
    FOR rec IN
 +
SELECT t.TableName,
 +
  CASE WHEN t.IsView='Y' THEN 'VIEW' ELSE 'TABLE' END AS ObjectType,
 +
  COALESCE(t.Description,t.Name) AS Description
 +
FROM AD_Table t
 +
WHERE t.IsActive='Y'
 +
ORDER BY 1
 +
LOOP
 +
cmd := 'COMMENT ON ' || rec.ObjectType || ' ' || rec.TableName || ' IS ''' ||
 +
REPLACE(rec.Description,'''', '''''') || '''';
 +
RAISE NOTICE '%', cmd;
 +
        EXECUTE cmd;
 +
    END LOOP;
 +
    FOR rec IN
 +
SELECT t.TableName,
 +
  c.ColumnName,
 +
  COALESCE(c.Description,c.Name) AS Description
 +
FROM AD_Table t JOIN AD_Column c ON (c.AD_Table_ID=t.AD_Table_ID)
 +
WHERE t.IsActive='Y' AND c.IsActive='Y' AND c.ColumnSQL IS NULL
 +
ORDER BY 1,2
 +
LOOP
 +
cmd := 'COMMENT ON COLUMN '|| rec.TableName || '.' || rec.ColumnName || ' IS ''' ||
 +
REPLACE(rec.Description,'''', '''''') || '''';
 +
RAISE NOTICE '%', cmd;
 +
        EXECUTE cmd;
 +
    END LOOP;
 +
END $$;
 +
</syntaxhighlight>
  
 +
if SQL Error [42809]: ERROR: "t_spool" is not a view , set it is table.  NOTE: this was solved with [https://idempiere.atlassian.net/browse/IDEMPIERE-6592 IDEMPIERE-6592]
  
 +
<syntaxhighlight lang="sql">
 +
update ad_table set IsView ='N' where tablename ='T_Spool'
 +
</syntaxhighlight>command<syntaxhighlight lang="bash">
 +
java -jar schemaspy-6.2.4.jar -t pgsql -dp postgresql-42.7.6.jar   -db idempiere -host localhost -port 5432 -u adempiere  -p adempiere  -s adempiere -noimplied -o D://output
 +
</syntaxhighlight>[https://github.com/schemaspy/schemaspy?tab=readme-ov-file schemaspy github]
  
−
[[Category: Development]]
+
[https://schemaspygui.sourceforge.net/index.html#installation schemaspy GUI]
−
[[Category: financial accounting]]
+
[[File:Image.png|thumb]]
 +
[[File:Schema gui step2.png|thumb]]
  
−
[[Category: Account]]
+
[[Category:Development]]
−
[[Category: Developer documentation‏‎]]
+
[[Category:Developer documentation‏‎]]
−
[[Category: User Manual]]
+
[[Category:Database]]
 +
[[Category:financial accounting]]
 +
[[Category:Account]]
 +
[[Category:NeedsToBeUpdated]]
 +
 
 +
[[en:Database structure]]
 +
[[de:Darstellung der Datenbankstruktur]]

Latest revision as of 11:49, 27 June 2025

See the database structure in


This is made by schemaspy,you can made it by yourself,but it has some different, it is group by idempiere domain knowledge. See Tables by Module

You can fill the comments on postgresql database executing the following code:

DO $$
DECLARE
    rec RECORD;
	cmd varchar;
BEGIN
    FOR rec IN
		SELECT t.TableName,
			   CASE WHEN t.IsView='Y' THEN 'VIEW' ELSE 'TABLE' END AS ObjectType,
			   COALESCE(t.Description,t.Name) AS Description
			FROM AD_Table t
			WHERE t.IsActive='Y'
			ORDER BY 1
	LOOP
		cmd := 'COMMENT ON ' || rec.ObjectType || ' ' || rec.TableName || ' IS ''' ||
				REPLACE(rec.Description,'''', '''''') || '''';
		RAISE NOTICE '%', cmd;
        EXECUTE cmd;
    END LOOP;
    FOR rec IN
		SELECT t.TableName,
			   c.ColumnName,
			   COALESCE(c.Description,c.Name) AS Description
			FROM AD_Table t JOIN AD_Column c ON (c.AD_Table_ID=t.AD_Table_ID)
			WHERE t.IsActive='Y' AND c.IsActive='Y' AND c.ColumnSQL IS NULL
			ORDER BY 1,2
	LOOP
		cmd := 'COMMENT ON COLUMN '|| rec.TableName || '.' || rec.ColumnName || ' IS ''' ||
				REPLACE(rec.Description,'''', '''''') || '''';
		RAISE NOTICE '%', cmd;
        EXECUTE cmd;
    END LOOP;
END $$;

if SQL Error [42809]: ERROR: "t_spool" is not a view , set it is table. NOTE: this was solved with IDEMPIERE-6592

update ad_table set IsView ='N' where tablename ='T_Spool'

command

java -jar schemaspy-6.2.4.jar -t pgsql -dp postgresql-42.7.6.jar   -db idempiere -host localhost -port 5432 -u adempiere  -p adempiere  -s adempiere -noimplied -o D://output

schemaspy github

schemaspy GUI

Image.png
Schema gui step2.png
Cookies help us deliver our services. By using our services, you agree to our use of cookies.