Meet the brilliant yet eccentric Dr. Emmett Brown, better known as Doc. Hopelessly stuck in 2023, he is fixing his time machine to go back to the future and save his friend. His favourite online store FluxKart.com sells all the parts required to build this contraption. As crazy as he might get at times, Doc surely knows how to be careful. To avoid drawing attention to his grandiose project, Doc is using different email addresses and phone numbers for each purchase.
FluxKart.com is deadpan serious about their customer experience. There is nothing more important than rewarding their loyal customers and giving a personalised experience. To do this, FluxKart decides to integrate Bitespeed into their platform. Bitespeed collects contact details from shoppers for a personalised customer experience.
However, given Doc's modus operandi, Bitespeed faces a unique challenge: linking different orders made with different contact information to the same person.
Bitespeed needs a way to identify and keep track of a customer's identity across multiple purchases.
We know that orders on FluxKart.com will always have either an email
or phoneNumber
in the checkout event.
Bitespeed keeps track of the collected contact information in a relational database table named Contact
.
{
id Int
phoneNumber String?
email String?
linkedId Int? // the ID of another Contact linked to this one
linkPrecedence "secondary"|"primary" // "primary" if it's the first Contact in the link
createdAt DateTime
updatedAt DateTime
deletedAt DateTime?
}
One customer can have multiple Contact
rows in the database against them. All of the rows are linked together with the oldest one being treated as "primary” and the rest as “secondary” .
Contact
rows are linked if they have either of email
or phone
as common.
If a customer placed an order with
[email protected]
& phoneNumber=123456
and later came back to place another order with
[email protected]
& phoneNumber=123456
,
database will have the following rows:
{
id 1
phoneNumber "123456"
email "[email protected]"
linkedId null
linkPrecedence "primary"
createdAt 2023-04-01 00:00:00.374+00
updatedAt 2023-04-01 00:00:00.374+00
deletedAt null
},
{
id 23
phoneNumber "123456"
email "[email protected]"
linkedId 1
linkPrecedence "secondary"
createdAt 2023-04-20 05:30:00.11+00
updatedAt 2023-04-20 05:30:00.11+00
deletedAt null
}