I want to store ids in an array and attach them to an address. For example: There are 0 houses. User1 buys an house so id 0 gets added to the array userHouses[msg.sender]. User2 buys 2 houses so it 1 and 2 gets added to userHouses[msg.sender]. user1 buys another house, id 3 gets added to userHouses[msg.sender] and so on. I could do
mapping(uint => address) houseOwner;
houseOwner = msg.sender; // User1 houseOwner = msg.sender; // User2 houseOwner = msg.sender; // User2 houseOwner = msg.sender; // User1
But when there are 1.000.000 houses of 10.000 users it gets too much. So I want instead 10.000 arrays for each address and simply add the houses into that address (like houses[msg.address]). Also it's easier and cheaper to loop only houses of the user instead of looping all houses and check if the house owner is the user.
I know how to make an array (
uint houses) but I don't know how to make arrays for each address (