Finding relationship between two tables - oracle

I have two tables tbl_customer and tbl_policy and i need to join these two tables. But there is no direct relationship of Pkey and Fkey between these two tables. In this case i know that tbl_customer has a field int_policy and in tbl_policy and its primary key int_policy_pk and these two column can be used to join the table.
But in a generalized way i need to write a function to find this relationship (If i don't know about those fields). Is there any algorithms or other ways to do this?

Related

ER diagram Relationship among tables

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
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.

(Powequery) How to call different functions based on a list of tables

I have a list of tables in Powerquery after partitioning from an original big table. I am trying to perform a nested join on each of the tables. Each of the 3 tables will have its own nested join, although the tables joined to and the key-containing columns are different for each table. Eg. List contains table1, table2,table3, table1 to be joined to Table A with table1[Host] as the key, table2 to be joined to Table B with table2[Location] as the key, table3 to be joined to Table C with table3[Name] as the key.
I can do the joins on each table separately (as opposed to having a list of tables), and then combine the output, but it gets unwieldy if there are many tables to be joined. Was wondering if there is a "neater" way to do so.
On a related note, is it possible to invoke different functions (1 function for each table in a list of tables), and how?
Cheers

Table joins in BigQuery

Do you know if there's a way to join two tables by, for
example, using a foreign key constraint like in MySQL (I don't seem to
find anything about this) ? If not, is there a replacement ?
Thanks!
I interpret your question as below -
Is there a way to limit the values that can be used on the tableX to only the IDs that exist on the tableY? For example via using a foreign key constraint like in MySQL!
BigQuery does not provide any direct mechanism for this to happen.
But you can easily achieve this by yourself.
For example, assume you need to insert some data to tableX, but you want to make sure that only those rows will be inserted where id in that new data is in tableY
So, you can "enforce" this via below query
#standardSQL
SELECT n.*
FROM newData AS n
JOIN tableY AS y
ON n.id = y.id
... you can run this query with tableX as destination and ONLY needed rows will be inserted
Hope you got an idea
Also you can check existing related feature requests -
https://issuetracker.google.com/issues/35906045
https://issuetracker.google.com/issues/35906043
Since you asked two questions (Stack Overflow suggests asking 1 question per question), I'll answer one:
Also, do you know if there's a way to join two tables by, for example,
using a foreign key
In BigQuery you can join tables by any key - even by keys defined on the fly (this is pretty useful when you need to join two tables from different datasets that choose to encode identical values in different ways).
Why would you need a foreign key to do these joins?

How do I link two parse tables per common field?

I have a simple relationship between two parse tables (objects).
Both contain a 'name' string column.
All I need to do is to create a join between the two tables per 'name' column.
For example:
Table A (main) <--> Table B (ancillary)
where
'A.name' == 'B.name'.
Table A is the driving table: all criteria focuses on Table A.
Table B is the ancillary table that has a particular field (column) needed for Table A's result.
Note: the tables don't have any formal relation with each other.
What is the correct Parse syntax to allow this to happen?
...or must I make two queries instead on one merged query?

LINQ: I have 3 tables and I want to make 2 join tables

I have three tables, Question, SubjectType and CoreValue.
Question table has many to many association to SubjectType table and CoreValue table.
I want to make 2 join tables: one between Question and SubjectType and one between Question and CoreValue.
How do I make sure that the Association tables with CoreValue FK and Question FK gets filled without inserting any values in Corevalue? CoreValue Table already have the values that is needed. I just need to be able to have FK on Question and Corevalue in same association table without inserting any data same goes to Question and SubjectType.
Thanks for advice!
Best Regards!
Just create the tables as pure join tables in the database.
EF will generate a model with navigation properties (Question - SubjectTypes, and so on). You probably want to remove the associations SubjectType.Questions and CoreValue.Questions.
See also this tutorial (the Class-Student part).

Resources