0

I am working on rent agreement and I have a situation here

  1. One landlord can have multiple properties
  2. every property have different details (property details, values)

now I want to link property details to property id also want to link id's to landlord address.

0

Contain owner's information in one mapping, where one variable can be an array of property Ids and create another mapping for each property Id to its relevant information.


    struct owner{
        uint[] propertyIds;
        uint totalarea;
        address[] clients;
    }
    mapping (address => owner) owners;

    struct property{
        uint id;
        string location;
        string area;
        uint price;
    }
    mapping (uint=> property) properties;

Or if you don't want to store anything else for an owner, you can directly map an address to an array.


struct property{
    uint id;
    string location;
    string area;
    uint price;
}
mapping (address => property[]) owners;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.