Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover the Trends Shaping AI in 2026: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Fill a simple 1-N relation

Hello everybody.

I need to fill mainly, two tables: users and files. So, each user has several documents and a file has only one owner (user).

First, I understand I need to generate a sample users. I'm using tRowGenerator with (id, username, firstname, lastname) schema.
Otherwise, I'm using a tFileList component in order to "generate" a list of files on a (filename field) schema. I'd like to merge this data (users and files).

I'm quite figuring out I need a tMap component, however, I don't know how to relate users and filename...
I'll appreciate a lot any help.
Thanks for all.

Labels (2)
9 Replies
Anonymous
Not applicable
Author

Hi,
Have you already checked component reference TalendHelpCenter:tMap with scenarios?

I'm quite figuring out I need a tMap component, however, I don't know how to relate users and filename...


Would you mind setting an example with input and expected output result so that we can design a demo job for you?



Best regards
Sabrina
Anonymous
Not applicable
Author

1. I'd like to fill a simple users collections (id, username, firstname, lastname)
2. For each created user, I'd like to assign several filenames assigned to each user.
Anonymous
Not applicable
Author

OK, this looks like an experiment with using Talend since you are using a tRowGenerator to generate users, etc. Therefore, the answer is simple. You need to assign a "key". This should be a number. Each user generated should have a number assigned to it. So if you have 10 users, the numbers could be 1 to 10. Then when you are getting the files from the file list, generate a random number (between 1 to 10) and assign it to the file. This will mean that a user can have several files, but a file can only have 1 user. Then you simply create an inner join in the tMap using the user number
Anonymous
Not applicable
Author

Ok, thanks rhall. I've gone ahead.
However, I'm indexing 1000 rows (users), but I'm inserting 1000 files yet. I'd like to insert every file generated.
As you can see, I'm generating 1000 users and 20000 files. However I'm indexing 1000 users but only 1000 files.
Anonymous
Not applicable
Author

If you have added a screenshot, I can't see it I'm afraid.
Anonymous
Not applicable
Author

I've attached it again...

Anonymous
Not applicable
Author

OK, I think I can see what you are saying. Can you take a screenshot of your tMap component? Also, how are you assigning a user number to the files? Have you assigned a random user number to the files?
Anonymous
Not applicable
Author

Yes, I've assigned a random number between 0-1000 to user_id on tIterateFlow component (row3 input on tMap).

Anonymous
Not applicable
Author

I see. You need to change the files input (row3) to be the "Main" input and the users input (row1) to be the "Lookup". The "Main" input drives the process. So every row received will be processed. The users input is simply a lookup here.

I should point out that this is not the only way of achieving this. You can leave it as it is and click on the spanner symbol on the row3 input. If you set the "Match Model" to "All Matches" and the "Join Model" to "Inner Join", it should do this as well.

My first suggestion is based on the fact that this process looks like it is driven by the files and not the users. The dataset that is driving the process should usually be the "Main" input.