0

My question is related to the ER-diagram I designed using Oracle SQL developer. I designed this ER-diagram but I don't know how to read the relationships between these tables.

I have created this ER diagram:

ER Diagram

As it can be seen that these relations don't look like those normal one to many or many to one relations. Can anyone please help me how to read the relation between SYS.GENERAL_LEDGER_ACCOUNTS and SYS.INVOICE_LINE_ITEMS? Thanks in advance

MT0
  • 143,790
  • 11
  • 59
  • 117
  • **NEVER** modify the system schemas. You should always create your own user and then create tables in that schema. – MT0 Sep 23 '22 at 13:24
  • It means that each row GENERAL_LEDGER_ACCOUNTS can be related to multiple rows in INVOICE_LINE_ITEMS. Also, never use the SYS schema for you objects. – gsalem Sep 23 '22 at 13:25
  • Thank you so much for identifying my mistake. Highly Appreciated. – Andrew Sky Sep 23 '22 at 13:58

1 Answers1

0

The relationship is described by the foreign key:

ALTER TABLE invoice_line_items
  ADD CONSTRAINT line_item_fk_accounts
  FOREIGN KEY (account_number)
  REFERENCES general_ledger_accounts(account_number);

Defines a foreign key with the name line_item_fk_accounts on the column account_number which references the account_number of the general_ledger_accounts.

Assuming that it is notNULL then this is a many-to-one relationship such that each row of invoice_line_items has a relationship to exactly one row in the general_ledger_accounts and there can be many invoice_line_items for each general_ledger_accounts.


Similarly, line_items_fk_invoices is a many-to-one constraint with many invoice_line_items each referencing one row of the invoices table.


Aside: NEVER modify the system schemas. If you do you risk making the database unusable and invalidating any support contract that you have with Oracle. Instead, you should create a user and then work in that schema.

MT0
  • 143,790
  • 11
  • 59
  • 117