Saturday, September 19, 2020

Azure - Azure Storage Table (AZ)

Azure tables are ideal for storing structured, non-relational data. Common uses of Table storage include:
  • Storing TBs of structured data capable of serving web scale applications
  • Storing datasets that don't require complex joins, foreign keys, or stored procedures and can be denormalized for fast access
  • Quickly querying data using a clustered index
  • Accessing data using the OData protocol and LINQ queries with WCF Data Service .NET Libraries

    Retreive Entity
    TableOperation TO = TableOperation.Retreive(PartitionKey, Rowkey);
    TableResult TR = TableEmp.Execute(TO);
    EmpEntity emp = TR.Result;

    Update Entity
    Update proprties of emp
    TableOperation TO = TableOperation.Replace(emp);
    TableEmp.Execute(TO)

    Delete Entity
    TableOperation TO = TableOperation.Delete(Entity)
    TableEmp.Execute(TO)


    Optimization Techniques

  1. Read First: Read first the entity using Partition name + Row key
  2. Multiple Keys: Keep multiple keys, if data is duplicating no worries
  3. Compound Key: You can make Row key as a compound key
    Ex. If you store 2 values (Id and Email) in Row key, you can search with any of the mob. or email, this is a compound key. Id_<Id> and Email_<Email>

    PartitionKey
    RowKey
    EmpName
    Employee
    Id_1001
    Megha
    Employee
    Id_1002
    Renuka
    Employee
    Tomar
    Employee
    Mukesh
  4. Avoid unnecessary tables: Try to keep all related entities in one table separated by Partition key. Makes transactions smooth (commit/rollback)
    Ex. Emp, EmpDetails
  5. Inter Partition Pattern: Keeping multiple type values in row key
    Keeping multiple values to divide search load, like people searching with email id will search with a key like "Email_ %"

    Compound Key example (point no.3) is an Inter Partition pattern example.
  6. Intra Partition Pattern: Dividing search by using multiple Partition key is Intra Partition Pattern.

    PartitionKey
    RowKey
    EmpName
    EmployeeId
    1001
    Megha
    EmployeeId
    1002
    Renuka
    EmployeeEmail
    Tomar
    EmployeeEmail
    Mukesh
     
  7. Delete Partition Pattern: This enables bulk delete. When you delete data based on the partition key.
    Ex. you can delete any month data in a single operation.

    PARTITIONKEY

    ROWKEY

    EMPNAME

    EMPLOYEE-JAN20
    1001
    Megha
    EMPLOYEE-JAN20
    1002
    Renuka
    EMPLOYEE-JAN20
    1003
    Tomar
    EMPLOYEE-FEB20
    1004
    Mukesh
    EMPLOYEE-FEB20
    1005
    Kailash

  8. Large Entity Pattern: In case you are storing image/binary data you can use blog to store 
  9. Long table Pattern: In case you have large no. of columns in your entity

No comments:

Post a Comment

CI/CD - Safe DB Changes/Migrations

Safe DB Migrations means updating your database schema without breaking the running application and without downtime . In real systems (A...