Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Merging Rule
- Tables
- rated table
- columns: [ratedId,fName,mName,lName,gender,ratedMergeId]
- rated_contact table
- columns: [ratedContactId,ratedId,contactTypeId,value]
- contact_type table
- columns: [contactTypeId,name,urlTEmplate]
- rated_merge table
- columns: [ratedMergeId,timestamp,ratedId]
- 1. Check form kung meron matching entry sa database if walang matching entries walang merging na magaganap
- 2. Kung may match na entry sa form at entry sa database dun papasok yung merging.
- 3. So pano yung merging?
- 3.1 lahat ng previous records na matching gagawan ng bagong record at imemerge lahat ng data nun.
- Flow:
- Upon submission ng form lahat ng form entries papasok sa rated and rated_contact table
- ano ano yung mga entries na yun?
- {firstName
- middleName
- lastName,
- gender,
- city
- dateOfBirth,
- social network usernames (twitter,facebook,instagram, etc, meron po silang dedicated input boxes sa form);
- }
- ganito po ang gusto kong gawin.
- kapag may nag-match, gagawa po ng new entry, ang laman po nitong new entry ay yung mga previous record na meron na at yung bagong record na wala pa.
- paano malalaman kung may match?
- for example po: nag input ang user ng facebook and twitter username.
- ichecheck po kung may matching sa rated_contact table na username.
- for example merong pong exisiting na entry sa rated at rated_contact table
- _____________________________________________________________________________
- | ratedId | fName | mName | lName | gender |ratedMergeId|active|
- -----------------------------------------------------------------------------
- |1048 | Altair | Ibn | La Ahad | male | | 1 |
- -----------------------------------------------------------------------------
- ___________________________________________________
- |ratedContactId | ratedId | contactTypeId | value |
- ---------------------------------------------------
- |1 | 1048 | facebook |altair |
- ---------------------------------------------------
- then yung user nag input sya sa form ng facebook at twitter username
- then upon submission ng form nakita ng system na nagmatch yung facebook username na ininput ni user at yung existing sa database
- ang mangyayari ngayon, kukuhanin yung facebook username at twitter username, pati yung personal information na galing sa form
- yung previous record galing database will be marked sa deleted (not totally deleted meron isang column sa db for marking as deleted)
- then yung latest entry na galing kay user yun ang magiging active entry containing both twitter and facebook usernames.
- rated table
- _____________________________________________________________________________
- | ratedId | fName | mName | lName | gender |ratedMergeId|active|
- -----------------------------------------------------------------------------
- |1048 | Altair | Ibn | La Ahad | male | | 0 |
- -----------------------------------------------------------------------------
- |1049 | Altair | Ibn | La Ahad | male | | 1 |
- -----------------------------------------------------------------------------
- |ratedContactId | ratedId | contactTypeId | value |
- ---------------------------------------------------
- |1 | 1049 | facebook |altair |
- ---------------------------------------------------
- |2 | 1049 | twitter |altair |
- ---------------------------------------------------
- kung mapapapansin po ninyo sa table sa taas nagbago yung ratedId dahil po yung latest record sa rated table is yung 1049 na id at marked as active sya then yung previous marked a inactive (0).
- paano naman yung ratedMergeId?
- sa bawat merging po na magaganap dito po malalagyan ng record yung rated_merge na table
- ___________________________________________________
- |ratedMergeId | timestamp | ratedId |
- ---------------------------------------------------
- |1 | 02/04/2016 14:04:55 | 1049 |
- ---------------------------------------------------
- then yung bagong insert na ratedMergeId iuupdate iya yung previous at active record
- _____________________________________________________________________________
- | ratedId | fName | mName | lName | gender |ratedMergeId|active|
- -----------------------------------------------------------------------------
- |1048 | Altair | Ibn | La Ahad | male | 1 | 0 |
- -----------------------------------------------------------------------------
- |1049 | Altair | Ibn | La Ahad | male | 1 | 1 |
- -----------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement