Showing posts with label Data base management system. Show all posts
Showing posts with label Data base management system. Show all posts

Thursday, November 1, 2018

Firebase Realtime database and firebase cloud firestore

Firebase  කියන්නෙ අපිට  back end services  ගොඩක් ලබාදෙන  googleලගෙ  feature එකක්  gooogle account  එකක් තියෙන ඕනිම කෙනෙක්ට  firebase features use  කරන්න හැකියාව තියෙනව

firebase features:-
1.realtime db
2.cloud storage
3.user authentication
4.static hosting
5.cloud messaging
6.authentication
7.ML kit etc.

අපි අද කතා කරන්න යන්නේ 'cloud firestore' ගැන.

 ඒ අය ලගදි (ලගදි කීවට ලගදිම නෙවෙයි ) ලබදුන්න  feature  එකක් තමයි "Cloud firestore" කියන්නෙ ඒක "Firebase realtime database" වලට
සමාන  (Firebase realtime database වල තියෙන්නෙ  json tree format  එකක් ).හැබැයි  cloud firestore  කියන මේ අලුත්  feature  එකේ
 data save  කරගන්නේ  'documents'( ඒ කියන්නෙ  key-value pair  විදිහට ).වල හා  collection ( document  වල  collection) විදිහට

 මේ උඩ තියෙන්නෙ firebase database data structure එක ..ඒක json tree එකක්..

මේ උඩ තියෙන්නේ firebase cloud firestore එකේ data structure එක..
realtime db එකේ  complex hierarchical   data හැසිරිවීම ටිකක් අපහසුයි.හැබැයි  Cloud firestore use  කරාම අපිට  subcollection පාවිච්චි
කරලා ලේසියෙන් වැඩ කරගන්න පුලුවන්.

Cloud firestore use කරාම එකේ අපිට chain filtering,combine filtering,sorting කරන්න පුලුවන්.

ඒ වගේම අපිට where methods  කිහිපයක් එකවර දාන්න හැකියාවත්  cloud firestore  අපිට ලබා දීලා තියෙනවා.
realtime database  එකකට වඩා Scalability එකත් cloud firestore වල වැඩී.

ඒ වගේම අපිට data  එක එකවරක් පමනක් ඔනිනම්  realtime  නැතුව  manually data fetch  කරන්න  cloud firestore  හැකියාව ලබා දී තියෙනවා

ඒ වගේම අයකිරීම් ගත්තම cloud firestore  වල අය කිරීම් කරන්නෙ
1. read,write,delete කරන වාර ගනනට
2.use  කරන  storage  එක අනුව.
3. use  කරන network bandwidth
එක අනුව.හැබැයි ඒ ඉතාම අඩු   rate  එකකට.
realtime db  එකේ  charge කරන්නේ bandwidth  එකයි  storage  එකයි අනුව හැබැයි ඒ high rate එකකට.
 security  ගැන කතා කරොත්,
realtime db අපිට වෙන වෙනම  data  validate  rule  එක  use  කරලා  validate  කරන්න ඕනි. cloud firestore  වල  automatically
 validate  කරල දෙනවා.ඒ වගේම හොද  security එකක් තියෙනව  realtime database  එකට වඩා.
 අවසාන වශයෙන්   අපිට  realtime db,firestore  දෙකම උනත් එකම  project  එකේ  use  කරන්න  හැකියාව ලබාදී තියෙනවා.

ඉතින් ඔන්න ඔය ටික තමා මම අද ඔයාලට අරන් ආවෙ..එහෙනම් ලගදිම අයෙම මේ වගේ වැදගත් වෙන තොරතුරු ටිකක් අරන් එන්න බලාපොරොත්තුවෙනව.. දිගටම blog එකත් එක්ක ඉන්න කියලා ආරාදනා කරනවා..








Thursday, November 23, 2017

EER එකක් කොහොමද relational mapping කරන්නෙ කියල බලමු ...

EER එකක් කොහොමද relational mapping කරන්නෙ කියල බලමු ...


මම හිතනව ඔයාලට හොද දැනුමක් ඇති eer ගැන කියල.. එහෙම නැත්නම් මේක තෙරෙන් නැතිවෙයි..
eer වල ඔයාල දන්නව අවස්තා කිහිපයක්  තියෙනවා 
  1. disjoint
  2. overlap
  3. total specialization
  4. partial specialization
 හරි මුලින්ම බලමු මේ මොකක්ද කියන්නේ කියලා 

disjoint




person කෙනෙක් employee කෙනෙක් හෝ student කෙනෙක් නම් එ කියන්නෙ ඔහු එක්කො  employee කෙනෙක් එක්කො student කෙනෙක් නම් අන්න ඒක disjoint කියනව..

overlap

හිතන්න student කෙනෙක් ඉගෙන ගන්න ගමන් job එකකුත් කරනව කියල එතකොට ඒ person employee කෙනෙක් වගේම student කෙනෙකුත් වෙනවා..අන්න එහෙම අවස්තා වලට අපි කියනව overlap අවස්තා කියලා...

total specialization and partial specialization

ඔයාලට පේනව ඇති person එකට ඉරි 2ක් වැදිලා තියෙනවා එකෙන් කියන්නෙ මේක total specialization වෙලා කියන එක.. ඒ කියන්නෙ අපි මේ කියන person අනිවාර්යෙන්ම මේ දෙන්නෙන් එක්කෙනෙක් වෙන කෙනෙක් වෙන්න බැහැ අපි හදන system එකෙ ඉන්න අය ඔය කොටස් දෙකෙන් බැහැර අය ඉන්න බෑ   තේරුන් නෑ නේද..හිතන්නකො priest කෙනෙක් එයා employee කෙනෙක්ද නෑ student කෙනෙක්ද නෑ අන්න එතකොට අපෙ database එකෙ priest කෙනෙක් දානව නම් එයා ඔය කියන දෙකටම අදාල නෑ..අන්න එ වගේ අවස්තාවකට අපි කියනව partial specialization කියල... 

මම හිතනවා තෙරෙන්න ඇති කියලා 

දැන් අපි යමුකො මාතෘකාවට EER එකක් කොහොමද relational mapping කරන්නෙ කියල..

ඒකට conditions කිහිපයකට අදාල option 4 ක් තියෙනවා ..
option 1

person(id, name,age)
employee(id,salary)
student(id, GPA)

option 2

employee(id,age,name,salary)
student(id,name,age,GPA)

option 3
person(id,name,age,salary,GPA,TYPE)

option 4

person(id, name,age,salary,GPA,employee,student)



ER diagram එකක් relational mapping කරන ආකරය උදාහරනයකින් ....

ER diagram එකක් relational mapping කරන ආකරය උදාහරනයකින් ....



මේකට එන පිලිතුර තමා මේ...



තව ප්‍රශ්න ඔයාලත් හොයගෙන කරන්න...මම හිතනව මගෙ කලින් note එක තෙරෙන්න ඇති කියලා එහෙනම් ඉස්තුතියි ....

Tuesday, November 21, 2017

ER diagram එකක් relational mapping කරන විදිහ...

        ER diagram එකක් relational mapping කරන විදිහ...


මේක ඉගෙන ගන්න කලින් අපි  බලමු ,

  1. Single valued attribute එකක් කියන්නෙ මොකක්ද 
  2. Multi valued attribute එකක් කියන්නෙ මොකක්ද 
  3. Derived  attribute එකක් කියන්නෙ මොකක්ද 
  4. Binary relationship එකක් කියන්නෙ මොකක්ද 
Single valued attribute
student ට තියෙන්නෙ එක dob එකයිනෙ. මෙන්න මේ වගේ ඒවා single valued attribute
කියල කියනවා.






Multi valued attribute

student ට phone numbers කිහිපයක් තියෙන්න පුලුවන්. අන්න ඒ වගේ ඒවා multi valued attribute කියල කියනවා.







Derived attribute

age කියන එක අපිට dob සහ current date එකෙන් (පරිගණකයේ සදහන් වන අද දිනය)  හොයා ගන්න පුලුවන්. අන්න ඒ වගේ වෙනත් attribute එකකින් හෝ කිහිපයකින් හොයා ගන්න පුලුවන් attribute, derived attribute කියලා කියනවා. 



Binary relationship

binary relationship කියල කියන්නෙ මේ වගේ entity දෙකක් එක relationship එකකට සම්බන්ධ වීමයි.





Ternary relationship එකක් කියන්නෙ,







මෙන්න මේ වගේ එකක්.



අපි දැන් බලමු කොහොමද මේ වැඩේ කරන්නෙ කියලා.

ER diagram එකක් relational mapping කරන්න පියවර 7 ක් තියෙනවා.

    1. Map regular entity types
    2. Map Weak entity types
    3. Map binary 1:1 realationship types
    4. Map binary 1:N relationship types
    5. Map binary M:N Reltionship types
    6. Map Multivalued attributes
    7. Map N-ary Relationship types

      1. Map regular entity types
ඉහත උදාහරනයේ regular entity වන්නේ vehicle සහ option යන entity දෙකයි. ඒවා mapping කලාම,
  • option(ID , EXPIRY, COST)
  • vehicle(VIN , COST, REGISTRATION)

        2. Map weak entity types

ඉහත උදාහරනයේ weak entity වන්නේ TAX DISC entity එකයි. ඒක mapping කලාම

  • TAX _DISC(VIN , DURATION , CLASS)
දැන් ඔයාල බලනව  ඇති VIN  කොහොමද මෙතෙන්ට ආවෙ කියලා , ඒක ආවෙ TAX_DISC ගෙ strong entity* එක වෙන්නෙ vehicle entity එක නිසයි.
*(weak entity එකක් පවතින්නේ strong entity එක පවතින කල් පමනයි)


                     3.Map binary 1:1 Relation types

මෙතනදි අපි බලනව මේ සම්බන්දතාවයේ partial සහ total බව.
අපේ උදාහරනයේ vehicle සහ TAX_DISK අතර පවතින්නේ 1:1 සම්බන්ධතාවයකි. මෙහි
TAX_DISK පවත්වන්නේ total සම්බන්ධතාවයකි. vehicle පවත්වන්නේ partial  සම්බන්ධතාවයකි.

mapping කිරීමේදී සිදු  අරන්නේ partial පාර්ශවයේ පවතින primary key එකත් එම relationship එකේ පවතින attribute  කිහිපයත්  total පාර්ශවයේ පවතින entity එකට අදාල relation  එකට පැමිනීමයි.

උදා :-



  • student(Student_Id, Student_name)
  • Project( project_Id, Student_IdStart_date, Project_type)
දැන් ඔයාලට පේනව ඇති project වගුවට student_id, start_date  කියන දෙකත්  ආව.
දැන් මෙහෙම ආපු student_id ට අපි කියනවා foreign key එකක් කියලා
*දෙපැත්තම total හෝ දෙපැත්තම partial නම් දෙපැත්තෙන් ඕනෙම එක entity එකකට අදාල වගුවකට මෙම ක්‍රියාවලිය සිදු කල යුතුය.

                       4.Map binary 1:M Relation types

මෙහිදී total හෝ partial නොසලකා හරින අතර many relationship පැත්තට අදාල වගුවට, 1 පැත්තේ  entity එකේ primary key එකත් relationship එකට අදාල attribute කිහිපයත් පැමිනේ.


  • student(student_Id,student_name, project_id,Start_date, )
  • project(project_Id,project_type)
                    5.Map binary M:N Relation types

මෙහිදී සිදුවන්නේ relationship එකට අදාලව table එකක් සෑදීම හා. entity වලට අදාල primary keys සහ relation attributes එම table එකට පැමිනීමයි.


  • Works_On(Student_Id, ,Project_Id, ,Start_date)

                   6.Map Multivalued attribute
මෙහෙදි අපි සිදුකරන්නෙ එම attribute එකට වෙනම වගුවක් සැකසීමයි 




  • Department_Location(DNumber,Location)

එම වගුවට අපි ඇතුලත් කරන්නෙ එම attribute එක ඇතුලත් entity එකේ primary key එක  සහ  එම multivalued attribute එකේ නමයි.



                   7.Map N-ary Relationship types

n-ary relationship කියන්නෙ binary relationship නොවන අනිකුත් අවස්තා එ කියන්නෙ මෙන්න මේ වගේ අවස්තා.


මේවා විතරකමත් නෙවෙයි self referencing අවස්තාත් එන්නෙ මෙකටම තමා එ කියන්නෙ
 මෙන්න මේ වගේ අවස්තා...

මෙන්න මේ වගේ අවස්තා  වලදි කරන්නේ,, ඒ කියන්නෙ self referencing වල M:N අවස්තාව
 මේකට වෙනම වගුවක් සකසන එකයි

  • Option_depend(ID1, ID2, TYPE,NOTES) 
දැන් බලනවා ඇති මොකක්ද මේ කෙරුවේ කියලා,ඇත්තටම හරි සරලයි මේක අපිට මෙන්න මෙහෙම බලන්ඩ පුලුවන් නේද ?


හරිනෙ දැන් මේක M:N relationship එකක් වගෙනේ .. එකයි එකට අරවගෙ වගුවක් එන්නේ..

මේ වගේම self referencing වල 1:Nඅවස්තාවක් ආවොත් ඒකට අපි උඩදි කතා කරපු binary 1:N අවස්තාව වගේ තමා කරන්නේ..

දැන් අපි බලමු n'ary  අනිකුත් අවස්තාවල මොනවදා කරන්නෙ කියල,,

මේ වගේ අවස්තා වලදි කරන්නෙ අපි කරන්නේ,,

  • R(E1_ID,E2_ID,E3_ID,date)
මම හිතන්නේ මේක තෙරෙන්න ඇති කියලා... මම ඊලග ලිපිය මෙකට අදාල ගානක් පල කරන්නම් .