Talend csv to relational db tables : foreign key setting - join

I'm a Talend beginner and searched about this simple problem, many have posted the web about the same problem but no solution appeared...
I have a csv file with 50 fields, I want to load it into a three tables relational database with Talend. I did a tMap, everything is ok except for foreign key : I don't know how to set them.
Here is my job
Here is my tMap
I hope someone could give me the simple exact solution
Cheers
Pascal

You can do it in two Time.
(CSV) -> (tmap) -> (organisation_output)
|
subjobok
|
| (organisation_input)
| |
(CSV) -> (tmap)-> (country and adress output)
Do a INNER JOIN in the second tmap on column that have unique value for each row.
And load 'ImpID' of your organisation input in the two other output table Impid column.

Related

call data from sql in processmaker

i have a table in sql which is like this:
| product code | weight|
| ----------------------|-----------|
| 1235896 | 0.5|
| 3256kms | 1.5|
| dk-kmsw | 3 |
and the data type for [product code] is nvarchar
now i want to call the weight by putting the product code in processmaker
the code that i wrote is this:
select [weight] from table where [product code] = ##textVar047
and by this code i get nothing, i have changed the ## to ##, #= but it did not work.
how can i do this?
any comment is appreciated.
When you use ## in the SQL of a control, it means you are referencing another control's value. If that's your scenario I'd suggest first to retrieve the full list of product codes in a Suggest control (instead of a Textbox) with this SQL:
select PRODUCT_CODE, PRODUCT_CODE FROM YOUR_TABLE_NAME
(you call product code twice since Suggest controls, like dropdowns, need 2 values to be filled up, one for the id and one for the label)
Now that you have a way to obtain the actual code and it's saved in the suggest control id, you can make another field a dependent field with the SQL you where proposing:
select WEIGHT FROM YOUR_TABLE_NAME where PRODUCT_CODE = ##your_suggest_control_id
(## should work just fine as it just adds quotes to the variable)
You can also check the wiki page to get an in depth explanation of this. https://wiki.processmaker.com/3.1/Dependent_Fields
I hope this helps!
select CAST(weight AS nvarchar(max)) from table where [product code] = ##textVar047

Sqlite3: Selecting from multiple tables without duplicates

I've got three tables:
paper: items: attachments:
============ ============== ==============
jkey | title itemID | jkey* itemID* | path
*foreign key from another table
I'm trying to retrieve the title of all papers and their associated attachment paths, for all papers that have attachments.
Current attempt is:
SELECT paper.title,attachments.path IN paper,attachments
WHERE paper.jkey IN (
SELECT items.jkey FROM items,attachments
WHERE items.itemID = attachments.itemID
);
Unfortunately this just seems to print gibberish (the same path for different titles and vice versa).
What am I doing wrong?
If you want to join, you should use joins:
SELECT paper.title,
attachments.path
FROM paper
JOIN items USING (jkey)
JOIN attachments USING (itemID);
To omit duplicate rows, use SELECT DISTINCT ... instead.

How to combine tables in qlikview

How can I merge two or three tables into one single table and make a big master table in QlikView?
Scenario : I have following 3 Tables. They all contain different facts but i want to merge them and make a big fact table.
(Table#1) Order_Case
OrderID | CaseID | CustomerID | WorkFlowID
(Table#2) Work_Flow
WorkFlowID | WorkFlowStatus | CreatedDate |
(Table#3) Product_Detail
CaseID | ProductID | SupplierID |
What I am trying to achieve : is I want to merge all this tables into a single table so the matching field data should merge and if the field does not match then it should show NULL against it.
This should work just fine, if its not, than you have a problem in one of the "key/join" fields:
Load OrderID ,CaseID,CustomerID,WorkFlowID resident Table#1;
join // or left join
Load WorkFlowID,WorkFlowStatus,CreatedDate resident Table#2;
join
load CaseID,ProductID,SupplierID resident Table#3;
You don't need those merging... as long you have the same Field Name
(as I noticed)
Order_case will be connected to Work_flow by field WorkflowID
and
Order_case will also be connected to Product_Detail by field CaseID
You just need to LOAD them in sequence (all three)
These are star-scheme fact tables, it is quite common and applicable in qlikview, you'll just need to "play along" with the filtering
Hope this can help...

How to show same column in dbgrid with different criteria

i need your help to finish my delphi homework.
I use ms access database and show all data in 1 dbgrid using sql. I want to show same column but with criteria (50 record per column)
i want select query to produce output like:
No | Name | No | Name |
1 | A | 51 | AA |
2 | B | 52 | BB |
3~50 | | 53~100| |
Is it possible ?
I can foresee issues if you choose to return a dataset with duplicate column names. To fix this, you must change your query to enforce strictly unique column names, using as. For example...
select A.No as No, A.Name as Name, B.No as No2, B.Name as Name2 from TableA A
join TableB B on B.Something = A.Something
Just as a note, if you're using a TDBGrid, you can customize the column titles. Right-click on the grid control in design-time and select Columns Editor... and a Collection window will appear. When adding a column, link it to a FieldName and then assign a value to Title.Caption. This will also require that you set up all columns. When you don't define any columns here, it automatically returns all columns in the query.
On the other hand, a SQL query may contain duplicate field names in the output, depending on how you structure the query. I know this is possible in SQL Server, but I'm not sure about MS Access. In any case, I recommend always returning a dataset with unique column names and then customizing the DB Grid's column titles. After all, it is also possible to connect to an excel spreadsheet, which can very likely have identical column names. The problem arrives when you try to read from one of those columns for another use.

Is it a good idea to use a foreign key to reference 2 or more tables?

Ruby on Rails ORM(object relational mapping) has a thing call polymorphic associations that allow a foreign key to be used to reference 2 or more other tables. This is achieved by creating an additional column called "type" that specifies the table with which the foreign key is associated with.
Does this implementation have a name from a database point of view? and is it good/bad practice?
thanks
Yes, using multiple keys to reference a unique record is known as a composite key. Whether it's good or bad practice is dependant on your database schema.
Example Scenario
Let's pretend that we have 4 tables: A, B, C and Z. Z maintains a reference to A, B, and C. Each record contains a reference to a single table. Below is two potential schema's for Z.
Single Foreign Key
We need a column to store the reference for each of the tables. That means we'll end up with NULL values for the unused columns. In future, if we introduce a D table, then we'll be required to add a new column to Z.
id | a_id | b_id | c_id
-----------------------
1 | 1 | NULL | NULL
2 | NULL | 1 | NULL
3 | NULL | NULL | 1
Composite Foreign Key
We start off with two columns for building a reference to the other tables. However, when we introduce D we do not need to modify the schema. In addition, we'll never have columns with NULL values.
id | z_id | z_type
------------------
1 | 1 | 'A'
2 | 1 | 'B'
3 | 1 | 'C'
Therefore, we can achieve some level of normalisation by using composite foreign keys. Provided that both columns are indexed, querying should be very fast. While it must be slower than using a single foreign key, the difference is insignificant.
Often it's tempting to use Rails' polymorphic associations whenever you have data that appears to be the same (Eg: Address). You should always exercise caution when coupling many models together. A good indicator you've gone too far is when you notice yourself switching based on the association type. A potential solution is to refactor common code out into a module and mix that into the models you care about instead.
Not all databases allow a composite foreign key and personally I'd shoot anyone who tried to do that to my database. Foreign keys MUST be maintained by the datbase not somethign like Rails. There are other processes which typically hit a database where this critical relationship must be checked which may not use an ORM (I certainly wouldn't use such a thing to import a 10,000, 000 record file or update a million price records or fix a data integrity problem.

Resources