Multiple foreign key joins between two tables
Hi,
I have a question about building a repository.
I have a date dimension and one fact. The fact table has about 10 foreign key columns that link to the date Dimension.
In this case should I create 10 aliases to create joins in the Physical and BMM layer or is there any other way to handle this situation.
I am asking this question because 10 aliases can get very confusing for me at the later point of time while creating reports.
Using OBIEE 10.1.3
Hi
I have a follow up question on this.
I am okay with not seeing the different date tables under the Subject area. Even if it just shows a it as a Simple DATE Dimension I am good with it.
In this case which is the efficient way, creating 10 aliases or creating 10 joins in the physical layer. I just figured out that we can create multiple joins between the same set of two tables but do not know how will that effect the way BI server works.
Please help me in understanding this concept.
thanks
This request id for OBIEE 10.1.3
Similar Messages
-
Foreign Key join between two columns in a dimension to one column in Fact
Hi,
I have a requirement to join two columns in a Dimension to the same column in the fact.
My reports contains columns from this dimension and will need to use both the joins to get the correct values. So I am not sure if I create an alias to join the second column, if that will be output incorrect values.
How can we achieve this so that I can still use columns from the dimension and still run both the joins in my SQL eventually.
Dimension
Column 1
Column2
Fact
Column 3
Need to map Column1--->Column 3 and Column2 -----> Column 3
ThanksI put it in Dimension and dimension extension scenario with a fact
The possible scenarios are:
1) Column1--->Column 3 and Column2 -----> Column 3
Both Column1 and Column2 have their own logical tables in BMM
2)
Column1--->Column 3
Column1--->Column2
In this case You have Logical table with 2 different sources Column1 and Column2 using column mapping.
you can go for multiple logical sources in this case, based on column selection tables in the join condition -
Subject: How to do join between two tables using something like SE16
SE16, SE11 provide form based interface query information from a single table. Is there a way to do join between two tables without creating an infoset erc? I am looking for something similar to sql join but in SAP BI 7.0
Thanks.Hi
Pls look into below links. Hope this helps you.
1. http://help.sap.com/saphelp_46c/helpdata/EN/d2/cb45bf455611d189710000e8322d00/content.htm
2. http://help.sap.com/saphelp_46c/helpdata/EN/d2/cb45a5455611d189710000e8322d00/content.htm
Regards
Sirigiri -
Multiple foreign keys to a single table
Hi,
I need to write an SQL sentence to bring a unique row formed from multiple foreign keys which are dependent on the same table. The two tables as follow:
CREATE TABLE UNIDADMEDIDA (
IDUNIDADMEDIDA NUMERIC(3) NOT NULL,
DESCRIPCION VARCHAR2(128) NOT NULL,
CONSTRAINT PKUM PRIMARY KEY(IDUNIDADMEDIDA)
CREATE TABLE TRANSPORTE (
IDBOLETA NUMERIC(12) NOT NULL,
CORRELAVEHICULO NUMERIC(2) NOT NULL,
TIPOVEHICULO NUMERIC(1),
TIPOGASOLINA NUMERIC(1),
CANTIDAD NUMERIC(8),
RECORRIDOPROMEDIO NUMERIC(10,2),
IDUMRECORRIDO NUMERIC(3),
CONSUMOPROMEDIO NUMERIC(10,2),
IDUMCONSUMOPROM NUMERIC(3),
CONSUMOTOTALANUAL NUMERIC(10,2),
IDUMCONSUMOTOT NUMERIC(3),
CONSTRAINT PKTRANSPORT PRIMARY KEY(IDBOLETA, CORRELAVEHICULO),
CONSTRAINT FKUMRECORRI FOREIGN KEY(IDUMRECORRIDO) REFERENCES UNIDADMEDIDA(IDUNIDADMEDIDA),
CONSTRAINT FKUMCONSUMO FOREIGN KEY(IDUMCONSUMOPROM) REFERENCES UNIDADMEDIDA(IDUNIDADMEDIDA),
CONSTRAINT FKUMCONSTOT FOREIGN KEY(IDUMCONSUMOTOT) REFERENCES UNIDADMEDIDA(IDUNIDADMEDIDA)
The columns IDUMRECORRIDO, IDUMCONSUMOPROM and IDUMCONSUMOTOT depend on the table UNIDADMEDIDA (specifically from the IDUNIDADMEDIDA field). I need to bring back the description (DESCRIPCION field) from the different values stored in TRANSPORTE table.
Thanks for your help!!!
MarioWelcome to the forum!
Have you thought about joining against the parent table three times to pick up each different description?
SELECT <COLUMN LIST>
, UNI_A.DESCRIPCION
, UNI_B.DESCRIPCION
, UNI_C.DESCRIPCION
FROM TRANSPORTE
JOIN UNIDADMEDIDA UNI_A ON UNI_A.IDUNIDADMEDIDA = TRANPORTE.IDUMRECORRIDO
JOIN UNIDADMEDIDA UNI_B ON UNI_B.IDUNIDADMEDIDA = TRANPORTE.IDUMCONSUMOPROM
JOIN UNIDADMEDIDA UNI_C ON UNI_C.IDUNIDADMEDIDA = TRANPORTE.IDUMCONSUMOTOT
;It is always helpful to provide the following:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
You provided #2 partially. If you provide the rest we may be able to help you even further. -
Doubt on creating join between two tables
Hi friends,
I have two tables , ekes and eine
my requirement is if Ekes-ebtyp = 'X1'.
then Ekes-ebtyp = EKES-EINDT + Eine-j_3alitra.
the doubt is there is no primary key common between this table . actually in my whole program for purchase order i used EBELN for extracting details when two tables are involved . in this two tables no two primary keys are common to extract data ...is there any ways please suggest..
the code i wrote is
loop at li_ekes assigning <fl_ekes>.
read table li_eine assigning <fl_eine> with table key (here i need to give some unique fields to join these two fields please guide me which field i can use.).
<fl_ekes>-ebtyp = <fl_ekes>-EINDT + <fl_eine>-j_3alitra.Hi,
Both tables have field EBELN in common.
You can use it to extract data from both.
Hope this helps.
reward if helpful.
Regards,
Sipra -
Join between two tables in SAP ( actual sales vs budget sales)
I have one table with actual data sales in SAP .This table has a name CE11000
This table contain amounts about : customers ,Products, Quantity of Sales ,amount of sales ,month witch did the sales and the year.
The other table from SAP has the budget sales . This table is CE21000
This table contain the same fields : customers ,Products, Quantity of Sales ,amount of sales ,month witch did the sales and the year but all this for budget .
In the budget table ( CE21000)there are no records for a particular make if it was not budgeted to make a sale.
Sometimes i have the same problem with the actual data table (CE11000) ...I have not records witch can use to join the results for a report witch take the comparison between actual sales and budget sales.
I would like to remind you that the report should have four "dimensions"
a) year
b) month
c) customer
d) type of product
I try to use left outer join with a customer fields in two tables but i have simultaneously the field with type of product .
I want to see in one year (for example february of 2011) for one customer the type of products (quantity and anmounts) witch buy (ACTUAL) and that to compare with the corresponding data if available
Any help would appreciate
thanksHaggar
Your first query matches on two conditions BOTH being true. If there is a D and no matching E, you'll see the columns from D but none from E.
Your second query takes all Emplyees, and lines up 2 (possibly different) rows from D against each
E columns | D columns (match e.deptid=d.dept_id) | D columns (match ep_id=de_id)
So you may have any mix of:
E | D1 | D2
E | nothing | D2
nothing | D1 | D2
E | D1 | nothing
E | nothing | nothing
nothing | D1 | nothing
nothing | nothing | D2(NB I'm assuming FULL OUTER JOIN is commutative - ie the order is unimportant - but I may be wrong in which case the last row won't occur)
You will get a different number of rows (as well as different columns) in each case.
Try it!
Regards Nigel -
hello all,
can anyone help me write an outer join b/n the two tables below. The joining condition has if's and or's.
table 1 has 2 million rows, table 2 is very small
TABLE1
CUSTOMER_ID
CITY
STATE
1
SKOKIE
IL
2
CHICAGO
IL
3
CARY
NC
ERIE
PA
PHILLY
PA
CHARLOTE
NC
2 MILLION
CITYXY
STATEX
TABLE2
CITY
STATE
CONTACT
IL
OJO
ERIE
BRITT
PA
MIKE
PITTSBURG
PA
HILTON
N043
TAT
affi
B
affi
R
b0b
Q
b0b
CHARLOTE
NC
b0b
problem :: for all the data in table1, I need to find out the CONTACT from table 2 And the join condition would be as below
1. either both TABLE1.CITY=TABLE2.CITY AND TABLE1.STATE=TABLE2.STATE and get CONTACT
OR
2. TABLE1.CITY=TABLE2.CITY AND TABLE2.STATE IS NULL and get the value of CONTACT
OR
3. TABLE1.STATE=TABLE2.STATE AND TABLE2.CITY is null and get the value of CONTACT
I need a query like this
SELECT A.CUSTOMER_ID, A.CITY, A.STATE, B.CONTACT
FROM TABLE1 A, TABLE2 B
WHERE (join condition fitting in the 3 condition mentioned above)Dear OP,
Do you want something like this?
> with t1 as
-- Start of SAMPLE DATA
(select 1 CUSTOMER_ID, 'SKOKIE' CITY, 'IL' STATE from dual union
select 2, 'CHICAGO', 'IL' from dual union
select 3, 'CARY', 'NC' from dual union
select 4, 'ERIE', 'PA' from dual union
select 5, 'PHILLY', 'PA' from dual union
select 6, 'CHARLOTE', 'NC' from dual)
t2 as
(select null CITY, 'IL' STATE, 'OJO' CONTACT from dual union
select 'ERIE', null, 'BRITT' from dual union
select null, 'PA', 'MIKE' from dual union
select 'PITTSBURG', 'PA', 'HILTON' from dual union
select 'N043', 'TAT', 'affi' from dual union
select null,'B', 'affi' from dual union
select null,'R', 'b0b' from dual union
select null,'Q', 'b0b' from dual union
select 'CHARLOTE', 'NC', 'b0b' from dual
--- END IF SAMPLE Data
select * from t1 full outer join t2
on ( nvl(t1.city,t2.city) = nvl(t2.city,t1.city)
and nvl(t1.state,t2.state) = nvl(t2.state,t1.state) )
order by 1,2,3,4
CUSTOMER_ID CITY STATE CITY STATE CONTACT
1 SKOKIE IL IL OJO
2 CHICAGO IL IL OJO
3 CARY NC
4 ERIE PA ERIE BRITT
4 ERIE PA PA MIKE
5 PHILLY PA PA MIKE
6 CHARLOTE NC CHARLOTE NC b0b
N043 TAT affi
PITTSBURG PA HILTON
B affi
Q b0b
R b0b
12 rows selected
Elapsed: 00:00:00.112
Hope this is helpful. If not please let us know what is you desired result (sample) if your data was like above?
vr,
Sudhakar -
Joins between two tables generating Cartesian product
Hi All,
I am facing an issue in my report in which, I am getting mismatch as the two subsets which I'm joining is resulting in a cartesian product of individual subset's results. I am doing left join to join those two subsets. Please help in resolving
this issue.
Thank you,
Anu.Hi,
Can you please post your script to see what is causing the cartesian product?
This way it is difficult to help you.
Regards,
Reshma
Please Vote as Helpful if an answer is helpful and/or Please mark Proposed as Answer or Mark As Answer when question is answered -
Update Multiple Column with Single Command with Join between Two tables.
This is our command where we are trying to update a table's two columns by pulling values from another table after joining. This query takes too much time to execute. Any suggestions ?
UPDATE raw_alc_rmfscombinednew
SET (BSC, CELL_NAME) =
SELECT distinct raw_alc_R110combinednew.BSC, raw_alc_R110combinednew.CELL_NAME
FROM raw_alc_R110Combinednew
WHERE
raw_alc_R110Combinednew.OMC_ID = raw_alc_rmfscombinednew.OMC_ID
AND raw_alc_R110Combinednew.CELL_CI = raw_alc_rmfscombinednew.CI
AND RAW_ALC_R110COMBINEDNEW.START_TIME = RAW_ALC_RMFSCOMBINEDNEW.START_TIME
Results of Last execution:
Elapsed Time (sec) 4,476.56
CPU Time (sec) 4,471.88
Wait Time (sec) 4.68
Executions that Fetched all Rows (%) 100.00
Average Persistent Mem (KB) 32.43
Average Runtime Mem (KB) 31.59
--------------------------------------------------------------Your update requires a full execution of the subquery for each row in the destination table (raw_alc_rmfscombinednew). Try rewriting as a MERGE. Tons faster.
MERGE INTO raw_alc_rmfscombinednew D
USING ( SELECT distinct
BSC,
CELL_NAME
START_TIME
FROM raw_alc_R110Combinednew ) S
ON ( S.OMC_ID = D.OMC_ID
AND S.CELL_CI = D.CI
AND S.START_TIME = D.START_TIME )
WHEN MATCHED THEN
UPDATE
SET D.BSC = S.BSC,
D.CELL_NAME = S.CELL_NAME -
Inner Join between two big tables
Hi There,
I have a situation where in which I have to write an inner join between two table of the order of (30k to 60 rows).
My query is as simple as,
select A.a,B.b from A ,B where A.a = B.b;
N.B: a and b are of type varchar
But the problem is it takes nearly 15 mins to run. Is there any better way of doing an inner join between such bigger tables?
Thanks,
Jose John.Thank you all for your help.....Indexing works....:)
--JJ -
Hi
I need data from two different schemas. Can develop one subject area taking 2 tables from 2 different schemas or we need to have these two tables from one schema only ?
Can any one help on this.
Thanks
ManuHi,
When you try to create physical join between these two tables of different schemas.
The join condition is REGION.REGION_CODE = REGION.REGION_ID
Note: The table name is same in both the schema.
Now as soon as I click on Ok, it gives an error.Because You can not create join between two tables with the same name.
So, create alias for these two tables and try to create the join with the same join condition.
It allowed me to create join perfectly. I moved ahead with the creation of Subject Area based out of these two tables.
Opened Presentation Services, selected few attributes from both the Presentation folders.But it gave ODBC error as :
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46036] Internal Assertion: Condition m_CountFields == static_cast<int32>(m_ColumnNameVector.size()), file .\Src\SQCSCacheStorageListStream.cpp, line 221. (HY000)
Now in order to fix that issue, rename the base tables as Schema1_name.REGION and Schema2_name.REGION in the repository.
Reload the rpd and run the same report, it would give correct result.
But instead you can have the tables in the same schema for better maintenance activities.
Hope this solved your question.
Regards
MuRam -
Sql join on two tables where column like another column
hi all,
been trying to get the results from a join between two tables where one column is like another one.
table1 (nameA) examples: black2, green1
table2 (nameB) example: black2.location.uk.com, green1.location.uk.com
so for example I want to match all those in table1 with black2 to the column in table2 that begins with black2 and so on if you see what im trying to get at!
my sql so far:
select * from schema.table1 a
join schema.table2 b
on a.nameA like concat('%', b.nameB, '%'); but it errors:
ORA-00909: invalid number of arguments
00909. 00000 - "invalid number of arguments"
Any help or advice would be greatly appreciated, thankyou!Either of these should do it...
select * from schema.table1 a
join schema.table2 b on a.nameA like '%'||b.nameB||'%';or
select * from schema.table1 a
join schema.table2 b on instr(b.nameB,a.nameA) > 0 -
Update query with multiple foreign key parameters
I am trying to perform an update query on one field that uses multiple foreign key parameters from one table to update the other table. The data in all three foreign key parameter fields are not constant. Accuracy is absolutely critical. I tied this as well as other various scenarios with no success. Can anyone help?
Update A_table a
set a.rate = (
select b.rate
from B_table b
where b.id = a.id
and b.transdate = a.transdate
and b.orgnum = a.orgnum
and b.transdate = to_date('31/12/2007', 'dd/mm/yyyy')
)I would check symbols by a user name and number of posts before calling anyone a hot shot, especially damorgon.<br><br>
Yes version matters (due to bugs and features in each version).<br>
DDL matters because of indexes and associations.<br>
Data matters because it makes a difference on how SQL can be written.<br>
Reasons why an SQL statement don't work is because we aren't looking over your shoulder at your screen.<br><br>
damorgon did leave off his list that the best place for this question is on the PL/SQL, where they will ask you similar questions in addition to your explain plan and data volumes. -
Prcedure to joining of two tables and pls explore the primary & foriegn key
Dear All,
Am new to this forum looking forward to have some discussions and guidance reg ABAP.
<b>My query is</b>
what is the prcedure to joining of two tables and pls explore the primary & foriegn key relationships.
Your kind help is required in this query .
Thanks n regards
Carol PHi Carol,
Joining two tables fetch data from tables that has relevent entry based on the keys. like LIKP and LIPS these are delivery tables. if the business requirement is fetching delivery data that are exists in both two tables. here LIKP will conatins a single entry against a condition and LIPS may contains several entry because one delivery may has multiple line items. so, fetch the data joining the two tables on vbeln that is delivrey number. this is used to increase the performance of the program except for all entries.
Foreign key is poiting twowards primary key; it may be 1:1 , 1:many and many:many. if field1 of table a is pointing towards field1 of table b. then based on these condition at the time of entry SAP will check how many entry can be entred in field1 of table a.
regards
Krishnendu -
Questions about creating a foreign key on a large table
Hello @ll,
during a database update I lost a foreign key between two tables. The tables are called werteart and werteartarchiv_pt. Because of its size, werteartarchiv_pt is a partitioned table. The missing foreign key was a constraint on table werteartarchiv_pt referencing werteart.
Some statistics about the sizes of the mentioned tables:
werteart 22 MB
werteartarchiv_pt 223 GB
werteartarchiv_pt (Index) 243 GB
I tried to create the foreign key again, but it failed with the following error (Excuses for the german error message):
sqlplus ORA-00604: Fehler auf rekursiver SQL-Ebene 1
sqlplus ORA-01652: Temp-Segment kann nicht um 128 in Tablespace TEMPS00 erweitert
The statement I used:
alter table werteartarchiv_pt
add constraint werteartarchiv_pt_fk1
foreign key (schiene, werteartadresse, merkmale)
references werteart (schiene, werteartadresse, merkmale)
on delete cascade
initially deferred deferrable;
So the problem seems to be, that Oracle needs a lot of temporary tablespace to generate the foreign key and I do not know how much and why.
My questions now are, and hopefully someone is here, who can answer all or a part of it:
1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.
2a) Is it possible to tweak the statement without using the temporary tablespace?
2b) If it is not possible to avoid the usage of the temporary tablespace, is there a formula how to calculate the needed temporary tablespace?
3) Is it possible to modify data in the tables while the foreign key is created or is the whole table locked during the process?
Any help or hint is appreciated.
Regards,
BjoernRollinHand wrote:
My questions now are, and hopefully someone is here, who can answer all or a part of it:
1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.Because it's validating the data to ensure the foreign key won't be violated. If you had specified ENABLE NOVALIDATE when creating it then the existing data in the table wouldn't need to be checked and the statement should complete instantly (future data added would be checked by the constraint).
http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/general005.htm
Search for "Enable Novalidate Constraint State"
Maybe you are looking for
-
Mailto: Link doesn't work in Safari
In my project, we have a link to open a outlook mail. when i open the link in IE/Chrome/Firefox browser, it opens the outlook with the given mail id. But, same link was not working properly in safari browser. I am using safari version 5.1.7(7534.57.2
-
Why dosen't h:messages work well under Facelets?
My code looks as follow: <h:messages layout="table" showDetail="true" style="color: red; font-family: 'New Century Schoolbook', serif; font-style: oblique; text-decoration: none" id="errors" /> This means, the error message will be shown in red and i
-
Weird issue with Purchased Song!
I just downloaded "Your Graudin Angle" by Face Down. The song is listed for 5:12 but nothing plays between 3:48 and 5:12. What is wrong?
-
ORABPEL-10516 - Beehive Custom Workflow Tutorial
Hi all, I am (still) trying to set up the Beehive custom workflow tutorial. The BPEL process fails: Faulted while invoking operation "initiateTask" on provider "TaskService" ORABPEL-10516 Identity Service cannot find user. Error occurs while getting
-
Why I can´t install 8GB RAM DDR3 1333MHZ in a MacBook late 2009?
Why I can´t install 8GB RAM DDR3 1333MHZ in a MacBook late 2009?