اصول طراحي پايگاه داده

  • Uploaded by: sara khaku
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View اصول طراحي پايگاه داده as PDF for free.

More details

  • Words: 32,599
  • Pages: 129
‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١ /‬‬

‫ﻓﺼﻞ ﺍﻭﻝ ‪:‬‬ ‫ﻣﻌﺮﻓﻲ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ‬ ‫‪ -١-١‬ﺗﻌﺮﻳﻒ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ‪:‬‬ ‫ﻣﻔﻬـﻮﻡ ﭘﺎﻳﮕـﺎﻩ ﺩﺍﺩﻩ ﻫـﺎ ﺍﺯ ﻧﻈـﺮ ﻣﺆﻟﻔـﻴﻦ ﻣﺨـﺘﻠﻒ ﺩﺭ ﺑﻴﺎﻥ ﺑﺎ ﺗﻔﺎﻭﺗﻬﺎﻳﻲ ﻫﻤﺮﺍﻩ ﻭﻟﻲ ﺍﺯ ﻧﻈﺮ ﺗﻜﻨﻴﻜﻲ ﺑﻪ ﮔﻮﻧﻪ ﺍﻱ ﻣﺸﺎﺑﻪ ﺗﻌﺮﻳﻒ‬ ‫ﺷﺪﻩ ﺍﺳﺖ‪ .‬ﻳﻜﻲ ﺍﺯ ﺗﻌﺎﺭﻳﻒ ﻣﻨﺎﺳﺐ ﺁﻥ ﺑﻪ ﻓﺮﻡ ﺯﻳﺮ ﻣﻲ ﺑﺎﺷﺪ‪:‬‬

‫ﺑﺎﻧـﻚ ﺍﻃﻼﻋﺎﺗـﻲ‪ ،‬ﻣﺠﻤـﻮﻋﻪ ﺍﻱ ﺍﺳـﺖ ﺍﺯ ﺩﺍﺩﻩ ﻫـﺎﻱ ﺫﺧﻴـﺮﻩ ﺷـﺪﻩ ﻭ ﭘﺎﻳـﺎ )ﺩﺭ ﻣﻮﺭﺩ ﺍﻧﻮﺍﻉ ﻣﻮﺟﻮﺩﻳﺘﻬﺎﻱ ﻳﻚ ﻣﺤﻴﻂ‬ ‫ﻋﻤﻠﻴﺎﺗـﻲ ﻭ ﺍﺭﺗـﺒﺎﻃﺎﺕ ﺑـﻴﻦ ﺁﻧﻬـﺎ( ﺑﺼـﻮﺭﺕ ﻣﺠﺘﻤﻊ ﻭ ﻣﺒﺘﻨﻲ ﺑﺮ ﻳﻚ ﺳﺎﺧﺘﺎﺭ‪ ،‬ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺑﻄﻮﺭ ﺻﻮﺭﻱ ﺑﺎ ﺣﺪﺍﻗﻞ ﺍﻓﺰﻭﻧﮕﻲ‪،‬‬ ‫ﺗﺤﺖ ﻣﺪﻳﺮﻳﺖ ﻳﻚ ﺳﻴﺴﺘﻢ ﻛﻨﺘﺮﻝ ﻣﺘﻤﺮﻛﺰ‪ ،‬ﻣﻮﺭﺩ ﺍﺳﺘﻔﺎﺩﻩ ﻳﻚ ﻳﺎ ﭼﻨﺪ ﻛﺎﺭﺑﺮ‪ ،‬ﺑﻄﻮﺭ ﺍﺷﺘﺮﺍﻛﻲ ﻭ ﻫﻤﺰﻣﺎﻥ‪.‬‬ ‫ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺍﻳﻦ ﺗﻌﺮﻳﻒ ﻣﻲ ﺗﻮﺍﻥ ﺩﺭﻳﺎﻓﺖ ﻛﻪ ﺍﺯ ﺩﻳﺪﮔﺎﻩ ﺗﺨﺼﺼﻲ ﻫﺮ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﻓﺎﻳﻠﻬﺎ ﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﻟﺰﻭﻣﺎ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ‬ ‫ﻣﺤﺴﻮﺏ ﻧﻤﻴﮕﺮﺩﺩ‪.‬ﺩﺭ ﺍﺩﺍﻣﻪ ﺑﺮﺧﻲ ﺍﺻﻄﻼﺣﺎﺕ ﻣﻮﺟﻮﺩ ﺩﺭ ﺗﻌﺮﻳﻒ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺗﻮﺿﻴﺢ ﺩﺍﺩﻩ ﺷﺪﻩ ﺍﻧﺪ‪:‬‬ ‫ﻣﺠﺘﻤﻊ ‪ Integrity‬ﻭ ﻣﺒﺘﻨﻲ ﺑﺮ ﻳﻚ ﺳﺎﺧﺘﺎﺭ‬ ‫ﺑـﻪ ﻣﻌﻨـﻲ ﺁﻥ ﺍﺳـﺖ ﻛﻪ ﻛﻞ ﺩﺍﺩﻩ ﻫﺎﻱ ﻋﻤﻠﻴﺎﺗﻲ ﻣﺤﻴﻂ ﻣﻮﺭﺩ ﻧﻈﺮ ﻛﺎﺭﺑﺮﺍﻥ ﻣﺨﺘﻠﻒ‪ ،‬ﺩﺭ ﻗﺎﻟﺐ ﻳﻚ ﺳﺎﺧﺘﺎﺭ ﻣﺸﺨﺺ ﺑﺼﻮﺭﺕ‬ ‫ﻳﻜﺠﺎ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺑﺎﺷﻨﺪ‪ .‬ﺑﻪ ﻋﺒﺎﺭﺗﻲ ﭘﺮﺍﻛﻨﺪﮔﻲ ﺩﺭ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﺩﺍﺩﻩ ﻫﺎﻱ ﻣﺤﻴﻂ ﻭﺟﻮﺩ ﻧﺪﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺑﺼﻮﺭﺕ ﺻﻮﺭﻱ‪:‬‬ ‫ﺑـﻪ ﻣﻌﻨـﻲ ﺁﻥ ﺍﺳﺖ ﻛﻪ ﺩﺍﺩﻩ ﻫﺎ ﺑﻪ ﻛﻤﻚ ﺍﺣﻜﺎﻡ ﺧﺎﺻﻲ‪ ،‬ﺩﺭ ﻛﺎﺩﺭ ﺗﻌﺮﻳﻒ ﻓﺎﻳﻠﻬﺎﻱ ﻣﻮﺭﺩ ﻧﻴﺎﺯ‪ ،‬ﺗﺸﺮﻳﺢ ﻭ ﺗﻌﺮﻳﻒ ﺷﻮﻧﺪ ﻭ ﺍﻳﻦ‬ ‫ﻛﺎﺭ ﺯﺑﺎﻥ ﺧﺎﺻﻲ ﺭﺍ ﻻﺯﻡ ﺩﺍﺭﺩ‪.‬‬ ‫ﻣﺜﺎﻟﻲ ﺑﺮﺍﻱ ﺩﺭﻙ ﺑﻬﺘﺮ ﻣﻔﻬﻮﻡ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ‬ ‫ﻣﺤـﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﺩﺍﻧﺸﮕﺎﻩ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﺑﮕﻴﺮﻳﺪ ﻛﻪ ﺩﺍﺭﺍﻱ ﺑﺨﺶ ﻫﺎﻱ ﻋﻤﻠﻴﺎﺗﻲ ﻣﺨﺘﻠﻒ ﻣﻲ ﺑﺎﺷﺪ‪ .‬ﻓﺮﺽ ﻣﻲ ﺷﻮﺩ ﻛﻪ‬ ‫ﺳﻪ ﺑﺨﺶ ﺍﻣﻮﺭ ﺁﻣﻮﺯﺵ‪ ،‬ﺍﻣﻮﺭ ﺩﺍﻧﺸﺠﻮﻳﻲ ﻭ ﺍﻣﻮﺭ ﻣﺎﻟﻲ ﺩﺍﻧﺸﮕﺎﻩ ﺑﺨﺸﻬﺎﻳﻲ ﻫﺴﺘﻨﺪ ﻛﻪ ﻣﻲ ﺧﻮﺍﻫﻴﻢ ﺑﺮﺍﻱ ﺁﻧﻬﺎ ﻳﻚ ﺳﻴﺴﺘﻢ‬ ‫ﺫﺧﻴـﺮﻩ ﻭ ﺑﺎﺯﻳﺎﺑﻲ ﻛﺎﻣﭙﻴﻮﺗﺮﻱ ﺍﻳﺠﺎﺩ ﻧﻤﺎﻳﻴﻢ ﻭ ﻧﻴﺰ ﻓﺮﺽ ﻣﻲ ﻛﻨﻴﻢ ﻛﻪ ﺗﻨﻬﺎ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻮﺭﺩ ﻧﻈﺮ‪ ،‬ﻣﻮﺟﻮﺩﻳﺖ ﺩﺍﻧﺸﺠﻮ‬ ‫ﺑﺎﺷـﺪ ﻭ ﺑﺨﺸﻬﺎﻱ ﻓﻮﻕ ﻣﻲ ﺧﻮﺍﻫﻨﺪ ﺍﻃﻼﻋﺎﺗﻲ ﺭﺍ ﺩﺭ ﻣﻮﺭﺩ ﺍﻳﻦ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ‪ .‬ﻭﺍﺿﺢ ﺍﺳﺖ ﻛﻪ ﺩﺭ ﻫﺮ ﻳﻚ‬ ‫ﺍﺯ ﺑﺨﺸﻬﺎﻱ ﻓﻮﻕ ﺍﻧﻮﺍﻉ ﺩﻳﮕﺮﻱ ﺍﺯ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ ﻭﺟﻮﺩ ﺩﺍﺭﻧﺪ ﻛﻪ ﺩﺭ ﺍﻳﻦ ﻣﺜﺎﻝ ﻣﻮﺭﺩ ﺑﺤﺚ ﻗﺮﺍﺭ ﻧﻤﻲ ﮔﻴﺮﻧﺪ‪.‬‬ ‫ﺩﻭ ﺭﻭﺵ ﻭ ﻣﺸﻲ ﻛﻠﻲ ﺩﺭ ﻃﺮﺍﺣﻲ ﺍﻳﻦ ﺳﻴﺴﺘﻢ ﻭﺟﻮﺩ ﺩﺍﺭﺩ‪:‬‬

‫ﺍﻣﻮﺭ ﻣﺎﻟﻲ‬

‫ﺍﺩﺍﺭﻩ ﺁﻣﻮﺯﺵ‬ ‫ﺩﺍﻧﺸﺠﻮ‬

‫……‬

‫ﺍﻣﻮﺭ ﺩﺍﻧﺸﺠﻮﻳﻲ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢ /‬‬

‫ﺍﻟﻒ – ﻣﺸﻲ ﻏﻴﺮ ﺑﺎﻧﻜﻲ )ﺳﻴﺴﺘﻢ ﻓﺎﻳﻞ ﭘﺮﺩﺍﺯﻱ( ‪File Processing‬‬

‫ﻼ ﻣﻄﺎﻟﻌﻪ ﻣﻲ ﺷﻮﺩ ﻭ ﺑﺮﺍﻱ ﻫﺮ ﺯﻳﺮ ﻣﺠﻤﻮﻋﻪ ﻳﻚ ﺳﻴﺴﺘﻢ ﺧﺎﺹ‬ ‫ﺩﺭ ﺍﻳﻦ ﺭﻭﺵ ﻫﺮ ﻳﻚ ﺍﺯ ﺯﻳﺮ ﻣﺤﻴﻂ ﻫﺎﻱ ﻋﻤﻠﻴﺎﺗﻲ ﻣﺴﺘﻘ ﹰ‬ ‫ﻫﻤـﺎﻥ ﺯﻳـﺮ ﻣﺤـﻴﻂ ﻃﺮﺍﺣـﻲ ﻭ ﺗﻮﻟـﻴﺪ ﻣﻲ ﺷﻮﺩ‪ ،‬ﺑﮕﻮﻧﻪ ﺍﻱ ﻛﻪ ﻓﻘﻂ ﭘﺎﺳﺨﮕﻮﻱ ﻫﻤﺎﻥ ﺯﻳﺮ ﻣﺤﻴﻂ ﺍﺳﺖ‪.‬ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﻣﺜﺎﻝ ﻣﻄﺮﺡ‬ ‫ﺷﺪﻩ ﻫﺮ ﻗﺴﻤﺖ ﺍﺯ ﺩﺍﻧﺸﮕﺎﻩ ﺳﻴﺴﺘﻢ ﻛﺎﺭﺑﺮﺩﻱ ﺧﺎﺹ ﻭ ﺟﺪﺍﮔﺎﻧﻪ ﺧﻮﺩ ﺭﺍ ﺧﻮﺍﻫﺪ ﺩﺍﺷﺖ ‪.‬‬

‫ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﺍﻳﺠﺎﺩ‬ ‫ﻓﺎﻳﻠﻬﺎﻱ ﺧﺎﺹ‬

‫ﺳﻴﺴﺘﻢ ﻓﺎﻳﻞ‬

‫ﻛﻨﻨﺪﻩ ﻭ‬ ‫ﭘﺮﺩﺍﺯﺷﮕﺮ ﻓﺎﻳﻠﻬﺎ‬

‫ﺍﺩﺍﺭﻩ ﺁﻣﻮﺯﺵ‬

‫ﻣﺤﻴﻂ ﻓﻴﺰﻳﻜﻲ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ‬ ‫ﺧﺎﺹ ﻛﺎﺭﺑﺮﺍﻥ ﺁﻣﻮﺯﺵ‬

‫ﺍﺩﺍﺭﻩ ﺁﻣﻮﺯﺵ‬

‫ﻧﺮﻡ ﺍﻓﺰﺍﺭ ﺳﻴﺴﺘﻢ ﻭﺍﺳﻂ‬

‫ﻗﺎﻟﺐ ﺭﻛﻮﺭﺩ ﺍﺯ ﺩﻳﺪ ﺁﻣﻮﺯﺵ ‪) :‬ﺩﺍﻧﺸﻜﺪﻩ‪ ،‬ﺳﺎﻝ ﻭﺭﻭﺩ‪ ،‬ﺗﺎﺭﻳﺦ ﺗﻮﻟﺪ‪ ،‬ﻧﺎﻡ ﺧﺎﻧﻮﺍﺩﮔﻲ‪ ،‬ﻧﺎﻡ‪ ،‬ﺷﻤﺎﺭﻩ ﺩﺍﻧﺸﺠﻮ(‬ ‫ﺍﻣﻮﺭ ﺩﺍﻧﺸﺠﻮﻳﻲ ﻧﻴﺰ ﻓﺎﻳﻠﻬﺎﻱ ﺧﺎﺹ ﺧﻮﺩ ﺭﺍ ﺩﺍﺭﺩ‪:‬‬ ‫ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﺍﻳﺠﺎﺩ‬ ‫ﻓﺎﻳﻠﻬﺎﻱ ﺧﺎﺹ‬

‫ﺳﻴﺴﺘﻢ ﻓﺎﻳﻞ‬

‫ﺍﺩﺍﺭﻩ ﺍﻣﻮﺭ‬

‫ﻛﻨﻨﺪﻩ ﻭ‬ ‫ﭘﺮﺩﺍﺯﺷﮕﺮ ﻓﺎﻳﻠﻬﺎ‬

‫ﺩﺍﻧﺸﺠﻮﻳﻲ‬ ‫ﺍﻣﻮﺭ ﺩﺍﻧﺸﺠﻮﻳﻲ‬

‫ﻗﺎﻟﺐ ﺭﻛﻮﺭﺩ ﺍﺯ ﺩﻳﺪ ﺍﻣﻮﺭ ﺩﺍﻧﺸﺠﻮﻳﻲ‪:‬‬ ‫)ﺳﺎﻝ ﻭﺭﻭﺩ‪ ،‬ﺗﺎﺭﻳﺦ ﺗﻮﻟﺪ‪ ،‬ﻧﺎﻡ ﺧﺎﻧﻮﺍﺩﮔﻲ‪ ،‬ﻧﺎﻡ‪ ،‬ﺷﻤﺎﺭﻩ ﺩﺍﻧﺸﺠﻮ(‬ ‫ﻣﺸﺨﺼﻪ ﻫﺎﻱ ﺍﻳﻦ ﺭﻭﺵ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ‪:‬‬ ‫‪ – ١‬ﺩﺭ ﺭﻭﺵ ﻓﺎﻳﻞ ﭘﺮﺩﺍﺯﻱ ﺩﺍﺩﻩ ﻫﺎ ﺍﺯ ﻫﻢ ﻣﺠﺰﺍ ﻣﻲ ﺑﺎﺷﻨﺪ‪.‬‬ ‫‪ – ٢‬ﻣﺤﻴﻂ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﻧﺎﻣﺠﺘﻤﻊ ﺍﺳﺖ )ﺗﻌﺪﺍﺩﻱ ﺳﻴﺴﺘﻢ ﺟﺪﺍﮔﺎﻧﻪ ﻭ ﻣﺤﻴﻂ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﺟﺪﺍﮔﺎﻧﻪ(‬ ‫‪ – ٣‬ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﻭﺍﺑﺴﺘﻪ ﺑﻪ ﻗﺎﻟﺐ ﻓﺎﻳﻞ ﻣﻲ ﺑﺎﺷﻨﺪ‪.‬‬ ‫‪ – ٤‬ﻋﺪﻡ ﺳﺎﺯﮔﺎﺭﻱ ﺩﺭ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﻓﺎﻳﻠﻬﺎ ﺩﻳﺪﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪ – ٥‬ﺍﺷﺘﺮﺍﻛﻲ ﻧﺒﻮﺩﻥ ﺩﺍﺩﻩ ﻫﺎ ‪ :‬ﺩﺍﺩﻩ ﻫﺎﻱ ﺯﻳﺮ ﻣﺤﻴﻂ ‪ ١‬ﻣﻮﺭﺩ ﺍﺳﺘﻔﺎﺩﻩ ﻛﺎﺭﺑﺮﺍﻥ ﺯﻳﺮ ﻣﺤﻴﻂ ‪ ٢‬ﻧﻤﻲ ﺗﻮﺍﻧﻨﺪ ﻗﺮﺍﺭ ﮔﻴﺮﻧﺪ‪.‬‬ ‫‪ – ٦‬ﺍﻃﻼﻋﺎﺕ ﺗﻜﺮﺍﺭﻱ ﻭ ﺍﻓﺰﻭﻧﮕﻲ ﺩﺭ ﺩﺍﺩﻩ ﻫﺎ ﻭﺟﻮﺩ ﺩﺍﺭﺩ‪.‬‬ ‫‪ – ٧‬ﻋـﺪﻡ ﺍﻣﻜـﺎﻥ ﺍﺳﺘﺎﻧﺪﺍﺭﺩﻫﺎﻱ ﻭﺍﺣﺪ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﺑﺪﻟﻴﻞ ﻭﺟﻮﺩ ﺳﻴﺴﺘﻢ ﻫﺎﻱ ﻣﺘﻌﺪﺩ ﻭ ﭘﺮﺍﻛﻨﺪﻩ ﻛﻪ ﺍﺣﻴﺎﻧﹰﺎ ﺗﻮﺳﻂ ﺗﻴﻢ ﻫﺎﻱ‬ ‫ﻣﺨﺘﻠﻒ ﻃﺮﺍﺣﻲ ﻭ ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ ﺷﺪﻩ ﺍﺳﺖ ﺍﻣﻜﺎﻥ ﺍﻋﻤﺎﻝ ﻳﻜﺴﺮﻱ ﺍﺯ ﻋﻤﻠﻴﺎﺕ ﻣﻨﺴﺠﻢ ﺭﻭﻱ ﺁﻥ ﺳﻴﺴﺘﻢ ﻭﺟﻮﺩ ﻧﺪﺍﺭﺩ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣ /‬‬

‫‪ -٨‬ﻣﺼـﺮﻑ ﻏﻴـﺮ ﺑﻬﻴـﻨﻪ ﺍﻣﻜﺎﻧـﺎﺕ ﺳـﺨﺖ ﺍﻓـﺰﺍﺭﻱ ﻭ ﻧﺮﻡ ﺍﻓﺰﺍﺭﻱ ﻭ ﺣﺠﻢ ﺯﻳﺎﺩ ﺑﺮﻧﺎﻣﻪ ﺳﺎﺯﻱ ﻭ ﺍﺳﺘﻔﺎﺩﻩ ﻏﻴﺮ ﺑﻬﻴﻨﻪ ﺍﺯ ﻣﻬﺎﺭﺕ ﻭ‬ ‫ﻭﻗﺖ ﺗﻴﻤﻬﺎﻱ ﺑﺮﻧﺎﻣﻪ ﺳﺎﺯﻱ ‪.‬‬ ‫ﺏ – ﻣﺸﻲ ﺑﺎﻧﻜﻲ )ﭘﺎﻳﮕﺎﻫﻲ(‬

‫‪Database Approach‬‬

‫ﺩﺭ ﺍﻳـﻦ ﺭﻭﺵ ﻳـﻚ ﺗـﻴﻢ ﻭﺍﺣﺪ ﻃﺮﺍﺣﻲ ﻭ ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ ﺑﻪ ﺳﺮﭘﺮﺳﺘﻲ ﻣﺘﺨﺼﺼﻲ ﺑﻪ ﻧﺎﻡ ‪ DBA‬ﻣﺠﻤﻮﻋﻪ ﻧﻴﺎﺯﻫﺎﻱ ﺍﻃﻼﻋﺎﺗﻲ‬ ‫ﻛـﻞ ﻣﺤـﻴﻂ ﻋﻤﻠﻴﺎﺗـﻲ ﻣـﻮﺭﺩ ﻧﻈـﺮ ﻣﺪﻳـﺮﻳﺖ ﻛـﻞ ﺳﺎﺯﻣﺎﻥ ﺭﺍ ﺑﺮﺭﺳﻲ ﻣﻲ ﻛﻨﺪ ﻭ ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﻧﻴﺎﺯﻫﺎﻱ ﺍﻃﻼﻋﺎﺗﻲ ﺗﻤﺎﻡ ﻛﺎﺭﺑﺮﺍﻥ‬ ‫ﻣﺤـﻴﻂ ﻭ ﺿـﻤﻦ ﺍﺳـﺘﻔﺎﺩﻩ ﺍﺯ ﻳـﻚ ﻧـﺮﻡ ﺍﻓﺰﺍﺭ ﺧﺎﺹ ﺑﻪ ﻧﺎﻡ ‪ DBMS‬ﻣﺤﻴﻂ ﻭﺍﺣﺪ ﻭ ﻣﺠﺘﻤﻊ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﺍﻃﻼﻋﺎﺕ ﺍﻳﺠﺎﺩ ﻣﻲ‬ ‫ﺷـﻮﺩ‪.‬ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﻣﺜﺎﻝ ﻣﻄﺮﺡ ﺷﺪﻩ‪ ،‬ﺭﻛﻮﺭﺩ ﻧﻮﻉ ﺩﺍﻧﺸﺠﻮ ﻓﻘﻂ ﻳﻜﺒﺎﺭ ﺩﺭ ﻓﺎﻳﻞ ﺫﺧﻴﺮﻩ ﻣﻲ ﺷﻮﺩ ﻭﻛﺎﺭﺑﺮﺍﻥ ﻣﺨﺘﻠﻒ ﻫﺮ ﻳﻚ ﻃﺒﻖ‬ ‫ﻧﻴﺎﺯ ﺍﻃﻼﻋﺎﺗﻲ ﺧﻮﺩ ﺍﺯ ﺁﻥ ﺑﻄﻮﺭ ﻣﺸﺘﺮﻙ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﻧﻤﺎﻳﻨﺪ‪ .‬ﺩﺭ ﺭﻛﻮﺭﺩ ﻧﻮﻉ ﺩﺍﻧﺸﺠﻮ‪ ،‬ﺗﻤﺎﻡ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻣﻮﺭﺩ ﻧﻴﺎﺯ ﻛﺎﺭﺑﺮﺍﻥ‬ ‫ﻣﺨﺘﻠﻒ ﻭﺟﻮﺩ ﺩﺍﺭﻧﺪ ﻭ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻣﺸﺘﺮﻙ‪ ،‬ﺗﻨﻬﺎ ﻳﻜﺒﺎﺭ ﺩﺭ ﺭﻛﻮﺭﺩ ﻣﻨﻈﻮﺭ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬ ‫ﺩﺭ ﺍﻳـﻦ ﺭﻭﺵ ﻫـﺮ ﻛﺎﺭﺑـﺮﻱ‪ ،‬ﺩﻳـﺪ ﺧـﺎﺹ ﺧـﻮﺩ ﺭﺍ ﻧﺴـﺒﺖ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺩﺭ ﺑﺎﻧﻚ ﺩﺍﺭﺩ‪ .‬ﺩﻳﺪ ﻛﺎﺭﺑﺮﺍﻥ ﻣﺨﺘﻠﻒ ﺍﺯ‬ ‫ﻳﻜﺪﻳﮕﺮ ﻣﺘﻔﺎﻭﺕ ﻭ ﺣﺘﻲ ﮔﺎﻩ ﺑﺎ ﻫﻢ ﻣﺘﻀﺎﺩ ﺍﺳﺖ‪.‬‬ ‫‪U1‬‬

‫ﻧﺮﻡ ﺍﻓﺰﺍﺭ ﻣﺪﻳﺮﻳﺖ ﺑﺎﻧﻚ‬

‫‪D‬‬

‫‪DB: Fils‬‬

‫‪A‬‬ ‫‪M‬‬

‫‪AP1‬‬

‫‪B‬‬ ‫‪M‬‬

‫ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﺁﻣﻮﺯﺵ‬

‫‪U2‬‬ ‫‪AP2‬‬

‫ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﺍﻣﻮﺭ ﺩﺍﻧﺸﺠﻮﻳﻲ‬

‫‪S‬‬ ‫‪AP3‬‬

‫‪U3‬‬ ‫ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﺍﻣﻮﺭ ﻣﺎﻟﻲ‬

‫ﻣﺤﻴﻂ ﻓﻴﺰﻳﻜﻲ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ‬ ‫ﻣﺠﺘﻤﻊ ﻭ ﻭﺍﺣﺪ‬

‫ﻣﺸﺨﺼﻪ ﻫﺎﻱ ﺍﻳﻦ ﺭﻭﺵ ‪:‬‬ ‫‪ – ١‬ﺩﺍﺩﻩ ﻫـﺎﻱ ﻣﺠـﺘﻤﻊ‪ :‬ﻛـﻞ ﺩﺍﺩﻩ ﻫـﺎ ﺑﺼﻮﺭﺕ ﻳﻚ ﺑﺎﻧﻚ ﻣﺠﺘﻤﻊ ﺩﻳﺪﻩ ﻣﻲ ﺷﻮﻧﺪ ﻭ ﺍﺯ ﻃﺮﻳﻖ ‪ DBMS‬ﺑﺎ ﺁﻧﻬﺎ ﺍﺭﺗﺒﺎﻁ ﺑﺮﻗﺮﺍﺭ‬ ‫ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪ – ٢‬ﻋـﺪﻡ ﻭﺍﺑﺴﺘﮕﻲ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﻓﺎﻳﻠﻬﺎ‪ :‬ﺯﻳﺮﺍ ‪ DBMS‬ﺧﻮﺩ ﺑﻪ ﻣﺴﺎﺋﻞ ﻓﺎﻳﻠﻴﻨﮓ ﻣﻲ ﭘﺮﺍﺯﺩ ﻭ ﻛﺎﺭﺑﺮﺍﻥ ﺩﺭ‬ ‫ﻣﺤﻴﻂ ﺍﻧﺘﺰﺍﻋﻲ ﻫﺴﺘﻨﺪ‪.‬‬ ‫‪ – ٣‬ﺗﻌﺪﺩ ﺷﻴﻮﻩ ﻫﺎﻱ ﺩﺳﺘﻴﺎﺑﻲ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎ‬ ‫‪ – ٤‬ﻋﺪﻡ ﻭﺟﻮﺩ ﻧﺎﺳﺎﺯﮔﺎﺭﻱ ﺩﺭ ﺩﺍﺩﻩ ﻫﺎ‬ ‫‪ – ٥‬ﺍﺷﺘﺮﺍﻛﻲ ﺑﻮﺩﻥ ﺩﺍﺩﻩ ﻫﺎ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٤ /‬‬

‫‪ – ٦‬ﺍﻣﻜﺎﻥ ﺗﺮﻣﻴﻢ ﺩﺍﺩﻩ ﻫﺎ‬ ‫‪ – ٧‬ﻛﺎﻫﺶ ﺍﻓﺰﻭﻧﮕﻲ‬ ‫‪ – ٨‬ﻛﺎﻫﺶ ﺯﻣﺎﻥ ﺗﻮﻟﻴﺪ ﺳﻴﺴﺘﻢ ﻫﺎ‬ ‫‪ – ٩‬ﺍﻣﻜﺎﻥ ﺍﻋﻤﺎﻝ ﺿﻮﺍﺑﻂ ﺩﻗﻴﻖ ﺍﻳﻤﻨﻲ‬ ‫‪ -٢-١‬ﻋﻨﺎﺻﺮ ﺍﺻﻠﻲ ﺗﺸﻜﻴﻞ ﺩﻫﻨﺪﻩ ﻣﺤﻴﻂ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ‪:‬‬ ‫ﻣﺤﻴﻂ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ‪ ،‬ﻧﻈﻴﺮ ﻫﺮ ﻣﺤﻴﻂ ﺩﻳﮕﺮ ﺫﺧﻴﺮﻩ ﻭ ﺑﺎﺯﻳﺎﺑﻲ‪ ،‬ﺍﺯ ﻋﻨﺎﺻﺮ ﺯﻳﺮ ﺗﺸﻜﻴﻞ ﻣﻲ ﺷﻮﺩ‪:‬‬

‫‪ – ١‬ﺳﺨﺖ ﺍﻓﺰﺍﺭ‬

‫ﻧﺮﻡ ﺍﻓﺰﺍﺭ ﺳﻴﺴﺘﻢ ﻣﺪﻳﺮﻳﺖ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺕ‬

‫‪ – ٢‬ﻧﺮﻡ ﺍﻓﺰﺍﺭ‬

‫ﺑﺮﻧﺎﻣﻪ ﻛﺎﺭﺑﺮﺩﻱ‬

‫‪ – ٣‬ﻛﺎﺭﺑﺮ‬ ‫‪ – ٤‬ﺩﺍﺩﻩ‬

‫‪Data‬‬

‫ﻛﺎﺭﺑﺮﺍﻥ‬ ‫‪ – ١-٢-١‬ﺳﺨﺖ ﺍﻓﺰﺍﺭ ‪:‬‬ ‫ﺳﺨﺖ ﺍﻓﺰﺍﺭ ﻣﺤﻴﻂ ﺑﺎﻧﻜﻲ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺗﻘﺴﻴﻢ ﺑﻨﺪﻱ ﻧﻤﻮﺩ‪:‬‬ ‫ﺍﻟﻒ‪ -‬ﺳﺨﺖ ﺍﻓﺰﺍﺭ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﺩﺍﺩﻩ ﻫﺎ‬ ‫ﻻ ﺑﺮﺍﻱ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﺩﺍﺩﻩ ﻫﺎ ﺍﺯ ﺩﻳﺴﻜﻬﺎﻱ ﺳﺮﻳﻊ ﺑﺎ ﻇﺮﻓﻴﺖ ﺑﺎﻻ‬ ‫ﻣـﻨﻈﻮﺭ ﻫﻤـﺎﻥ ﺭﺳـﺎﻧﻪ ﻫـﺎﻱ ﺫﺧﻴـﺮﻩ ﺳـﺎﺯﻱ ﺍﺳـﺖ ﻛـﻪ ﻣﻌﻤﻮ ﹰ‬ ‫ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺏ‪ -‬ﺳﺨﺖ ﺍﻓﺰﺍﺭ ﭘﺮﺩﺍﺯﺷﻲ‬ ‫ﻣـﻨﻈﻮﺭ ﻫﻤـﺎﻥ ﻛﺎﻣﭙﻴﻮﺗﺮ ﻳﺎ ﻣﺎﺷﻴﻦ ﺍﺳﺖ‪ .‬ﻣﺎﺷﻴﻨﻬﺎﻱ ﺧﺎﺹ ﺑﺮﺍﻱ ﻣﺤﻴﻄﻬﺎﻱ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﻧﻴﺰ ﻃﺮﺍﺣﻲ ﻭ ﺗﻮﻟﻴﺪ‬

‫ﺷﺪﻩ ﺍﻧﺪ‬

‫ﻛـﻪ ﺑـﻪ ﻧـﺎﻡ ‪ DBM‬ﻣﺎﺷـﻴﻨﻬﺎﻱ ﺑﺎﻧـﻚ ﺍﻃﻼﻋﺎﺗـﻲ ﻧﻴﺰ ﺧﻮﺍﻧﺪﻩ ﻣﻲ ﺷﻮﻧﺪ‪ .‬ﺍﻳﻦ ﻣﺎﺷﻴﻨﻬﺎ ﺍﺯ ﻧﻈﺮ ﻣﻌﻤﺎﺭﻱ‪ ،‬ﺣﺎﻓﻈﻪ ﺍﺻﻠﻲ‪ ...،‬ﻭ ﺳﺎﻳﺮ‬ ‫ﺍﺟﺰﺍﺀ ﺍﺯ ﻭﻳﮋﮔﻴﻬﺎ ﻭ ﺟﻨﺒﻪ ﻫﺎﻳﻲ ﺑﺮﺧﻮﺭﺩﺍﺭﻧﺪ ﻛﻪ ﺷﺮﺡ ﺁﻥ ﺩﺭ ﺍﻳﻦ ﺟﺰﻭﻩ ﻧﻤﻲ ﮔﻨﺠﺪ‪.‬‬ ‫ﺝ‪ -‬ﺳﺨﺖ ﺍﻓﺰﺍﺭ ﺍﺭﺗﺒﺎﻃﻲ‬ ‫ﻣﻨﻈﻮﺭ ﻣﺠﻤﻮﻋﻪ ﺍﻣﻜﺎﻧﺎﺕ ﺳﺨﺖ ﺍﻓﺰﺍﺭﻱ ﺍﺳﺖ ﻛﻪ ﺑﺮﺍﻱ ﺑﺮﻗﺮﺍﺭﻱ ﺍﺭﺗﺒﺎﻁ ﺑﻴﻦ ﻛﺎﻣﭙﻴﻮﺗﺮ ﻭ ﺩﺳﺘﮕﺎﻫﻬﺎﻱ ﺟﺎﻧﺒﻲ ﻭ ﻧﻴﺰ ﺑﻴﻦ ﺩﻭ‬ ‫ﻛﺎﻣﭙﻴﻮﺗـﺮ ﻳـﺎ ﺑﻴﺸـﺘﺮ ﺑﻜـﺎﺭ ﮔﺮﻓﺘﻪ ﻣﻲ ﺷﻮﻧﺪ‪ ،‬ﺍﻋﻢ ﺍﺯ ﺍﻳﻨﻜﻪ ﺍﺭﺗﺒﺎﻁ ﻧﺰﺩﻳﻚ ﺑﺎﺷﺪ ﻭ ﻳﺎ ﺍﺭﺗﺒﺎﻁ ﺩﻭﺭ‪ .‬ﺳﺨﺖ ﺍﻓﺰﺍﺭ ﺍﺭﺗﺒﺎﻃﻲ ﺧﺎﺹ‬ ‫ﻣﺤﻴﻂ ﻫﺎﻱ ﺑﺎﻧﻜﻲ ﻧﻴﺴﺖ ﻭ ﺩﺭ ﻫﺮ ﻣﺤﻴﻂ ﻏﻴﺮ ﺑﺎﻧﻜﻲ ﻧﻴﺰ ﻣﻤﻜﻦ ﺍﺳﺖ ﻣﻮﺭﺩ ﻧﻴﺎﺯ ﺑﺎﺷﻨﺪ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٥ /‬‬

‫‪ – ٢-٢-١‬ﻧﺮﻡ ﺍﻓﺰﺍﺭ‪:‬‬ ‫ﻧﺮﻡ ﺍﻓﺰﺍﺭ ﻣﺤﻴﻂ ﺑﺎﻧﻜﻲ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﺑﻪ ﺩﻭ ﺩﺳﺘﻪ ﺗﻘﺴﻴﻢ ﻧﻤﻮﺩ‪:‬‬ ‫‪ –١-٢-٢-١‬ﻧﺮﻡ ﺍﻓﺰﺍﺭ ﻛﺎﺭﺑﺮﺩﻱ‪:‬‬ ‫ﻧﺮﻡ ﺍﻓﺰﺍﺭﻱ ﺍﺳﺖ ﻛﻪ ﻛﺎﺭﺑﺮ ﺑﺎﻳﺪ ﺑﺮﺍﻱ ﺗﻤﺎﺱ ﺑﺎ ﺳﻴﺴﺘﻢ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺁﻣﺎﺩﻩ ﻛﻨﺪ‪.‬‬ ‫‪ -٢-٢-٢-١‬ﻧﺮﻡ ﺍﻓﺰﺍﺭ ﺳﻴﺴﺘﻤﻲ‪:‬‬ ‫ﺑﻴﻦ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﻓﻴﺰﻳﻜﻲ ﻛﻪ ﺩﺍﺩﻩ ﻫﺎ ﺑﺼﻮﺭﺕ ﻓﻴﺰﻳﻜﻲ ﺩﺭ ﺁﻥ ﺫﺧﻴﺮﻩ ﻣﻲ ﺷﻮﻧﺪ ﻭ ﻛﺎﺭﺑﺮﺍﻥ ﺳﻴﺴﺘﻢ‪ ،‬ﻻﻳﻪ ﺍﻱ ﺍﺯ ﻧﺮﻡ ﺍﻓﺰﺍﺭ‬ ‫ﻣﻮﺳـﻮﻡ ﺑـﻪ ﻣﺪﻳـﺮ ﺑﺎﻧـﻚ ﺍﻃﻼﻋﺎﺗـﻲ ﻗﺮﺍﺭ ﺩﺍﺭﺩ‪ .‬ﺳﻴﺴﺘﻢ ﻣﺪﻳﺮﻳﺖ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﻧﺮﻡ ﺍﻓﺰﺍﺭﻱ ﺍﺳﺖ ﻛﻪ ﺑﻪ ﻛﺎﺭﺑﺮﺍﻥ ﺍﻣﻜﺎﻥ ﻣﻲ‬ ‫ﺩﻫـﺪ ﻛـﻪ ﭘﺎﻳﮕـﺎﻩ ﺍﺯ ﺩﻳـﺪ ﺧـﻮﺩ ﺭﺍ ﺗﻌﺮﻳﻒ ﻛﻨﻨﺪ ﻭ ﺑﻪ ﭘﺎﻳﮕﺎﻩ ﺧﻮﺩ ﺩﺳﺘﻴﺎﺑﻲ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ‪ ،‬ﺑﺎ ﭘﺎﻳﮕﺎﻩ ﺧﻮﺩ ﻛﺎﺭ ﻛﻨﻨﺪ ﻭ ﺭﻭﻱ ﺁﻥ‬ ‫ﻛﻨﺘﺮﻝ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ‪.‬‬ ‫‪ -٣-٢-١‬ﻛﺎﺭﺑﺮﺍﻥ‪:‬‬ ‫ﺍﺯ ﻧﻈﺮ ﻭﻇﺎﻳﻔﻲ ﻛﻪ ﺍﻧﺠﺎﻡ ﻣﻲ ﺩﻫﻨﺪ ﺑﻪ ﺩﻭ ﺩﺳﺘﻪ ﻛﻠﻲ ﺗﻘﺴﻴﻢ ﻣﻲ ﺷﻮﻧﺪ‪:‬‬ ‫ﺍﻟﻒ‪ :‬ﻛﺎﺭﺑﺮﺍﻥ ﺑﺎ ﻧﻘﺶ ﻣﺪﻳﺮﻳﺘﻲ )‪(DBA‬‬

‫ﺏ‪ :‬ﻛﺎﺭﺑـﺮﺍﻥ ﺑـﺎ ﻧﻘـﺶ ﺍﺳـﺘﻔﺎﺩﻩ ﻛﻨـﻨﺪﻩ ﻛـﻪ ﺑـﻪ ﺩﻭ ﺩﺳـﺘﻪ‪ :‬ﻛﺎﺭﺑﺮﺍﻥ ﺗﻮﻟﻴﺪ ﻛﻨﻨﺪﻩ ﺳﻴﺴﺘﻢ )ﺑﺮﻧﺎﻣﻪ ﻧﻮﻳﺴﺎﻥ ﻛﺎﺭﺑﺮﺩﻱ( ﻭ ﺍﺳﺘﻔﺎﺩﻩ‬ ‫ﻛﻨـﻨﺪﮔﺎﻥ ﻧﻬﺎﻳـﻲ ﺳﻴﺴـﺘﻢ ﻣـﻲ ﺗـﻮﺍﻧﺪ ﺗﻘﺴـﻴﻢ ﮔـﺮﺩﺩ‪ .‬ﺑـﺮﻧﺎﻣﻪ ﻧﻮﻳﺴـﺎﻥ ﻛﺎﺭﺑـﺮﺩﻱ ﻣﺴـﺌﻮﻝ ﻧﻮﺷـﺘﻦ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﺑﺎﻧﻚ‬ ‫ﺍﻃﻼﻋﺎﺗﻲ ﺑﻪ ﺯﺑﺎﻥ ﺳﻄﺢ ﺑﺎﻻ ﻳﺎ ﺯﺑﺎﻧﻬﺎﻱ ﻧﺴﻞ ﭼﻬﺎﺭﻡ )‪ (4GL‬ﻫﺴﺘﻨﺪ‪.‬‬ ‫‪ – ٤-٢-١‬ﺩﺍﺩﻩ‪:‬‬ ‫ﻣـﻨﻈﻮﺭ ﺩﺍﺩﻩ ﻫﺎﻳـﻲ ﺍﺳـﺖ ﻛـﻪ ﺩﺭ ﻣـﻮﺭﺩ ﺍﻧﻮﺍﻉ ﻣﻮﺟﻮﺩﻳﺘﻬﺎﻱ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﻭ ﺍﺭﺗﺒﺎﻁ ﺑﻴﻦ ﺁﻧﻬﺎ ﻣﻲ ﺑﺎﺷﻨﺪ ﻛﻪ ﺍﺻﻄﻼﺣﹰﺎ ﺑﻪ‬ ‫ﺁﻧﻬـﺎ ﺩﺍﺩﻩ ﻫـﺎﻱ ﻋﻤﻠﻴﺎﺗﻲ ﻭ ﻳﺎ ﺩﺍﺩﻩ ﻫﺎﻱ ﭘﺎﻳﺎ ﮔﻔﺘﻪ ﻣﻲ ﺷﻮﺩ ‪ .‬ﺩﺍﺩﻩ ﻫﺎﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻧﻲ ﺩﺭ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﺍﺑﺘﺪﺍ ﺑﺎﻳﺪ ﺩﺭ ﺑﺎﻻﺗﺮﻳﻦ‬ ‫ﺳـﻄﺢ ﺍﻧﺘـﺰﺍﻉ ﻣﺪﻟﺴـﺎﺯﻱ ﻣﻌﻨﺎﻳـﻲ ﺷـﻮﻧﺪ ‪.‬ﻣﻔﺎﻫـﻴﻢ ﺩﺍﺩﻩ ﻫـﺎ ﺩﺭ ﻫـﺮ ﻣﺤـﻴﻂ ﺑﻪ ﻛﻤﻚ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎ ﻭ ﺍﺭﺗﺒﺎﻃﺎﺕ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ‬ ‫ﻣﻴﺸﻮﻧﺪ ‪.‬‬ ‫ﺍﻧﺘﺨﺎﺏ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ ‪:‬‬ ‫ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ‪:‬‬ ‫ﻋﺒﺎﺭﺗﺴـﺖ ﺍﺯ ﻣﻔﻬﻮﻡ ﻛﻠﻲ ﺷﻲﺀ ﭘﺪﻳﺪﻩ ﻭ ﺑﻄﻮﺭ ﻛﻠﻲ ﻫﺮ ﺁﻧﭽﻪ ﺍﺯ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﻛﻪ ﻣﻲ ﺧﻮﺍﻫﻴﻢ ﺩﺭ ﻣﻮﺭﺩﺵ ﺍﻃﻼﻉ ﺩﺍﺷﺘﻪ‬ ‫ﺑﺎﺷﻴﻢ ‪ .‬ﻣﺜﺎﻝ ‪ :‬ﺩﺍﻧﺸﻜﺪﻩ ‪ ،‬ﺩﺭﺱ ‪،‬ﺩﺍﻧﺸﺠﻮ ‪ ،‬ﮔﺮﻭﻩ ﺁﻣﻮﺯﺷﻲ ‪.‬‬ ‫ﺩﺭ ﻫـﺮ ﻣﺤـﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﺍﻧﻮﺍﻉ ﻣﺨﺘﻠﻒ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ ﻭﺟﻮﺩ ﺩﺍﺭﻧﺪ‪ .‬ﻃﺮﺍﺡ ﭘﺎﻳﮕﺎﻩ ﭘﺲ ﺍﺯ ﻣﻄﺎﻟﻌﻪ ﺩﻗﻴﻖ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ‪ ،‬ﻣﺠﻤﻮﻋﻪ‬ ‫ﻣﻮﺟﻮﺩﻳﺘﻬﺎﻱ ﻣﺤﻴﻂ ﺭﺍ ﺗﻌﻴﻴﻦ ﻣﻲ ﻛﻨﺪ ﻭ ﺍﻳﻦ ﺍﻭﻟﻴﻦ ﻗﺪﻡ ﺩﺭ ﻃﺮﺍﺣﻲ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﺍﺳﺖ‪.‬‬ ‫ﺗـﻮﺟﻪ‪ :‬ﺗﺸـﺨﻴﺺ ﺩﺭﺳـﺖ ﻣﻮﺟـﻮﺩﻳﺖ ﻫﺎ ﻭ ﺷﻨﺎﺳﺎﻳﻲ ﺭﻭﺍﺑﻂ ﺑﻴﻦ ﺁﻧﻬﺎ ﻗﺒﻞ ﺍﺯ ﻫﺮ ﭼﻴﺰ ﺑﺴﺘﮕﻲ ﺑﻪ ﺍﻳﻦ ﺩﺍﺭﺩ ﻛﻪ ﺩﺭ ﻣﻮﺭﺩ ﭼﻪ‬ ‫ﭘﺪﻳـﺪﻩ ﻫﺎﻳـﻲ ﭼـﻪ ﺍﻃﻼﻋﺎﺗـﻲ ﺭﺍ ﻣـﻲ ﺧﻮﺍﻫـﻴﻢ ﺩﺍﺷـﺘﻪ ﺑﺎﺷـﻴﻢ‪ .‬ﻣﻮﺟﻮﺩﻳﺘﻬﺎﻳـﻲ ﺍﻧـﺘﺨﺎﺏ ﻣـﻲ ﺷﻮﻧﺪ ﻛﻪ ﻧﻴﺎﺯﻫﺎﻱ ﺍﻃﻼﻋﺎﺗﻲ ﻫﻤﻪ‬ ‫ﻛﺎﺭﺑﺮﺍﻥ ﻣﺤﻴﻂ ﻧﺎﻇﺮ ﺑﻪ ﺁﻧﻬﺎ ﺑﺎﺷﺪ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٦ /‬‬

‫ﺻﻔﺎﺕ ﺧﺎﺻﻪ‪:‬‬ ‫ﻫـﺮ ﻣﻮﺟـﻮﺩﻳﺖ ﻣﺠﻤـﻮﻋﻪ ﺍﻱ ﺍﺯ ﺻـﻔﺎﺕ ﺧﺎﺻـﻪ ﺍﺳـﺖ ﻛﻪ ﺍﻳﻦ ﻣﺠﻤﻮﻋﻪ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺭﺍ ﻧﻴﺰ ﺑﺎﻳﺪ ﻃﺮﺍﺡ ﺗﻌﻴﻴﻦ ﻛﻨﺪ‪ .‬ﻫﺮ‬ ‫ﺻﻔﺖ ﺍﺯ ﻧﻈﺮ ﻛﺎﺭﺑﺮﺍﻥ ﻳﻚ ﻧﺎﻡ ‪،‬ﻳﻚ ﻧﻮﻉ ﻭ ﻳﻚ ﻣﻌﻨﺎﻱ ﻣﺸﺨﺺ ﺩﺍﺭﺩ ‪.‬‬ ‫ﺑﻌﻨﻮﺍﻥ ﻣﺜﺎﻝ‪ :‬ﻣﻮﺟﻮﺩﻳﺖ ﻛﺎﺭﻣﻨﺪ ﻣﻲ ﺗﻮﺍﻧﺪ ﺩﺍﺭﺍﻱ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺷﻤﺎﺭﻩ ﻛﺎﺭﻣﻨﺪﻱ‪ ،‬ﻧﺎﻡ ﻭ ﺣﻘﻮﻕ ﺑﺎﺷﺪ‪.‬‬ ‫ﺍﺭﺗﺒﺎﻁ‪:‬‬ ‫ﻫـﺮ ﻧـﻮﻉ ﺍﺭﺗـﺒﺎﻁ ﻳﻚ ﻣﻌﻨﺎﻱﻣﺸﺨﺺ ﺩﺍﺭﺩ ﻭ ﺑﺎ ﻳﻚ ﻧﺎﻡ ﺑﻴﺎﻥ ﻣﻲ ﺷﻮﺩﻭ ﻧﻴﺰ ﻣﻲ ﺗﻮﺍﻥ ﮔﻔﺖ ﻛﻪ ﻫﺮ ﻧﻮﻉ ﺍﺭﺗﺒﺎﻁ ‪،‬ﻋﻤﻠﻲ ﺍﺳﺖ‬ ‫ﻛﻪ ﺑﻴﻦ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ ﻭﺟﻮﺩ ﺩﺍﺭﺩ‪.‬‬ ‫ﻻ ﺑﺎ ﻳﻚ ﻋﺒﺎﺭﺕ ﻓﻌﻠﻲ ﻫﻤﺮﺍﻩ ﺍﺳﺖ‪ .‬ﺍﻳﻦ ﺍﺭﺗﺒﺎﻃﺎﺕ‬ ‫ﺍﻧﻮﺍﻉ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎﻱ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﺑﺎ ﻳﻜﺪﻳﮕﺮ ﺍﺭﺗﺒﺎﻁ ﺩﺍﺭﻧﺪ ﻛﻪ ﻣﻌﻤﻮ ﹰ‬ ‫ﻛﻪ ﻫﺮ ﻳﻚ ﺳﻤﺎﻧﺘﻴﻚ ﺧﺎﺹ ﺭﺍ ﺩﺍﺭﺩ ﺑﺎﻳﺪ ﺷﻨﺎﺳﺎﻳﻲ ﺷﺪﻩ ﻭ ﺩﺭ ﭘﺎﻳﮕﺎﻩ ﺫﺧﻴﺮﻩ ﺷﻮﻧﺪ‪.‬‬ ‫ﻣﺜﺎﻝ‪ - :‬ﺩﺍﻧﺸﺠﻮ ﺩﺭﺱ ﺭﺍ ﺍﻧﺘﺨﺎﺏ ﻣﻲ ﻛﻨﺪ‬ ‫‪ -‬ﺩﺭﺱ ﺗﻮﺳﻂ ﺩﺍﻧﺸﺠﻮ ﺍﻧﺘﺨﺎﺏ ﻣﻲ ﺷﻮﺩ‬

‫ﺍﻧﺘﺨﺎﺏ ﻣﻲ ﻛﻨﺪ‬ ‫ﺩﺭﺱ‬

‫ﺍﻧﺘﺨﺎﺏ ﻣﻲ ﺷﻮﺩ‬

‫ﺩﺍﻧﺸﺠﻮ‬

‫ ﺑﻴﻦ ﺩﻭ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻲ ﺗﻮﺍﻧﺪ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﺍﺭﺗﺒﺎﻁ ﻣﺘﻔﺎﻭﺕ ﺑﺎ ﻣﻌﻨﺎﻱ )ﺳﻤﺎﻧﺘﻴﻚ( ﻣﺘﻔﺎﻭﺕ ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬‫ﺍﺭﺗـﺒﺎﻁ ﻣﻤﻜـﻦ ﺍﺳـﺖ ﺑـﻴﻦ ﻳﻚ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﻭ ﺧﻮﺩﺵ ﺑﺎﺷﺪ‪ .‬ﻣﺜﺎﻝ‪ :‬ﻗﻄﻌﻪ ‪ X‬ﺩﺭ ﺳﺎﺧﺖ ﻗﻄﻌﻪ ‪ Y‬ﺑﻜﺎﺭﻣﻲ ﺭﻭﺩ‪ .‬ﺑﻪ‬ ‫ﺍﻳﻦ ﻧﻮﻉ ﺍﺭﺗﺒﺎﻁ ‪،‬ﺍﺭﺗﺒﺎﻁ ﺑﺎﺯﮔﺸﺘﻲ )‪ (Recursive Relationship‬ﻧﻴﺰ ﮔﻔﺘﻪ ﻣﻲ ﺷﻮﺩ‪.‬‬

‫ﺩﺍﻧﺸﺠﻮ‬ ‫ﻣﺎﻫﻴﺖ ﺍﺭﺗﺒﺎﻁ‪:‬‬ ‫ﺗﻨﺎﻇـﺮ ﺑـﻴﻦ ﻋﻨﺎﺻﺮ ﻣﺠﻤﻮﻋﻪ ﻧﻤﻮﻧﻪ ﻫﺎﻱ ﻳﻚ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ‪ ،‬ﺑﺎ ﻋﻨﺎﺻﺮ ﻣﺠﻤﻮﻋﻪ ﻧﻤﻮﻧﻪ ﻫﺎﻱ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﺩﻳﮕﺮ ﺭﺍ ﻣﺎﻫﻴﺖ‬ ‫ﺍﺭﺗﺒﺎﻁ ﮔﻮﻳﻨﺪ‪.‬‬ ‫ﻣﺎﻫﻴﺖ ﺍﺭﺗﺒﺎﻁ ﺑﻴﻦ ﺍﻧﻮﺍﻉ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ‪:‬‬ ‫ﺍﺭﺗﺒﺎﻁ‬

‫‪١:١‬‬

‫ﺗﻨﺎﻇﺮ ﻳﻚ ﺑﻪ ﻳﻚ‬

‫ﺍﺭﺗﺒﺎﻁ‬

‫‪١:n‬‬

‫ﺗﻨﺎﻇﺮ ﻳﻚ ﺑﻪ ﭼﻨﺪ‬

‫ﺍﺭﺗﺒﺎﻁ‬

‫‪n:n‬‬

‫ﺗﻨﺎﻇﺮ ﭼﻨﺪ ﺑﻪ ﭼﻨﺪ‬

‫ ﻣﺎﻫﻴﺖ ﺍﺭﺗﺒﺎﻁ ﺑﺮ ﻣﺒﻨﺎﻱ ﻗﻮﺍﻋﺪﻣﻌﻨﺎﻳﻲ) ﺳﻤﺎﻧﺘﻴﻚ (ﺣﺎﻛﻢ ﺑﺮ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﺗﻌﻴﻴﻦ ﻣﻲ ﺷﻮﺩ‪.‬‬‫ﻣﺜﺎﻝ‪ :‬ﺭﺍﺑﻄﻪ ﺑﻴﻦ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎﻱ ﺍﺳﺘﺎﺩ ﻭ ﺩﺭﺱ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﺑﮕﻴﺮﻳﻢ‪.‬‬ ‫ﺍﻟﻒ ‪ :‬ﻳﻚ ﺍﺳﺘﺎﺩ ﺣﺪﺍﻛﺜﺮ ﻳﻚ ﺩﺭﺱ ﺭﺍ ﺍﺭﺍﺋﻪ ﻣﻲ ﻛﻨﺪ ﻭ ﻫﺮ ﺩﺭﺱ ﺩﻗﻴﻘﹰﺎ ﺗﻮﺳﻂ ﻳﻚ ﺍﺳﺘﺎﺩ ﺍﺭﺍﺋﻪ ﻣﻲ ﺷﻮﺩ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫‪F C101‬‬

‫‪P1 F‬‬

‫‪F PH108‬‬

‫‪P2 F‬‬

‫‪F SH0‬‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٧ /‬‬

‫ﺍﺭﺍﺋﻪ ﻣﻲ ﻛﻨﺪ‬

‫ﺍﺳﺘﺎﺩ‬

‫ﺩﺭﺱ‬

‫‪P3 F‬‬

‫ﺍ ﺭﺍﺋﻪ ﻣﻲ ﺷﻮﺩ‬

‫ﺏ‪) :‬ﺍﺭﺗﺒﺎﻁ ﻳﻚ ﺑﻪ ﭼﻨﺪ( )ﺩﺭﺱ – ﺍﺳﺘﺎﺩ (‬ ‫ﻳﻚ ﺩﺭﺱ ﻣﻤﻜﻦ ﺍﺳﺖ ﺗﻮﺳﻂ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﺍﺳﺘﺎﺩ ﺍﺭﺍﺋﻪ ﺷﻮﺩ ﻭﻟﻲ ﻳﻚ ﺍﺳﺘﺎﺩ ﺣﺪﺍﻛﺜﺮ ﻳﻚ ﺩﺭﺱ ﺭﺍ ﺍﺭﺍﺋﻪ ﻣﻲ ﻛﻨﺪ ‪.‬‬ ‫ﺝ‪):‬ﺍﺭﺗﺒﺎﻁ ﭼﻨﺪ ﺑﻪ ﭼﻨﺪ( ‪:‬‬ ‫ﻳـﻚ ﺍﺳـﺘﺎﺩ ﻣﻤﻜـﻦ ﺍﺳـﺖ ﺑـﻴﺶ ﺍﺯ ﻳﻚ ﺩﺭﺱ ﺭﺍ ﺍﺭﺍﺋﻪ ﻛﻨﺪ ﻭ ﻳﻚ ﺩﺭﺱ ﻣﻤﻜﻦ ﺍﺳﺖ ﺗﻮﺳﻂ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﺍﺳﺘﺎﺩ ﺍﺭﺍﺋﻪ ﺷﻮﺩ‪.‬‬ ‫ﺩﺭﺟﻪ ﺍﺭﺗﺒﺎﻁ‪:‬‬ ‫ﺗﻌﺪﺍﺩ ﻣﻮﺟﻮﺩﻳﺘﻬﺎﻳﻲ ﻛﻪ ﺩﺭ ﺁﻥ ﺍﺭﺗﺒﺎﻁ ﻣﺸﺎﺭﻛﺖ ﺩﺍﺭﻧﺪ ﺩﺭﺟﻪ ﺍﺭﺗﺒﺎﻁ ﻧﺎﻣﻴﺪﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﻣﺜﺎﻝ‪:‬‬

‫ﻗﻄﻌﻪ‬

‫ﺍﺭﺗﺒﺎﻁ ﺩﺭﺟﻪ ‪ ١‬ﻳﺎ ﺭﺍﺑﻄﻪ ﺑﺎﺯﮔﺸﺘﻲ‪:‬‬ ‫ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ‬

‫ﺍﺭﺗﺒﺎﻁ ﺩﺭﺟﻪ ‪:٢‬‬

‫ﺩﺍﻧﺸﺠﻮ‬

‫ﺍﺳﺘﺎﺩ‬

‫ﺭﺍﻫﻨﻤﺎﻳﻲ‬ ‫ﺗﻤﺮﻳﻦ ‪:‬‬ ‫‪ -١‬ﺳﻴﺴﺘﻢ ﺑﺎﻧﻜﻲ ﭼﻪ ﻣﺰﺍﻳﺎﻳﻲ ﺑﺮ ﺳﻴﺴﺘﻢ ﻏﻴﺮ ﺑﺎﻧﻜﻲ ﺩﺍﺭﺩ؟‬ ‫‪ -٢‬ﺑﻪ ﻧﻈﺮ ﺷﻤﺎ ﻣﻌﺎﻳﺐ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﭼﻴﺴﺖ؟‬ ‫‪ -٣‬ﺗﺤﺖ ﭼﻪ ﺷﺮﺍﻳﻄﻲ ﻭ ﻧﻪ ﻟﺰﻭﻣﺎ ﺑﺎﻳﺪ ﺍﺯ ﺗﻜﻨﻮﻟﻮﮊﻱ ﭘﺎﻳﮕﺎﻫﻲ ﺻﺮﻑ ﻧﻈﺮ ﻛﺮﺩ؟‬ ‫‪ -٤‬ﺗﻌﺮﻳﻒ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺭﺍ ﺩﺭ ﺷﺶ ﻣﻨﺒﻊ ﻣﻌﺘﺒﺮ ﺧﺎﺭﺟﻲ ﺑﺮﺭﺳﻲ ﻧﻤﺎﻳﻴﺪ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٨ /‬‬

‫ﻓﺼﻞ ﺩﻭﻡ ‪:‬‬ ‫ﻣــﺪ ﻝ ‪E/R‬‬ ‫‪ -١-٢‬ﻣﻘﺪﻣﻪ ‪:‬‬ ‫ﻳـﻚ ﻣـﺪﻝ ﺩﺍﺩﻩ ﺍﻱ ﻣﺠﻤـﻮﻋﻪ ﺍﻱ ﺍﺯ ﺍﺑـﺰﺍﺭﻫﺎﻱ ﻣﻔﻬﻮﻣـﻲ ﺑـﺮﺍﻱ ﺗﻮﺻـﻴﻒ ﺩﺍﺩﻩ ﻫﺎ ‪ ،‬ﺍﺭﺗﺒﺎﻁ ﺑﻴﻦ ﺩﺍﺩﻩ ﻫﺎ‪،‬ﻣﻌﺎﻧﻲ ﺩﺍﺩﻩ ﻫﺎ ﻭ‬ ‫ﻣﺤـﺪﻭﺩﻳﺖ ﻫـﺎﻱ ﺁﻧﻬﺎﺳـﺖ‪ .‬ﺑﻌﺒﺎﺭﺗـﻲ ﻳـﻚ ﺭﻭﺵ ﺗﻔﻜـﺮ ﺩﺭﺑـﺎﺭﻩ ﺩﺍﺩﻩ ﻫﺎ ﻛﻪ ﺑﻪ ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ ﺭﺑﻄﻲ ﻧﺪﺍﺭﺩ‪.‬ﺩﺭ ﻳﻚ ﻧﮕﺎﻩ ﻛﻠﻲ‬ ‫ﻣﻴﺘﻮﺍﻥ ﺍﻧﻮﺍﻉ ﻣﺪﻟﻬﺎﻱ ﺩﺍﺩﻩ ﺍﻱ ﺭﺍ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﻧﺎﻡ ﺑﺮﺩ ‪:‬‬ ‫•‬

‫ﻣﺪﻟﻬﺎﻱ ﻣﺒﺘﻨﻲ ﺑﺮ ﺍﺷﻴﺎﺀ ‪Object based Logical Models‬‬

‫ﺩﺍﺩﻩ ﻫـﺎ ﺑﺼﻮﺭﺕ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎ ﻛﻪ ﻧﻤﺎﻳﺶ ﺍﺷﻴﺎﺀ ﺩﺭ ﺩﻧﻴﺎﻱ ﻭﺍﻗﻌﻲ ﻣﻴﺒﺎﺷﻨﺪ ﺩﻳﺪﻩ ﻣﻲ ﺷﻮﻧﺪ‪.‬ﺍﺯ ﺟﻤﻠﻪ‬ ‫ﺍﻳﻦ ﻣﺪﻟﻬﺎ ﻣﺪﻝ ﺩﺍﺩﻩ ﺍﻱ ‪E/R‬ﻭ ﻣﺪﻝ ﺷﻲﺀﮔﺮﺍﻳﻲ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﻧﺎﻡ ﺑﺮﺩ‪.‬‬ ‫•‬

‫ﻣﺪﻟﻬﺎﻱ ﻣﺒﺘﻨﻲ ﺑﺮ ﺭﻛﻮﺭﺩ ‪Record based Logical Models‬‬

‫ﺩﺍﺩﻩ ﻫﺎ ﺩﺭ ﻗﺎﻟﺐ ﺭﻛﻮﺭﺩﻫﺎﻱ ﺛﺎﺑﺖ ﻭ ﻳﺎ ﺑﺎ ﻃﻮﻝ ﻣﺘﻐﻴﻴﺮ ﺩﻳﺪﻩ ﻣﻴﺸﻮﻧﺪ‪.‬‬ ‫ﺍﺯ ﺍﻧﻮﺍﻉ ﺩﻳﮕﺮ ﻣﺪﻟﻬﺎﻱ ﺩﺍﺩﻩ ﺍﻱ ﻣﻲ ﺗﻮﺍﻥ ﺑﻪ ﻣﺪﻝ ﻫﺎﻱ ﺩﺍﺩﻩ ﺍﻱ ﺷﺒﻪ ﺳﺎﺧﺘﻴﺎﻓﺘﻪ ‪ ،‬ﻣﺪﻟﻬﺎﻱ ﺷﺒﻜﻪ ﺍﻱ ﻭ ﻣﺪﻟﻬﺎﻱ ﺳﻠﺴﻠﻪ‬ ‫ﻣﺮﺍﺗﺒﻲ ﺍﺷﺎﺭﻩ ﻧﻤﻮﺩ‪.‬‬ ‫ﺍﺯﺟﻤﻠـﻪ ﻣـﺪﻟﻬﺎﻱ ﻣﻨﻄﻘـﻲ ﻣﺒﺘﻨـﻲ ﺑـﺮ ﺍﺷـﻴﺎ ﻣﻲ ﺗﻮﺍﻥ ﻣﺪﻝ ‪ E/R‬ﺭﺍ ﻧﺎﻡ ﺑﺮﺩ‪ .‬ﺩﺭ ﺳﺎﻝ ‪ ١٩٧٦‬ﻳﻚ ﺩﺍﻧﺸﺠﻮﻱ ﺩﻛﺘﺮﺍﻱ ﻛﺎﻣﭙﻴﻮﺗﺮ‬ ‫ﺩﺍﻧﺸﮕﺎﻩ ‪ MIT‬ﺑﻪ ﻧﺎﻡ ﭼﻦ )‪ ( chen‬ﻣﺪﻟﻲ ﺑﺮﺍﻱ ﻃﺮﺍﺣﻲ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﭘﻴﺸﻨﻬﺎﺩ ﻛﺮﺩ ﻛﻪ ﻣﻮﺭﺩ ﺗﻮﺟﻪ ﻋﺎﻡ ﻭﺍﻗﻊ ﺷﺪ‪ .‬ﻭﻱ ﻣﺪﻝ‬ ‫ﺧـﻮﺩ ﺭﺍ ‪ E / R‬ﻧﺎﻣـﻴﺪ‪ .‬ﺍﻳـﻦ ﻣـﺪﻝ ﺩﺭ ﻃﻮﻝ ﺯﻣﺎﻥ ﭘﻴﺸﺮﻓﺖ ﻛﺮﺩ ﻭ ﺳﺎﺧﺘﺎﺭﻫﺎﻱ ﺟﺪﻳﺪﻱ ﺑﻪ ﺁﻥ ﺍﻓﺰﻭﺩﻩ ﺷﺪ‪ .‬ﺩﺭ ﻣﺪﻝ ‪ E / R‬ﻫﺮ‬ ‫ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺩﺍﺭﺍﻱ ﺩﻭ ﺑﺨﺶ ﭘﺪﻳﺪﻩ ﻳﺎ ﻣﻮﺟﻮﺩﻳﺖ ﻭ ﺍﺭﺗﺒﺎﻁ ﻣﻲ ﺑﺎﺷﺪ‪ Chen .‬ﻧﻪ ﺗﻨﻬﺎ ﻣﺪﻝ ‪ E / R‬ﺭﺍ ﻣﻌﺮﻓﻲ ﻧﻤﻮﺩ ﺑﻠﻜﻪ ﻧﻤﻮﺩﺍﺭ‬ ‫ﻣﻮﺟـﻮﺩﻳﺖ ﺭﺍﺑﻄﻪ ﺭﺍ ﻧﻴﺰ ﻣﻄﺮﺡ ﺳﺎﺧﺖ‪ .‬ﻧﻤﻮﺩﺍﺭ ‪ E / R‬ﺭﻭﺷﻲ ﺑﺮﺍﻱ ﻧﻤﺎﻳﺶ ﺳﺎﺧﺘﺎﺭﻱ ﻣﻨﻄﻘﻲ ﻳﻚ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺑﻪ ﺭﻭﺵ‬ ‫ﺗﺼـﻮﻳﺮﻱ ﺍﺳﺖ‪ .‬ﺍﻳﻦ ﻧﻤﻮﺩﺍﺭﻫﺎ ﺍﺑﺰﺍﺭﻫﺎﻳﻲ ﺭﺍﺣﺖ ﻭ ﻣﻨﺎﺳﺐ ﺭﺍ ﺑﺮﺍﻱ ﺩﺭﻙ ﺍﺭﺗﺒﺎﻃﺎﺕ ﻣﺎﺑﻴﻦ ﻣﻮﺟﻮﺩﻳﻬﺎ ﻓﺮﺍﻫﻢ ﻣﻲ ﻛﻨﻨﺪ‪) .‬ﻳﻚ‬ ‫ﺗﺼﻮﻳﺮ ﮔﻮﻳﺎ ﺗﺮ ﺍﺯ ﻫﺰﺍﺭ ﻛﻠﻤﻪ ﺍﺳﺖ‪(.‬‬ ‫ﻻ ﺑﻪ ﺭﻭﺵ ﺭﺳﻢ ﻧﻤﻮﺩﺍﺭﻫﺎﻱ‬ ‫ﺩﺭ ﻭﺍﻗـﻊ‪ ،‬ﺷﻬﺮﺕ ﻭ ﻣﺤﺒﻮﺑﻴﺖ ﻣﺪﻝ ‪ E / R‬ﺑﻪ ﻋﻨﻮﺍﻥ ﺭﻭﺷﻲ ﺑﺮﺍﻱ ﻃﺮﺍﺣﻲ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺍﺣﺘﻤﺎ ﹰ‬ ‫‪ E / R‬ﻣﺮﺑﻮﻁ ﻣﻲ ﺷﺪ ﺗﺎ ﺑﻪ ﺟﻨﺒﻪ ﻫﺎﻱ ﺩﻳﮕﺮ ﺁﻥ‪.‬‬ ‫‪ – ٢ – ٢‬ﻧﻤﺎﻳﺶ ﻧﻤﻮﺩﺍﺭﻱ ‪E / R‬‬

‫ﻣـﺪﻝ ‪ E/R‬ﺑﻜﻤـﻚ ﻧﻤـﻮﺩﺍﺭﻱ ﺗﺤـﺖ ﻧـﺎﻡ ﺧـﻮﺩ ﻗﺎﺑـﻞ ﻧﻤﺎﻳﺶ ﺍﺳﺖ ﻛﻪ ﺩﺭ ﺍﻳﻦ ﻧﻤﻮﺩﺍﺭ ﻣﻔﺎﻫﻴﻢ ﻣﺮﺑﻮﻃﻪ ﺑﺎ ﺍﺷﻜﺎﻝ ﻣﺸﺨﺼﻲ‬ ‫ﺗﺮﺳﻴﻢ ﻣﻴﮕﺮﺩﻧﺪ‪.‬ﺩﺭ ﺍﺩﺍﻣﻪ ﻫﺮ ﻳﻚ ﺍﺯ ﺍﻳﻦ ﺍﺷﻜﺎﻝ ﻧﺸﺎﻥ ﺩﺍﺩﻩ ﺷﺪﻩ ﺍﻧﺪ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩ /‬‬

‫‪ -١-٢-٢‬ﻣﻮﺟﻮﺩﻳﺖ‪:‬‬ ‫ﻣﻮﺟـﻮﺩﻳﺖ‪ ،‬ﭼﻴـﺰﻱ ﺍﺳـﺖ ﻛـﻪ ﺑﺼـﻮﺭﺕ ﻣﺘﻤﺎﻳـﺰ ﻗﺎﺑـﻞ ﺷﻨﺎﺳﺎﻳﻲ ﺑﺎﺷﺪ‪ .‬ﺁﻗﺎﻱ ﭼﻦ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ ﺭﺍ ﺑﻪ ﺩﻭ ﺩﺳﺘﻪ ﻣﻨﻈﻢ )ﻗﻮﻱ( ﻭ‬ ‫ﺿﻌﻴﻒ ﺩﺳﺘﻪ ﺑﻨﺪﻱ ﻛﺮﺩ‪.‬‬ ‫‪ – ١‬ﻣﻮﺟـﻮﺩﻳﺖ ﻣـﻨﻈﻢ)ﻗـﻮﻱ(‪ :‬ﻣﻮﺟﻮﺩﻳﺘـﻲ ﺍﺳﺖ ﻛﻪ ﻭﺟﻮﺩﺵ ﻭﺍﺑﺴﺘﻪ ﺑﻪ ﻣﻮﺟﻮﺩﻳﺖ ﺩﻳﮕﺮﻱ ﻧﻴﺴﺖ‪ .‬ﻣﺜﻞ ﻣﻮﺟﻮﺩﻳﺖ‬ ‫ﺩﺍﻧﺸﺠﻮ ﻭ ﻣﻮﺟﻮﺩﻳﺖ ﺩﺭﺱ ﻛﻪ ﻫﺮﻳﻚ ﺑﻪ ﺗﻨﻬﺎﻳﻲ ﺩﺭ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﺩﺍﻧﺸﻜﺪﻩ ﻣﻄﺮﺡ ﻣﻴﺒﺎﺷﻨﺪ‪.‬‬ ‫‪ – ٢‬ﻣﻮﺟـﻮﺩﻳﺖ ﺿﻌﻴﻒ‪ :‬ﻣﻮﺟﻮﺩﻳﺘﻲ ﺍﺳﺖ ﻛﻪ ﻭﺟﻮﺩﺵ ﻭﺍﺑﺴﺘﻪ ﺑﻪ ﻣﻮﺟﻮﺩﻳﺖ ﺩﻳﮕﺮ ﺍﺳﺖ‪ .‬ﺑﻄﻮﺭ ﻣﺜﺎﻝ ﻣﻮﺟﻮﺩﻳﺖ ﺍﻋﻀﺎﺀ‬ ‫ﺧﺎﻧـﻮﺍﺩﻩ ﻛﺎﺭﻣـﻨﺪ ﻭﺍﺑﺴﺘﻪ ﺑﻪ ﻣﻮﺟﻮﺩﻳﺖ ﻛﺎﺭﻣﻨﺪ ﻣﻲ ﺑﺎﺷﺪ‪ .‬ﻭ ﻳﺎ ﻣﻮﺟﻮﺩﻳﺖ ﺁﺛﺎﺭ ﻣﻨﺘﺸﺮﻩ ﺍﺳﺘﺎﺩ‪ ،‬ﻣﻮﺟﻮﺩﻳﺖ ﺿﻌﻴﻒ ﻣﻮﺟﻮﺩﻳﺖ‬ ‫ﺍﺳﺘﺎﺩ ﺍﺳﺖ‪.‬‬ ‫ﺩﺭ ﻧﻤـﻮﺩﺍﺭ ‪ E / R‬ﻣﻮﺟﻮﺩﻳـﺘﻬﺎﻱ ﻗـﻮﻱ ﺑﺼـﻮﺭﺕ ﻳـﻚ ﻣﺴـﺘﻄﻴﻞ ﻧﺸﺎﻥ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﻧﺪ ﻛﻪ ﻣﺤﺘﻮﺍﻱ ﺁﻥ ﺩﺭ ﺑﺮ ﮔﻴﺮﻧﺪﻩ ﻧﺎﻡ ﻧﻮﻉ‬ ‫ﻣﻮﺟﻮﺩﻳﺖ ﻣﻮﺭﺩ ﻧﻈﺮ ﺍﺳﺖ‪ .‬ﺩﺭ ﻣﻮﺟﻮﺩﻳﺘﻬﺎﻱ ﺿﻌﻴﻒ ﻣﺮﺯ ﻣﺴﺘﻄﻴﻞ ﺑﺼﻮﺭﺕ ﺩﻭ ﺧﻄﻲ ﺍﺳﺖ‪.‬‬

‫ﻣﻮﺟﻮﺩﻳﺖ ﻗﻮﻱ‬

‫ﻣﻮﺟﻮﺩﻳﺖ ﺿﻌﻴﻒ‬ ‫‪ :-٢-٢-٢‬ﺻﻔﺎﺕ ﺧﺎﺻﻪ ‪Attributes‬‬

‫ﺩﺭ ﻧﻤـﻮﺩﺍﺭ ‪ E/R‬ﺻـﻔﺎﺕ ﺧﺎﺻـﻪ ﺑﺼﻮﺭﺕ ﺑﻴﻀﻲ ﻧﺸﺎﻥ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﻧﺪ ﻛﻪ ﻣﺤﺘﻮﺍﻱ ﺁﻥ ﺍﺳﻢ ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﻮﺭﺩ ﻧﻈﺮ ﺭﺍ ﺩﺭ ﺑﺮ‬ ‫ﻣﻲ ﮔﻴﺮﺩ ﻭ ﺑﻪ ﻭﺳﻴﻠﻪ ﺧﻄﻮﻁ ﺗﻮ ﭘﺮ ﺑﻪ ﻣﻮﺟﻮﺩﻳﺖ ﻳﺎ ﺭﺍﺑﻄﻪ ﻣﺮﺑﻮﻁ ﻣﺘﺼﻞ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬

‫ﺍﺳﻢ ﺻﻔﺖ ﺧﺎﺻﻪ‬

‫ﺩﺭ ﻳﻚ ﺗﻘﺴﻴﻢ ﺑﻨﺪﻱ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﺑﻪ ﺷﺮﺡ ﺯﻳﺮ ﺗﻘﺴﻴﻢ ﺑﻨﺪﻱ ﻧﻤﻮﺩ‪:‬‬ ‫ﺍﻟﻒ – ﺻﻔﺖ ﺧﺎﺻﻪ ﻛﻠﻴﺪ)ﺷﻨﺎﺳﻪ ﻣﻮﺟﻮﺩﻳﺖ(‪:‬‬ ‫ﻳﻚ ﻳﺎ ﭼﻨﺪ ﺻﻔﺖ ﺧﺎﺻﻪ ﻛﻪ ﺩﺭ ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻨﺤﺼﺮ ﺑﻪ ﻓﺮﺩ ﺍﺳﺖ‪.‬‬ ‫ﺻﻔﺖ ﺧﺎﺻﻪ ﻛﻠﻴﺪ‪ :‬ﺷﻤﺎﺭﻩ ﺩﺍﻧﺸﺠﻮ‬

‫ﻣﺜﺎﻝ‪ :‬ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ‪ :‬ﺩﺍﻧﺸﺠﻮ ‪:‬‬ ‫ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ‪ :‬ﮔﺮﻭﻩ ﺩﺭﺳﻲ ‪:‬‬

‫ﺻﻔﺖ ﺧﺎﺻﻪ ﻛﻠﻴﺪ‪ :‬ﺷﻤﺎﺭﻩ ﺩﺭﺱ‪ ،‬ﺷﻤﺎﺭﻩ ﮔﺮﻭﻩ ﻭ ﺗﺮﻡ‬

‫ﺑﺮﺍﻱ ﻣﺸﺨﺺ ﻛﺮﺩﻥ ﻛﻠﻴﺪ ﺩﺭ ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﺯﻳﺮ ﺻﻔﺖ ﻳﺎ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻛﻠﻴﺪ ﺧﻂ ﻛﺸﻴﺪﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺏ – ﺻﻔﺖ ﺧﺎﺻﻪ ﺳﺎﺩﻩ ‪ /‬ﻣﺮﻛﺐ‪:‬‬ ‫•‬

‫ﺻﻔﺖ ﺧﺎﺻﻪ ﺳﺎﺩﻩ ﺻﻔﺘﻲ ﺍﺳﺖ ﻛﻪ ﺑﻪ ﺍﺟﺰﺍﺀ ﻛﻮﭼﻜﺘﺮ ﺗﺠﺰﻳﻪ ﭘﺬﻳﺮ ﻧﺒﺎﺷﺪ‪.‬‬

‫•‬

‫ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﺮﻛﺐ ﺻﻔﺘﻲ ﺍﺳﺖ ﻛﻪ ﺑﻪ ﺍﺟﺰﺍﺀ ﻛﻮﭼﻜﺘﺮ ﺗﺠﺰﻳﻪ ﭘﺬﻳﺮ ﺑﺎﺷﺪ‪.‬‬

‫ﺑﻌﻨﻮﺍﻥ ﻣﺜﺎﻝ‪ :‬ﺻﻔﺖ ﺧﺎﺻﻪ ﺁﺩﺭﺱ ﻣﻲ ﺗﻮﺍﻧﺪ ﺑﻪ ﻗﺴﻤﺘﻬﺎﻳﻲ ﻧﻈﻴﺮ ﺷﻬﺮ‪ ،‬ﻛﻮﭼﻪ‪ ،‬ﺧﻴﺎﺑﺎﻥ … ﺗﻘﺴﻴﻢ ﺷﻮﺩ‪.‬‬ ‫ﺷﻬﺮ‬

‫ﻛﻮﭼﻪ‬

‫ﺧﻴﺎﺑﺎﻥ‬

‫ﺁﺩﺭﺱ‬

‫ﭘﻼﻙ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠ /‬‬

‫ﻧﻜﺘﻪ‪ :‬ﺩﺭ ﻣﺪﻝ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺭﺍﺑﻄﻪ ﺍﻱ ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﺮﻛﺐ ﺟﺎﻳﻲ ﻧﺪﺍﺭﺩ‪.‬‬ ‫‪Single Valued / Multi Valued‬‬

‫ﺝ– ﺻﻔﺖ ﺧﺎﺻﻪ ﺗﻚ ﻣﻘﺪﺍﺭﻱ ‪ /‬ﭼﻨﺪ ﻣﻘﺪﺍﺭﻱ‬

‫ﺻـﻔﺎﺗﻲ ﻛـﻪ ﻓﻘـﻂ ﻳﻚ ﻣﻘﺪﺍﺭ ﺭﺍ ﺩﺭ ﻫﺮ ﻟﺤﻈﻪ ﺍﺯ ﺯﻣﺎﻥ ﺑﻪ ﺧﻮﺩ ﺍﺧﺘﺼﺎﺹ ﺩﻫﻨﺪ ﺑﻪ ﺻﻔﺎﺕ ﺗﻚ ﻣﻘﺪﺍﺭﻱ ﻣﻌﺮﻭﻓﻨﺪ‪ .‬ﺑﻪ ﻋﻨﻮﺍﻥ‬ ‫ﻣـﺜﺎﻝ ﺷـﻤﺎﺭﻩ ﺩﺍﻧﺸـﺠﻮﻳﻲ ‪،‬ﺗـﺎﺭﻳﺦ ﺗـﻮﻟﺪ ﺗـﻚ ﻣﻘـﺪﺍﺭﻱ ﻫﺴﺘﻨﺪ‪.‬ﺍﮔﺮ ﺑﺮﺍﻱ ﻳﻚ ﺻﻔﺖ ﺧﺎﺻﻪ ﭼﻨﺪﻳﻦ ﻣﻘﺪﺍﺭ ﺑﺘﻮﺍﻧﺪ ﻗﺮﺍﺭ ﮔﻴﺮﺩ‬ ‫ﺻﻔﺖ ﺧﺎﺻﻪ ﭼﻨﺪ ﻣﻘﺪﺍﺭﻱ ﻧﺎﻣﻴﺪﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺑﻄـﻮﺭ ﻣـﺜﺎﻝ‪ :‬ﺻـﻔﺖ ﺧﺎﺻﻪ ﻣﺪﺭﻙ ﻭ ﻳﺎ ﺗﻠﻔﻦ ﺑﺮﺍﻱ ﺍﺳﺘﺎﺩ ﭼﻨﺪ ﻣﻘﺪﺍﺭﻱ ﻣﺤﺴﻮﺏ ﻣﻲ ﺷﻮﺩ‪ .‬ﺯﻳﺮﺍ ﻳﻚ ﺍﺳﺘﺎﺩ ﻣﻲ ﺗﻮﺍﻧﺪ ﺩﺍﺭﺍﻱ‬ ‫ﭼـﻨﺪ ﻣـﺪﺭﻙ ﻭ ﻳـﺎ ﺗﻠﻔـﻦ ﻣﺨـﺘﻠﻒ ﺑﺎﺷﺪ‪ .‬ﺩﺭ ﻧﻤﻮﺩﺍﺭ ‪ E / R‬ﺑﺮﺍﻱ ﺻﻔﺖ ﺧﺎﺻﻪ ﭼﻨﺪ ﻣﻘﺪﺍﺭﻱ ﺍﺯ ﺑﻴﻀﻲ ﺩﻭ ﺧﻄﻲ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ‬ ‫ﺷﻮﺩ‪.‬‬ ‫ﺩ– ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﺸﺘﻖ )ﺍﺳﺘﻨﺘﺎﺟﻲ( ]ﺩﺍﺭﺍﻱ ﻣﻘﺪﺍﺭ ﻣﺤﺎﺳﺒﻪ ﺷﺪﻧﻲ[‬

‫ﺻﻔﺘﻲ ﺍﺳﺖ ﻛﻪ ﺩﺭ ﻣﻮﺟﻮﺩﻳﺖ ﻭﺟﻮﺩ ﺧﺎﺭﺟﻲ ﻧﺪﺍﺭﺩ ﻭﻟﻲ ﺩﺭ ﺻﻮﺭﺕ ﻟﺰﻭﻡ ﻣﻲ ﺗﻮﺍﻥ ﺁﻥ ﺭﺍ ﺑﺪﺳﺖ ﺁﻭﺭﺩ‪.‬‬ ‫ﻣﺜﺎﻝ‪ :‬ﻣﻮﺟﻮﺩﻳﺖ ‪ :‬ﺍﺳﺘﺎﺩ‪ ،‬ﺻﻔﺖ ﺧﺎﺻﻪ ‪ :‬ﺗﺎﺭﻳﺦ ﺗﻮﻟﺪ‪ ،‬ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﺸﺘﻖ‪ :‬ﺳﻦ‬ ‫ﺩﺭ ﻧﻤﻮﺩﺍﺭ ‪ ER‬ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﺸﺘﻖ ﺑﺎ ﻳﻚ ﺑﻴﻀﻲ ﺑﺎ ﻣﺮﺯ ﻧﻘﻄﻪ ﭼﻴﻦ ﻣﺸﺨﺺ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﻧﻜﺘﻪ ‪ :‬ﺗﺼﻤﻴﻢ ﮔﻴﺮﻱ ﺩﺭ ﻣﻮﺭﺩ ﺻﻔﺖ ﻣﺸﺘﻖ ﺩﺭ ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﺑﻌﻬﺪﻩ ﻃﺮﺍﺡ ﺍﺳﺖ‪.‬‬ ‫ﻩ‪ -‬ﺻﻔﺖ ﺧﺎﺻﻪ ﻫﻴﭽﻤﻘﺪﺍﺭ ﭘﺬﻳﺮ ‪:‬‬ ‫ﻫـﻴﭽﻤﻘﺪﺍﺭ ﻳﻌﻨﻲ ﻳﻚ ﻣﻘﺪﺍﺭ ﻧﺎﺷﻨﺎﺧﺘﻪ ﻭ ﻳﺎ ﻣﻘﺪﺍﺭ ﻏﻴﺮ ﻗﺎﺑﻞ ﺍﻋﻤﺎﻝ ‪.‬ﺍﮔﺮ ﻣﻘﺪﺍﺭ ﻳﻚ ﺻﻔﺖ ﺩﺭ ﻳﻚ ﻳﺎ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﻧﻤﻮﻧﻪ ﺍﺯ‬ ‫ﻳﻚ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﺑﺮﺍﺑﺮ ﻫﻴﭽﻤﻘﺪﺍﺭ ﺑﺎﺷﺪ ﺁﻥ ﺻﻔﺖ ﺧﺎﺻﻪ ﻫﻴﭽﻤﻘﺪﺍﺭ ﭘﺬﻳﺮ ﺍﺳﺖ‪.‬‬ ‫•‬

‫ﻣﺜﺎﻝ ‪ :‬ﺷﻤﺎﺭﻩ ﺗﻠﻔﻦ ﻳﻚ ﻧﻤﻮﻧﻪ ﺍﺳﺘﺎﺩ ﻣﻤﻜﻦ ﺍﺳﺖ ﺩﺭ ﺩﺳﺖ ﻧﺒﺎﺷﺪ‪.‬‬

‫•‬

‫ﻧﺎﻡ ﺍﺳﺘﺎﺩ ﺩﺭ ﻳﻚ ﺑﺮﻧﺎﻣﻪ ﺩﺭﺳﻲ ﺗﺮﻡ ﻣﻤﻜﻦ ﺍﺳﺖ ﻫﻨﻮﺯ ﺍﻋﻼﻡ ﻧﺸﺪﻩ ﺑﺎﺷﺪ‪.‬‬

‫ﺗﻮﺟﻪ ‪ :‬ﺩﺭ ﻧﻤﻮﺩﺍﺭ ‪ E/R‬ﺍﻳﻦ ﺧﺎﺻﻴﺖ ﻧﺸﺎﻥ ﺩﺍﺩﻩ ﻧﻤﻲ ﺷﻮﺩ‪.‬‬ ‫‪ :-٣-٢-٢‬ﺍﺭﺗﺒﺎﻁ‪:‬‬ ‫ﻫﺮ ﺍﺭﺗﺒﺎﻁ ﺑﺼﻮﺭﺕ ﻳﻚ ﻟﻮﺯﻱ ﻧﺸﺎﻥ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﻣﺤﺘﻮﺍﻱ ﺁﻥ ﺩﺭ ﺑﺮ ﮔﻴﺮﻧﺪﻩ ﻧﺎﻡ ﻧﻮﻉ ﺭﺍﺑﻄﻪ ﻣﻮﺭﺩ ﻧﻈﺮ ﺍﺳﺖ‪.‬‬ ‫ﺩﺭ ﻧﻤﻮﺩﺍﺭ ‪ ER‬ﺍﺭﺗﺒﺎﻁ ﺑﺎ ﻣﻮﺟﻮﺩﻳﺖ ﺿﻌﻴﻒ ﺑﺼﻮﺭﺕ ﻟﻮﺯﻱ ﺩﻭ ﺧﻄﻲ ﻧﺸﺎﻥ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺍﺭﺗﺒﺎﻁ‬

‫ﺍﺭﺗﺒﺎﻁ ﺑﺎ ﻣﻮﺟﻮﺩﻳﺖ ﺿﻌﻴﻒ‬

‫ﻋﻨﺼـﺮﻫﺎﻱ ﻫﺮ ﺭﺍﺑﻄﻪ )ﺷﺎﻣﻞ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻭ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎ( ﺑﻮﺳﻴﻠﻪ ﺧﻄﻮﻁ ﭘﺮ ﺑﻪ ﺭﺍﺑﻄﻪ ﻣﺮﺑﻮﻃﻪ ﻭﺻﻞ ﻣﻲ ﺷﻮﻧﺪ‪ .‬ﻫﺮ ﺧﻂ‬ ‫ﺍﺭﺗﺒﺎﻃﻲ ﺑﻴﻦ ﻣﻮﺟﻮﺩﻳﺖ ﻭ ﺭﺍﺑﻄﻪ ﺩﺍﺭﺍﻱ ﺑﺮﭼﺴﺐ ‪ ١‬ﻳﺎ ‪ n‬ﻣﻲ ﺑﺎﺷﺪ ﻛﻪ ﻣﺎﻫﻴﺖ ﺍﺭﺗﺒﺎﻁ ﺭﺍ ﻣﺸﺨﺺ ﻣﻲ ﻛﻨﺪ‪.‬‬ ‫ﺩﺍﻧﺸﺠﻮ‬

‫ﺍﻧﺘﺨﺎﺏ‬

‫ﺣﺬﻑ‬

‫ﺩﺭﺱ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١ /‬‬

‫‪ -١-٣-٢-٢‬ﻭﺿﻊ ﻣﺸﺎﺭﻛﺖ ﺩﺭ ﺍﺭﺗﺒﺎﻁ‬ ‫ﺍﻧـﻮﺍﻉ ﻣﻮﺟﻮﺩﻳﺘﻬﺎﻳـﻲ ﻛـﻪ ﺑـﻴﻦ ﺁﻧﻬـﺎ ﺍﺭﺗـﺒﺎﻁ ﺑﺮﻗـﺮﺍﺭ ﺍﺳـﺖ ﺷـﺮﻛﺖ ﻛﻨﻨﺪﮔﺎﻥ ﺁﻥ ﺍﺭﺗﺒﺎﻁ ﻧﺎﻡ ﺩﺍﺭﻧﺪ‪ .‬ﻣﺸﺎﺭﻛﺖ ﻳﻚ ﻧﻮﻉ‬ ‫ﻣﻮﺟﻮﺩﻳﺖ ﺩﺭ ﻳﻚ ﻧﻮﻉ ﺍﺭﺗﺒﺎﻁ ﻣﻤﻜﻦ ﺍﺳﺖ ﺍﻟﺰﺍﻣﻲ )ﻛﺎﻣﻞ( ﻳﺎ ﻏﻴﺮﺍﻟﺰﺍﻣﻲ )ﻧﺎﻛﺎﻣﻞ( ﺑﺎﺷﺪ‪.‬‬ ‫ﻣﺸـﺎﺭﻛﺖ ﻳـﻚ ﻧـﻮﻉ ﻣﻮﺟـﻮﺩﻳﺖ ﺩﺭ ﻳـﻚ ﻧﻮﻉ ﺍﺭﺗﺒﺎﻁ ﺭﺍ ﺍﻟﺰﺍﻣﻲ ﮔﻮﻳﻨﺪ ﺍﮔﺮ ﺗﻤﺎﻡ ﻧﻤﻮﻧﻪ ﻫﺎﻱ ﺁﻥ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﺩﺭ ﺁﻥ‬ ‫ﺑﺎﻳﺪ ﺩﺭ ﺍﺭﺗﺒﺎﻁ ﺷﺮﻛﺖ ﻛﻨﻨﺪ‪.‬ﺩﺭ ﻏﻴﺮ ﺍﻳﻨﺼﻮﺭﺕ ﻣﺸﺎﺭﻛﺖ ﻏﻴﺮ ﺍﻟﺰﺍﻣﻲ )ﺍﺧﺘﻴﺎﺭﻱ( ﺍﺳﺖ‪.‬‬ ‫ﻣـﺜﺎﻝ ‪ :‬ﻣﺸﺎﺭﻛﺖ ﺩﺍﻧﺸﺠﻮ ﺩﺭ ﺍﺭﺗﺒﺎﻁ ﺍﻧﺘﺨﺎﺏ ﺍﻟﺰﺍﻣﻲ ﺍﺳﺖ ﻭﻟﻲ ﻣﺸﺎﺭﻛﺖ ﺩﺍﻧﺸﺠﻮ ﺩﺭ ﺍﺭﺗﺒﺎﻁ ﺣﺬﻑ ﺩﺭﺱ ﺍﻟﺰﺍﻣﻲ ﻧﻴﺴﺖ‬ ‫ﺯﻳﺮﺍ ﻟﺰﻭﻣﺎ ﻫﻤﻪ ﺩﺍﻧﺸﺠﻮﻳﺎﻥ ﺩﺭﺱ ﺭﺍ ﺣﺬﻑ ﻧﻤﻴﻜﻨﻨﺪ‪ .‬ﺩﺭ ﻧﻤﻮﺩﺍﺭ ‪ E/R‬ﻣﺸﺎﺭﻛﺖ ﺍﻟﺰﺍﻣﻲ ﺑﺎ ﺩﻭﺧﻂ ﻧﺸﺎﻥ ﺩﺍﺩﻩ ﻣﻴﺸﻮﺩ‪.‬‬ ‫ﺩﺍﻧﺸﺠﻮ‬

‫ﺍﻧﺘﺨﺎﺏ‬

‫ﺩﺭﺱ‬

‫ﺣﺬﻑ‬ ‫‪ :Total participation:‬ﻫﺮ ﻣﻮﺟﻮﺩﻳﺖ ﺣﺪﺍﻗﻞ ﺩﺭ ﻳﻚ ﺭﺍﺑﻄﻪ ﺍﺯ ﻣﺠﻤﻮﻋﻪ ﺍﺭﺗﺒﺎﻁ ﻣﺸﺎﺭﻛﺖ ﺩﺍﺭﺩ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﻣﺸﺎﺭﻛﺖ ﻭﺍﻡ ﺩﺭ ﺍﺭﺗﺒﺎﻁ ﻭﺍﻡ ﮔﺮﻓﺘﻦ ﻛﺎﻣﻞ ﺍﺳﺖ‪ .‬ﻫﺮ ﻭﺍﻡ ﺑﺎﻳﺪ ﺣﺪﺍﻗﻞ ﻳﻚ ﻣﺸﺘﺮﻱ ﻣﺘﻨﺎﻇﺮ ﺑﺎ ﺍﺭﺗﺒﺎﻁ ﻭﺍﻡ‬ ‫ﮔﻴﺮﻧﺪﻩ ﺩﺍﺭﺩ‪.‬‬ ‫‪ : Partial participation‬ﺑﺮﺧﻲ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎ ﻣﻤﻜﻦ ﺍﺳﺖ ﺩﺭ ﻫﻴﭻ ﺍﺭﺗﺒﺎﻃﻲ ﺍﺯ ﻣﺠﻤﻮﻋﻪ ﺍﺭﺗﺒﺎﻃﺎﺕ‬ ‫ﻣﺸﺎﺭﻛﺖ ﻧﺪﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ‪.‬‬ ‫ﻣﺜﻼ ‪ :‬ﻫﻤﻪ ﻣﺸﺘﺮﻳﺎﻥ ﻣﻤﻜﻦ ﺍﺳﺖ ﻭﺍﻡ ﻧﮕﻴﺮﻧﺪ‪.‬ﻳﻌﻨﻲ ﻣﺸﺎﺭﻛﺖ ﻣﺸﺘﺮﻱ ﻧﺎﻛﺎﻣﻞ ﺍﺳﺖ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٢ /‬‬

‫‪ -٢-٣-٢-٢‬ﻧﻮﻉ ﺍﺭﺗﺒﺎﻁ ﺑﻪ ﻣﺜﺎﺑﻪ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ )ﺍﺭﺗﺒﺎﻁ ﻣﻮﺟﻮﺩﻳﺘﻲ(‬ ‫ﺩﺭ ﻳـﻚ ﺩﻳـﺪ ﻛﻠـﻲ ﻣـﻲ ﺗـﻮﺍﻥ ﮔﻔـﺖ ﻧـﻮﻉ ﺍﺭﺗﺒﺎﻁ ﺧﻮﺩ ﻧﻮﻋﻲ ﻣﻮﺟﻮﺩﻳﺖ ﺍﺳﺖ ‪ .‬ﺯﻳﺮﺍ ﭘﺪﻳﺪﻩ ﺍﻱ ﺍﺳﺖ ﻛﻪ ﺩﺭ ﺩﻧﻴﺎﻱ ﻭﺍﻗﻌﻲ‬ ‫ﻭﺟـﻮﺩ ﺩﺍﺭﺩ ‪ .‬ﺑـﺎ ﺗـﻮﺟﻪ ﺑﻪ ﺍﻳﻦ ﺗﻌﺮﻳﻒ ﻣﻲ ﺗﻮﺍﻥ ﮔﻔﺖ ﭼﻮﻥ ﻧﻮﻉ ﺍﺭﺗﺒﺎﻁ ﺧﻮﺩ ﻧﻮﻋﻲ ﻣﻮﺟﻮﺩﻳﺖ ﺍﺳﺖ ﻟﺬﺍ ﻣﻲ ﺗﻮﺍﻧﺪ ﺻﻔﺖ ﻳﺎ‬ ‫ﺻـﻔﺎﺕ ﺧﺎﺻـﻪ ﺍﻱ ﺩﺍﺷـﺘﻪ ﺑﺎﺷﺪ‪.‬ﺍﻣﺎ ﻣﻌﻤﻮﻻ ﻓﺎﻗﺪ ﺻﻔﺖ ﺷﻨﺎﺳﻪ ﺍﺳﺖ‪.‬ﺍﺭﺗﺒﺎﻁ ﻳﻚ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﺿﻌﻴﻒ ﺑﺎ ﻣﻮﺟﻮﺩﻳﺖ ﻗﻮﻱ‬ ‫ﻣﻌﻤﻮﻻ ﺻﻔﺖ ﺧﺎﺻﻪ ﻧﺪﺍﺭﺩ‪.‬‬ ‫ﺩﺭ ﻣـﺜﺎﻝ ﺩﺍﻧﺸـﺠﻮ ﻭ ﺩﺭﺱ ﻭ ﺭﺍﺑﻄـﻪ ﺍﻧـﺘﺨﺎﺏ ﻣـﻲ ﺗـﻮﺍﻥ ﺻﻔﺖ ﺧﺎﺻﻪ ﻫﺎﻱ ﺗﺮﻡ ﻭ ﻧﻤﺮﻩ ﻭ ﺩﺭ ﺭﺍﺑﻄﻪ ﺣﺬﻑ ﺻﻔﺎﺕ ﺗﺮﻡ ﻭ ﻧﻮﻉ‬ ‫ﺣﺬﻑ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺖ‪.‬‬ ‫ﻧﻤﺮﻩ‬

‫ﺗﺮﻡ‬

‫ﺩﺭﺱ‬

‫ﺍﻧﺘﺨﺎﺏ‬

‫ﺩﺍﻧﺸﺠﻮ‬

‫ﺣﺬﻑ‬ ‫ﺗﺮﻡ‬ ‫ﻧﻮﻉ ﺣﺬﻑ‬

‫‪ -٣-٣-٢-٢‬ﻣﺎﻫﻴﺖ ﻧﻮﻉ ﺍﺭﺗﺒﺎﻁ‬ ‫ﭼﮕﻮﻧﮕﻲ ﺗﻨﺎﻇﺮ ﺑﻴﻦ ﺩﻭ ﻣﺠﻤﻮﻋﻪ ﻧﻤﻮﻧﻪ ﻫﺎﻱ ﻣﻮﺟﻮﺩﻳﺖ ﺭﺍ ﻣﺎﻫﻴﺖ ﺍﺭﺗﺒﺎﻁ ﮔﻮﻳﻨﺪ‪.‬ﻣﻲ ﺩﺍﻧﻴﻢ ﺳﻪ ﻧﻮﻉ ﺗﻨﺎﻇﺮ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪:‬‬ ‫ﺗﻨﺎﻇﺮ ﻳﻚ ﺑﻴﻚ ‪ ،‬ﺗﻨﺎﻇﺮ ﻳﻚ ﺑﻪ ﭼﻨﺪ ﻭ ﺗﻨﺎﻇﺮ ﭼﻨﺪ ﺑﻪ ﭼﻨﺪ‪ .‬ﺍﻳﻦ ﺳﻪ ﮔﻮﻧﻪ ﺗﻨﺎﻇﺮ ﺭﺍ ﭼﻨﻴﻦ ﻧﺸﺎﻥ ﻣﻴﺪﻫﻴﻢ ‪:‬‬ ‫‪.N : M ، 1 : N ، 1 : 1‬‬ ‫ﻣـﺜﺎﻝ ‪:‬ﻣﺎﻫـﻴﺖ ﺍﺭﺗﺒﺎﻁ ﺩﺭ ﺭﺍﺑﻄﻪ ﺣﺬﻑ ﺗﻚ ﺩﺭﺱ ﻣﻌﻤﻮﻻ ‪1:N‬ﺍﺳﺖ )ﻳﻌﻨﻲ ﻳﻚ ﺩﺍﻧﺸﺠﻮ ﻳﻚ ﺩﺭﺱ ﺭﺍ ﺣﺬﻑ ﻣﻴﻜﻨﺪﺩﻭﻟﻲ‬ ‫ﻳﻚ ﺩﺭﺱ ﻣﻤﻜﻦ ﺍﺳﺖ ﺗﻮﺳﻂ ﭼﻨﺪ ﺩﺍﻧﺸﺠﻮ ﺣﺬﻑ ﺷﻮﺩ (‪.‬‬ ‫‪N‬‬

‫‪M‬‬

‫ﺩﺭﺱ‬

‫ﺍﻧﺘﺨﺎﺏ‬

‫ﺩﺍﻧﺸﺠﻮ‬ ‫‪N‬‬

‫ﺣﺬﻑ‬

‫‪1‬‬

‫ﺑـﺮﺍﻱ ﻧﻤـﺎﻳﺶ ﻣﺎﻫـﻴﺖ ﺍﺭﺗـﺒﺎﻁ ﺩﺭ ﻧﻤـﻮﺩﺍﺭ ‪ E/R‬ﺭﻭﺵ ﺩﻳﮕـﺮﻱ ﻧﻴـﺰ ﻭﺟـﻮﺩ ﺩﺍﺭﺩ ‪ .‬ﺩﺭ ﺍﻳـﻦ ﺭﻭﺵ ﺑﻪ ﻫﺮ ﻣﺸﺎﺭﻛﺖ ﻳﻚ ﻧﻮﻉ‬ ‫ﻣﻮﺟﻮﺩﻳﺖ ﺩﺭ ﻳﻚ ﺍﺭﺗﺒﺎﻁ ‪ ،‬ﻳﻚ ﺯﻭﺝ ﻋﺪﺩ ﺻﺤﻴﺢ ﺑﻪ ﺻﻮﺭﺕ )‪( min,max‬‬

‫ﺍﻧﺘﺴﺎﺏ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﺩ‪.‬ﺑﻪ ﺍﻳﻦ ﻣﻌﻨﻲ ﻛﻪ ﺩﺭ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٣ /‬‬

‫ﻫـﺮ ﻟﺤﻈـﻪ ‪ ،‬ﻫـﺮ ﻧﻤـﻮﻧﻪ ﻣﻮﺟﻮﺩﻳﺖ ‪ e‬ﺍﺯ ﻧﻮﻉ ‪ E‬ﺑﺎﻳﺪ ﺣﺪﺍﻗﻞ ﺩﺭ ‪ min‬ﻭ ﺣﺪﺍﻛﺜﺮ ﺩﺭ ‪ max‬ﻧﻤﻮﻧﻪ ﺍﺯ ﺍﺭﺗﺒﺎﻁ ‪ R‬ﺷﺮﻛﺖ ﺩﺍﺷﺘﻪ‬ ‫ﺑﺎﺷﺪ‪ .‬ﺍﮔﺮ‪ min=0‬ﻣﺸﺎﺭﻛﺖ ﻏﻴﺮ ﺍﻟﺰﺍﻣﻲ)ﺍﺧﺘﻴﺎﺭﻱ( ﻭ ﺩﺭ ﻏﻴﺮ ﺍﻳﻨﺼﻮﺭﺕ ﻣﺸﺎﺭﻛﺖ ﺍﻟﺰﺍﻣﻲ ﺍﺳﺖ ‪.‬‬

‫ﻣﻮﺍﺭﺩ ﺍﻇﺎﻓﻪ ﺷﺪﻩ ﺑﻪ ﻧﻤﻮﺩﺍﺭ ‪E/R‬‬

‫‪ -٤-٢-٢‬ﺗﺠﺰﻳﻪ ﻭ ﺗﺮﻛﻴﺐ ‪:‬‬ ‫ﺗﺠـﺰﻳﻪ ﻳـﺎ ﺟﺪﺍﺳـﺎﺯﻱ ﻳﻌﻨـﻲ ﻳـﻚ ﺷـﻲﺀ ﻛﻠﻲ ﺭﺍ ﺑﻪ ﺍﺟﺰﺍﺀ ﺗﺸﻜﻴﻞ ﺩﻫﻨﺪﻩ ﺁﻥ ﺗﻘﺴﻴﻢ ﻛﻨﻴﻢ ‪ .‬ﺷﻲﺀ ﻛﻞ ‪ ،‬ﺻﻔﺎﺕ ‪،‬ﺳﺎﺧﺘﺎﺭ ﻭ‬ ‫ﺭﻓـﺘﺎﺭ ﺧـﻮﺩ ﺭﺍ ﺩﺍﺭﺩ ﻭ ﻫـﺮ ﻳـﻚ ﺍﺯ ﺍﺟـﺰﺍﺀ ﻧﻴـﺰ ﺻـﻔﺎﺕ ‪،‬ﺳﺎﺧﺘﺎﺭ ﻭ ﺭﻓﺘﺎﺭ ﺧﺎﺹ ﺧﻮﺩﺭﺍ ﺩﺍﺭﻧﺪ‪ .‬ﺑﻪ ﺍﻳﻦ ﻧﻮﻉ ﺍﺭﺗﺒﺎﻁ ﺩﺭ ‪E/ R‬‬

‫ﺍﺭﺗﺒﺎﻁ “ ﺟﺰﺋﻲ ﺍﺳﺖ ﺍﺯ ‪ “..‬ﻭ ﻳﺎ ‪ I S –A PART -OF‬ﮔﻔﺘﻪ ﻣﻲ ﺷﻮﺩ ‪.‬‬ ‫‪Computer‬‬

‫‪keyboard‬‬

‫‪Monitor‬‬

‫‪ -٥-٢-٢‬ﺯﻳﺮ ﻧﻮﻉ ﻫﺎ ﻭ ﺍﺑﺮﻧﻮﻉ ﻫﺎﻱ ﻣﻮﺟﻮﺩﻳﺖ‬

‫‪Hard‬‬

‫‪RAM‬‬

‫‪Subtype and Supertype‬‬

‫ﻼ ﺍﮔﺮ ﺑﻌﻀﻲ ﻛﺎﺭﻣﻨﺪﺍﻥ‪ ،‬ﺑﺮﻧﺎﻣﻪ ﻧﻮﻳﺲ ﺑﺎﺷﻨﺪ ﻭ ﺗﻤﺎﻡ ﺑﺮﻧﺎﻣﻪ‬ ‫ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻲ ﺗﻮﺍﻧﺪ ﺑﻄﻮﺭ ﻫﻤﺰﻣﺎﻥ ﺍﺯ ﺍﻧﻮﺍﻉ ﻣﺨﺘﻠﻔﻲ ﺑﺎﺷﺪ‪ .‬ﻣﺜ ﹰ‬ ‫ﻧﻮﻳﺴﺎﻥ ﻛﺎﺭﻣﻨﺪ‪ ،‬ﺁﻧﮕﺎﻩ ﻣﻲ ﺗﻮﺍﻥ ﮔﻔﺖ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﺑﺮﻧﺎﻣﻪ ﻧﻮﻳﺲ ﻳﻚ ﺯﻳﺮ ﻧﻮﻉ ﺍﺯ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﻛﺎﺭﻣﻨﺪ ﺍﺳﺖ‪.‬‬ ‫ﺍﮔـﺮ ﻧـﻮﻉ ﻣﻮﺟـﻮﺩﻳﺖ ‪ ، y‬ﻳـﻚ ﺯﻳﺮ ﻧﻮﻉ ﺍﺯ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ‪ x‬ﺑﺎﺷﺪ ﺁﻧﮕﺎﻩ ﺧﻄﻲ ﺟﻬﺖ ﺩﺍﺭ ﺍﺯ ﻣﺴﺘﻄﻴﻞ ‪ x‬ﺑﻪ ﻣﺴﺘﻄﻴﻞ ‪ y‬ﺭﺳﻢ‬ ‫ﻣﻲ ﺷﻮﺩ‪) .‬ﻫﺮ ‪ y‬ﻳﻚ ‪ x‬ﺍﺳﺖ( ﺍﻳﻦ ﺍﺭﺗﺒﺎﻁ ﺑﺮﺍﻱ ﭘﺮﻫﻴﺰ ﺍﺯ ﺗﻜﺮﺍﺭ ﺻﻔﺎﺕ‬ ‫ﺧﺎﺻﻪ ﺑﻴﻦ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ ﺩﺭ ﻳﻚ ﻧﻤﻮﺩﺍﺭ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ‬

‫ﺷﻤﺎﺭﻩ‬

‫ﻛﺎﺭﻣﻨﺪ‬ ‫ﻧﺎﻡ‬

‫ﺑﺮﻧﺎﻣﻪ ﻧﻮﻳﺲ‬ ‫ﻧﺎﻡ‬

‫‪ -١ -٥-٢-٢‬ﺗﺨﺼﻴﺺ )‪:(SPECIALIZATION‬‬ ‫ﻣﺸـﺨﺺ ﻛـﺮﺩﻥ ﮔـﻮﻧﻪ ﻫﺎﻱ ﺧﺎﺹ ﻳﻚ ﺷﻲﺀ ﺭﺍ ﺗﺨﺼﻴﺺ ﮔﻮﻳﻨﺪ‪ .‬ﺑﻄﻮﺭ ﻣﺜﺎﻝ ﺍﮔﺮ ﺷﻲﺀ ﻣﻮﺟﻮﺩ ﺯﻧﺪﻩ ﺭﺍ ﺩﺭﻧﻈﺮ ﺑﮕﻴﺮﻳﻢ‬ ‫ﺳـﻪ ﮔـﻮﻧﻪ ﺧﺎﺹ ﺁﻥ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ ‪ :‬ﺍﻧﺴﺎﻥ ‪ ،‬ﺣﻴﻮﺍﻥ ﻭ ﻧﺒﺎﺕ ‪ .‬ﺩﺭ ﻧﻤﻮﺩﺍﺭ ‪ E/R‬ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻴﺘﻮﺍﻧﺪ ﺯﻳﺮﻧﻮﻉ ﻫﺎﻳﻲ ﺩﺍﺷﺘﻪ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٤ /‬‬

‫ﺑﺎﺷﺪ ‪ .‬ﮔﻮﻳﻴﻢ ﺑﻴﻦ ﻫﺮ ﺯﻳﺮ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﻭ ﺍﺑﺮ ﻧﻮﻉ ﺁﻥ ﺍﺭﺗﺒﺎﻁ “ ﮔﻮﻧﻪ ﺍﻱ ﺍﺳﺖ ﺍﺯ‪”...‬‬

‫ﻳﺎ ﻫﺴﺖ ﻳﻚ …‬

‫‪IS‬‬

‫‪- A‬ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪.‬‬ ‫ﺗﺨﺼـﻴﺺ ‪ :‬ﻳـﻚ ﻓـﺮﺍﻳﻨﺪ ﺍﺯ ﺑـﺎﻻ ﺑـﻪ ﭘﺎﻳـﻴﻦ ﺍﺳـﺖ‪ .‬ﺩﺭ ﺗﺨﺼـﻴﺺ ﻳـﻚ ﻣﻮﺟـﻮﺩﻳﺖ ﺑﻪ ﮔﻮﻧﻪ ﻫﺎﻱ ﻣﺨﺘﻠﻒ ﮔﺮﻭﻩ ﺑﻨﺪﻱ‬ ‫ﻣـﻲ ﺷﻮﺩ‪ .‬ﺍﻳﻦ ﮔﺮﻭﻫﻬﺎ ﺑﻪ ﻋﻨﻮﺍﻥ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﭘﺎﻳﻴﻦ ﺗﺮ ﺁﻥ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻨﻈﻮﺭ ﻣﻲ ﮔﺮﺩﻧﺪ‪ .‬ﺩﺭ ﻧﻤﻮﺩﺍﺭ ‪ E/R‬ﺗﺨﺼﻴﺺ‬ ‫ﺑـﺎ ﻳـﻚ ﻣـﺜﻠﺚ ﺣـﺎﻭﻱ ‪ ISA‬ﻧﺸـﺎﻥ ﺩﺍﺩﻩ ﻣـﻲ ﺷـﻮﺩ‪ .‬ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﭘﺎﻳﻴﻦ ﺗﻤﺎﻡ ﺧﺼﻮﺻﻴﺎﺕ ﻣﺠﻤﻮﻋﻪ ﻣﻮﺟﻮﺩﻳﺖ‬ ‫ﺳﻄﺢ ﺑﺎﻻﺗﺮ ﺭﺍ ﺑﻪ ﺍﺭﺙ ﻣﻲ ﺑﺮﺩ‪.‬‬

‫ﻧﺎﻡ‬

‫ﺩﺍﻧﺸﺠﻮ‬

‫ﺷﻤﺎﺭﻩ‬

‫ﻧﺎﻡ ﺧﺎﻧﻮﺍﺩﮔﻲ‬

‫ﺩﺍﻧﺸﺠﻮﻱ ﻛﺎﺭﺷﻨﺎﺳﻲ‬

‫‪٢‬‬

‫‪ -٢-٥-٢-٢‬ﺗﻌﻤﻴﻢ ‪:‬‬

‫ﺩﺍﻧﺸﺠﻮﻱ ﻛﺎﺭﺩﺍﻧﻲ‬

‫ﺩﺍﻧﺸﺠﻮﻱ ﺩﻛﺘﺮﺍ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٥ /‬‬

‫ﺗﻌﻤـﻴﻢ ﻋﻜـﺲ ﻋﻤـﻞ ﺗﺨﺼـﻴﺺ ﺍﺳـﺖ ﺑـﻪ ﺍﻳﻦ ﻣﻌﻨﺎ ﻛﻪ ﺑﺎ ﺩﺍﺷﺘﻦ ﺯﻳﺮ ﻧﻮﻉ ﻫﺎﻱ ﺧﺎﺹ ‪ ،‬ﺻﻔﺎﺕ ﻣﺸﺘﺮﻙ ﺑﻴﻦ ﺁﻧﻬﺎ ﺭﺍ ﺩﺭ ﻳﻚ‬ ‫ﻣﺠﻤـﻮﻋﻪ ﺻـﻔﺎﺕ ﺑـﺮﺍﻱ ﻳـﻚ ﺍﺑـﺮﻧﻮﻉ ﻣﻮﺟـﻮﺩﻳﺖ ﺩﺭ ﻧﻈـﺮ ﻣـﻲ ﮔﻴﺮﻳﻢ‪ .‬ﺗﻌﻤﻴﻢ ﻳﻚ ﻓﺮﺍﻳﻨﺪ ﺍﺯ ﭘﺎﻳﻴﻦ ﺑﻪ ﺑﺎﻻﺳﺖ ﻛﻪ ﺗﻌﺪﺍﺩﻱ‬ ‫ﻣﺠﻤﻮﻋﻪ ﻣﻮﺟﻮﺩﻳﺘﻲ ﻛﻪ ﺧﺼﻮﺻﻴﺎﺕ ﻣﺸﺘﺮﻙ ﺩﺍﺭﻧﺪ ﺭﺍ ﺑﺎﻫﻢ ﺗﺮﻛﻴﺐ ﻣﻲ ﻛﻨﺪ‪.‬‬

‫ﺩﺍﻧﺸﺠﻮﻱ ﻛﺎﺭﺩﺍﻧﻲ‬ ‫ﺷﻤﺎﺭﻩ‬

‫ﺻﻔﺎﺕ ﺧﺎﺹ‬

‫ﺩﺍﻧﺸﺠﻮﻱ ﻛﺎﺭﺷﻨﺎﺳﻲ‬ ‫ﻧﺎﻡ‬

‫ﺷﻤﺎﺭﻩ‬

‫ﺻﻔﺎﺕ ﻣﺸﺘﺮﻙ‬

‫ﺻﻔﺎﺕ ﻣﺸﺘﺮﻙ‬

‫ﻧﺎﻡ‬

‫ﺻﻔﺎﺕ ﺧﺎﺹ‬

‫ﻧﺎﻡ‬

‫ﺻﻔﺎﺕ ﻣﺸﺘﺮﻙ‬

‫ﺩﺍﻧﺸﺠﻮ‬ ‫ﺷﻤﺎﺭﻩ‬

‫ﻧﺎﻡ ﺧﺎﻧﻮﺍﺩﮔﻲ‬

‫ﺩﺍﻧﺸﺠﻮﻱ ﻛﺎﺭﺷﻨﺎﺳﻲ‬

‫ﺩﺍﻧﺸﺠﻮﻱ ﻛﺎﺭﺩﺍﻧﻲ‬

‫ﺻﻔﺎﺕ ﺧﺎﺹ‬

‫ﺻﻔﺎﺕ ﺧﺎﺹ‬

‫ﺗﻮﺟﻪ ‪-:‬ﺗﺨﺼﻴﺺ ﻭ ﺗﻌﻤﻴﻢ ﻣﻌﻜﻮﺱ ﻳﻜﺪﻳﮕﺮﻧﺪ ﻛﻪ ﻫﺮ ﺩﻭ ﺩﺭ ﻧﻤﻮﺩﺍﺭ ﺑﺎﻳﻚ ﺷﻜﻞ ﻧﺸﺎﻥ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬ ‫ﻗﻴﻮﺩ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺩﺭ ﺍﺭﺗﺒﺎﻁ ﺳﻠﺴﻠﻪ ﻣﺮﺍﺗﺒﻲ ﺗﻌﻤﻴﻢ‪/‬ﺗﺨﺼﻴﺺ‬ ‫ﺑﺮﺍﻱ ﻣﺪﻝ ﺳﺎﺯﻱ ﺩﻗﻴﻖ ﺗﺮ ﻳﻚ ﺳﺎﺯﻣﺎﻥ ‪ ،‬ﻃﺮﺍﺡ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻣﻤﻜﻦ ﺍﺳﺖ ﻣﺤﺪﻭﺩﻳﺖ ﻫﺎ ‪/‬ﻗﻴﺪﻫﺎ ﻳﻲ ﺭﺍ ﺩﺭ ﻳﻚ ﺗﻌﻤﻴﻢ ﻭﻳﮋﻩ‬ ‫ﺩﺭ ﻧﻈـﺮ ﺑﮕﻴﺮﺩ ‪ .‬ﻳﻜﻲ ﺍﺯﺍﻳﻦ ﻗﻴﺪ ﻫﺎ ﺗﻌﻴﻴﻦ ﺍﻳﻦ ﺍﺳﺖ ﻛﻪ ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻲ ﺗﻮﺍﻧﺪﻋﻀﻮﻱ ﺍﺯ ﻳﻚ ﻣﺠﻤﻮﻋﻪ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ‬ ‫ﭘﺎﻳﻴﻦ ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺘﻪ ﺷﻮﺩ‪ .‬ﻋﻀﻮﻳﺖ ﻣﻲ ﺗﻮﺍﻧﺪﺑﺮ ﺍﺳﺎﺱ ﺷﺮﺍﻳﻂ ﻭ ﻳﺎ ﺗﻮﺳﻂ ﻛﺎﺭﺑﺮ ﺗﻌﻴﻴﻦ ﮔﺮﺩﺩ‪.‬‬ ‫ﺑﺮ ﺣﺴﺐ ﺷﺮﻁ ﺧﺎﺹ ﺗﻌﺮﻳﻒ ﺷﺪﻩ‪:‬‬ ‫ﺩﺭﺍﻳﻦ ﺣﺎﻟﺖ ﻋﻀﻮﻳﺖ ﺑﺮ ﺍﺳﺎﺱ ﻳﻚ ﺷﺮﻁ ﺻﺮﻳﺢ ﻳﺎ ﮔﺰﺍﺭﻩ ﺍﻱ ﺑﻴﺎﻥ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪condition-defined‬‬ ‫;‪E.g. all customers over 65 years are members of senior-citizen entity set‬‬ ‫‪senior-citizen ISA person.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٦ /‬‬

‫ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺗﻮﺳﻂ ﻛﺎﺭﺑﺮ‪:‬‬ ‫ﻛﺎﺭﺑﺮ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻣﻮﺟﻮﺩﻳﺖ ﺭﺍ ﺑﻪ ﻳﻚ ﻣﺠﻤﻮﻋﻪ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻮﺭﺩ ﻧﻈﺮ ﺗﺨﺼﻴﺺ ﻣﻲ ﺩﻫﺪ‪.‬‬ ‫ﻧﻮﻉ ﺩﻳﮕﺮ ﻣﺤﺪﻭﺩﻳﺖ ﺍﺯ ﻧﻈﺮ ﺍﻳﻨﻜﻪ ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﺑﻪ ﻳﻚ ﻳﺎ ﺑﻴﺸﺘﺮ ﺍﺯ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﭘﺎﻳﻴﻦ ﺗﻌﻠﻖ ﺩﺍﺭﺩ ﺗﻌﺮﻳﻒ‬ ‫ﻣﻲ ﮔﺮﺩﺩ‪.‬ﺍﻳﻦ ﻧﻮﻉ ﻣﺤﺪﻭﺩﻳﺖ ﺑﻪ ﺩﻭ ﺷﻜﻞ ﻣﺠﺰﺍ )‪ (Disjoint‬ﻭ ﻫﻤﭙﻮﺷﺎﻧﻲ )‪(Overlapping‬ﻭﺟﻮﺩ ﺩﺍﺭﺩ‪.‬‬ ‫‪Disjoint‬‬ ‫ﺑﻪ ﻣﻌﻨﺎﻱ ﺍﻳﻦ ﺍﺳﺖ ﻛﻪ ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻲ ﺗﻮﺍﻧﺪ ﻓﻘﻂ ﺑﻪ ﻳﻚ ﻣﺠﻤﻮﻋﻪ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﭘﺎﻳﻴﻦ ﺗﻌﻠﻖ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪ .‬ﺩﺭ ﻧﻤﻮﺩﺍﺭ‬ ‫‪ E/R‬ﺑﺎ ﻧﻮﺷﺘﻦ ﻋﺒﺎﺭﺕ ‪ disjoint‬ﺩﺭ ﻛﻨﺎﺭ ﻣﺜﻠﺚ ‪ ISA‬ﺍﻳﻦ ﻗﻴﺪ ﺗﻌﺮﻳﻒ ﻣﻴﺸﻮﺩ‪.‬‬ ‫‪Overlapping‬‬ ‫ﺑﻪ ﻣﻌﻨﺎﻱ ﺍﻳﻦ ﺍﺳﺖ ﻛﻪ ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻲ ﺗﻮﺍﻧﺪ ﻓﻘﻂ ﺑﻪ ﻳﻚ ﻳﺎ ﺑﻴﺸﺘﺮ ﺍﺯﻣﺠﻤﻮﻋﻪ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﭘﺎﻳﻴﻦ ﺗﻌﻠﻖ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫ﻗـﻴﺪ ﺩﻳﮕﺮﻱ ﻛﻪ ﺩﺭ ﺗﻌﻤﻴﻢ ﻣﻄﺮﺡ ﺷﺪﻩ ‪ ،‬ﻗﻴﺪ ﻛﺎﻣﻞ ﺑﻮﺩﻥ ﺍﺳﺖ ﻛﻪ ﺑﻴﺎﻧﮕﺮ ﺍﻳﻦ ﺍﺳﺖ ﻛﻪ ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﺑﺎﻻﺗﺮ ﺑﺎﻳﺪ‬ ‫ﻣـﺘﻌﻠﻖ ﺑﻪ ﺣﺪﺍﻗﻞ ﻳﻜﻲ ﺍﺯ ﻣﺠﻤﻮﻋﻪ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎﻱ ﺳﻄﺢ ﭘﺎﻳﻴﻦ ﺗﺮ ﺑﺎﺷﺪ ﻳﺎ ﺧﻴﺮ ‪ .‬ﺑﺮ ﺍﻳﻦ ﺍﺳﺎﺱ ﺩﻭ ﻧﻮﻉ ﻗﻴﺪ ﻛﺎﻣﻞ ﻭ ﺟﺰﺋﻲ ﺭﺍ‬ ‫ﺩﺍﺭﻳﻢ ‪:‬‬ ‫‪ : total‬ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﺑﺎﻳﺪ ﻣﺘﻌﻠﻖ ﺑﻪ ﻳﻜﻲ ﺍﺯ ﻣﺠﻤﻮﻋﻪ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎﻱ ﺳﻄﺢ ﭘﺎﻳﻴﻨﺘﺮ ﺑﺎﺷﺪ‪.‬‬ ‫‪ :partial‬ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻲ ﺗﻮﺍﻧﺪ ﻣﺘﻌﻠﻖ ﺑﻪ ﻳﻜﻲ ﺍﺯ ﻣﺠﻤﻮﻋﻪ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎﻱ ﺳﻄﺢ ﭘﺎﻳﻴﻨﺘﺮ ﻧﺒﺎﺷﺪ‪.‬‬ ‫ﺣﺎﻟـﺖ ﭘـﻴﺶ ﻓﺮﺽ ﻣﺴﺎﻟﻪ ‪ ،‬ﺣﺎﻟﺖ ﺟﺰﺋﻲ ﺍﺳﺖ ‪ .‬ﺑﺮﺍﻱ ﺑﻴﺎﻥ ﻗﻴﺪ ﻛﺎﻣﻞ ﺑﻮﺩﻥ ﺑﺎﻳﺪ ﺍﺯ ﺩﻭ ﺧﻂ ﺍﺳﺘﻔﺎﺩﻩ ﮔﺮﺩﺩ)ﻫﻤﺎﻧﻨﺪ ﻣﺸﺎﺭﻛﺖ‬ ‫ﺍﻟﺰﺍﻣﻲ‪/‬ﻛﺎﻣﻞ ﺩﺭ ﻧﻤﻮﺩﺍﺭ ‪( E/R‬‬ ‫ﺗﻤﺮﻳﻦ ‪ ٥ :‬ﻣﺜﺎﻝ ﻣﺨﺘﻠﻒ ﺍﺯ ﺗﻌﻤﻴﻢ ﺫﻛﺮ ﻛﻨﻴﺪ ﻭ ﺩﺭ ﻫﺮ ﻛﺪﺍﻡ ﻗﻴﻮﺩ ﻣﺨﺘﻠﻒ ﺭﺍ ﺑﺮﺭﺳﻲ ﻧﻤﺎﻳﻴﺪ‪.‬‬ ‫‪ -٦-٢-٢‬ﺗﺠﻤﻊ‬

‫‪Aggregation‬‬

‫ﺗﺠﻤـﻊ ﻳﻌﻨﻲ ﺳﺎﺧﺘﻦ ﻳﻚ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﺟﺪﻳﺪ ﻭ ﻭﺍﺣﺪ ﺑﺮ ﺍﺳﺎﺱ ﺩﻭ ﻳﺎ ﺑﻴﺶ ﺍﺯ ﺩﻭ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ‪،‬ﻛﻪ ﺧﻮﺩ ﺑﺎﻫﻢ ﺍﺭﺗﺒﺎﻁ‬ ‫ﺩﺍﺭﻧـﺪ‪.‬ﺩﺭ ﻭﺍﻗﻊ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ ﻭ ﺍﺭﺗﺒﺎﻃﺎﺕ ﺭﺍ ﺑﺎ ﻫﻢ ﻣﺠﺘﻤﻊ ﻛﺮﺩﻩ ﻭ ﺑﻪ ﻋﻨﻮﺍﻥ ﻳﻚ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﻭﺍﺣﺪ ﺩﺭ ﻧﻈﺮ‬ ‫ﻣﻴﮕﻴـﺮﻧﺪ‪ .‬ﻭ ﺍﻳـﻦ ﻧـﻮﻉ ﻣﻮﺟـﻮﺩﻳﺖ ﺧـﻮﺩ ﻣـﻲ ﺗـﻮﺍﻧﺪ ﺑـﺎ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﺩﻳﮕﺮﻱ ﺍﺭﺗﺒﺎﻁ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ‪.‬ﺩﺭ ﻭﺍﻗﻊ ﺯﻣﺎﻧﻲ ﺍﺯ ﺗﺠﻤﻊ‬ ‫ﺍﺳﺘﻔﺎﺩﻩ ﻣﻴﺸﻮﺩ ﻛﻪ ﺑﺨﻮﺍﻫﻴﻢ ﺍﺭﺗﺒﺎﻃﻲ ﺭﺍ ﺑﻴﻦ ﺍﺭﺗﺒﺎﻁ ﻫﺎ ﺑﻴﺎﻥ ﻛﻨﻴﻢ ﻭ ﻳﺎ ﺑﺨﻮﺍﻫﻴﻢ ﺍﺭﺗﺒﺎﻃﺎﺕ ﺍﻓﺰﻭﻧﻪ ﺭﺍ ﻛﻢ ﻛﻨﻴﻢ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺍﺭﺗﺒﺎﻁ ﺑﻴﻦ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺘﻬﺎﻱ ﺩﺍﻧﺸﺠﻮ ‪ ،‬ﺩﺭﺱ ﻭ ﺍﺳﺘﺎﺩ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﻫﻤﺎﻧﻨﺪ ﺷﻜﻞ ﺯﻳﺮ ﻣﺪﻟﺴﺎﺯﻱ ﻧﻤﻮﺩ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﺩﺍﻧﺸﺠﻮ‬

‫ﮔﺮﻭﻩ ﺩﺭﺳﻲ‬

‫ﺍﻧﺘﺨﺎﺏ‬

‫ﺁﻣﻮﺯﺵ‬

‫ﺍﺳﺘﺎﺩ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٧ /‬‬

‫ﺩﺭﺱ‬

‫ﺗﺮﻡ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺜﺎﻝ ‪ :‬ﻧﻤﻮﺩﺍﺭ ‪ E/R‬ﻳﻚ ﺳﻴﺴﺘﻢ ﺑﺎﻧﻜﻲ ‪:‬‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٨ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٩ /‬‬

‫ﻣﺜﺎﻟﻲ ﺩﻳﮕﺮ ‪:‬‬ ‫ﻣﺤـﻴﻂ ﻋﻤﻠﻴﺎﺗـﻲ‪ :‬ﺳـﺎﺯﻣﺎﻥ ﻳـﺎ ﺷـﺮﻛﺘﻲ ﺭﺍ ﺩﺭ ﻧﻈـﺮ ﻣـﻲ ﮔﻴـﺮﻳﻢ ﻛﻪ ﭘﺮﻭﮊﻩ ﻫﺎﻳﻲ ﺭﺍ ﺩﺭ ﺩﺳﺖ ﺍﺟﺮﺍ ﺩﺍﺭﺩ‪.‬ﺩﺭ ﭘﺮﻭﮊﻩ ﻫﺎ ﺍﺯ‬ ‫ﻗﻄﻌﺎﺗـﻲ ﺩﺭ ﻛﺎﺭ ﺳﺎﺧﺖ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﺩ ﻭ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻧﻲ ﺍﻳﻦ ﻗﻄﻌﺎﺕ ﺭﺍ ﺗﺄﻣﻴﻦ ﻣﻲ ﻛﻨﻨﺪ‪ .‬ﻗﻄﻌﺎﺕ ﺩﺭ ﭘﺮﻭﮊﻩ ﻫﺎ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ‬ ‫ﺷـﻮﻧﺪ‪ .‬ﻫﺮ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ﺩﺭ ﻳﻚ ﺷﻬﺮ ﺩﻓﺘﺮ ﺩﺍﺭﺩ‪ .‬ﻫﺮ ﻗﻄﻌﻪ ﻣﻲ ﺗﻮﺍﻧﺪ ﺩﺭ ﺳﺎﺧﺖ ﻗﻄﻌﻪ ﺩﻳﮕﺮ ﻧﻴﺰ ﺑﻜﺎﺭ ﺭﻭﺩ‪ .‬ﻛﺎﺭﻣﻨﺪ ﻣﺪﻳﺮ ﭘﺮﻭﮊﻩ‬ ‫ﺍﺳﺖ ﻭ ﻳﺎ ﺩﺭ ﭘﺮﻭﮊﻩ ﻛﺎﺭ ﻣﻲ ﻛﻨﺪ‪.‬‬ ‫ﻳﻚ ﻧﻤﻮﺩﺍﺭ ﺳﺎﺩﻩ ‪ E/R‬ﻣﻲ ﺗﻮﺍﻧﺪ ﺑﻪ ﻓﺮﻡ ﺯﻳﺮ ﺑﺎﺷﺪ‪:‬‬

‫‪City‬‬

‫‪J Name‬‬

‫‪city‬‬

‫‪J#‬‬

‫ﭘﺮﻭﮊﻩ‬

‫‪SJ‬‬

‫‪J‬‬

‫‪S tatus‬‬

‫‪S#‬‬

‫‪S Name‬‬

‫ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ‬ ‫‪Supplier‬‬

‫‪Qty‬‬

‫‪MJ‬‬

‫‪SPJ‬‬

‫‪PJ‬‬

‫‪EJ‬‬

‫‪SP‬‬ ‫‪Qty‬‬

‫ﻗﻄﻌﻪ‬

‫)‪(P‬‬

‫‪Part‬‬

‫ﻛﺎﺭﻣﻨﺪ‬

‫‪weight‬‬

‫‪city‬‬

‫‪color‬‬

‫‪P#‬‬

‫‪PP‬‬ ‫‪E nane‬‬

‫‪E mp#‬‬

‫‪Dept#‬‬

‫‪Salary‬‬

‫‪P name‬‬

‫‪Qty‬‬

‫ﺍﺭﺗـﺒﺎﻁ ﻣﻤﻜـﻦ ﺍﺳـﺖ ﻣﺎﺑﻴﻦ ﺑﻴﺶ ﺍﺯ ﺩﻭ ﻣﻮﺟﻮﺩﻳﺖ ﺑﺎﺷﺪ)‪ . (SPJ‬ﺍﻃﻼﻋﺎﺗﻲ ﻛﻪ ﺍﺯ ﺍﻳﻦ ﺍﺭﺗﺒﺎﻁ ﺑﻴﻦ ﺳﻪ ﻣﻮﺟﻮﺩﻳﺖ ﺑﻪ‬ ‫ﺩﺳﺖ ﻣﻲ ﺁﻳﺪ ﻫﻤﻴﺸﻪ ﻟﺰﻭﻣﹰﺎ ﻫﻤﺎﻥ ﺍﻃﻼﻋﺎﺗﻲ ﻧﻴﺴﺖ ﻛﻪ ﺍﺯ ﺍﺭﺗﺒﺎﻁ ﺩﻭ ﺑﻪ ﺩﻭﻱ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎ ﺑﺪﺳﺖ ﻣﻲ ﺁﻳﺪ‪.‬‬ ‫ﻣﺜﺎﻝ‪:‬‬ ‫‪ – ١‬ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ‪ S1‬ﻗﻄﻌﻪ ‪ P1‬ﺭﺍ ﺗﻬﻴﻪ ﻣﻲ ﻛﻨﺪ‪.‬‬ ‫‪ – ٢‬ﻗﻄﻌﻪ ‪ P1‬ﺩﺭ ﭘﺮﻭﮊﻩ ‪ J1‬ﺑﻜﺎﺭ ﺭﻓﺘﻪ ﺍﺳﺖ‪.‬‬ ‫‪ – ٣‬ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ‪ S1‬ﺑﺮﺍﻱ ﭘﺮﻭﮊﻩ ‪ J1‬ﻗﻄﻌﻪ ﺗﻬﻴﻪ ﻛﺮﺩﻩ ﺍﺳﺖ‪.‬‬ ‫‪ – ٤‬ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ‪ S1‬ﻗﻄﻌﻪ ‪ P1‬ﺭﺍ ﺑﺮﺍﻱ ﺍﺳﺘﻔﺎﺩﻩ ﺩﺭ ﭘﺮﻭﮊﻩ ‪ J1‬ﺗﻬﻴﻪ ﻛﺮﺩﻩ ﺍﺳﺖ‪.‬‬ ‫ﻫﻤﻴﺸﻪ ﺍﺯ ﺍﻃﻼﻉ ‪ ١‬ﻭ ‪ ٢‬ﻭ ‪ ٣‬ﻧﻤﻲ ﺗﻮﺍﻥ ﺍﻃﻼﻉ ‪ ٤‬ﺭﺍ ﻧﺘﻴﺠﻪ ﮔﺮﻓﺖ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢٠ /‬‬

‫‪ -٣-٢‬ﺍﺻﻄﻼﺡ ﺩﺍﻡ ﭘﻴﻮﻧﺪﻱ )‪(Connection trap‬‬ ‫ﺍﮔـﺮ ﺍﺯ ﺍﺭﺗـﺒﺎﻁ ﺑﻴﻦ ﺩﻭ ﺑﻪ ﺩﻭﻱ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ ﻧﺘﻴﺠﻪ ﮔﺮﻓﺘﻪ ﺷﻮﺩ ﻛﻪ ﺣﺘﻤﹰﺎ ﺍﺭﺗﺒﺎﻁ ﺑﻴﻦ ﺳﻪ ﻣﻮﺟﻮﺩﻳﺖ ﻳﺎ ﺑﻴﺸﺘﺮ ﺍﺯ ﺁﻥ ﺑﺪﺳﺖ ﺁﻳﺪ‬ ‫ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﻃﺮﺍﺡ ﮔﺮﻓﺘﺎﺭ ﺩﺍﻡ ﭘﻴﻮﻧﺪﻱ ﺷﺪﻩ ﺍﺳﺖ‪.‬‬ ‫‪-٤-٢‬ﻃﺮﺍﺣﻲ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ‬ ‫ﻃﺮﺍﺣـﻲ ﻳـﻚ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻣﺴﺘﻠﺰﻣﻲ ﻣﺮﺍﺣﻠﻲ ﺍﺳﺖ ﻛﻪ ﺩﺭ ﻫﺮ ﻣﺮﺣﻠﻪ ﻓﻌﺎﻟﻴﺘﻬﺎﻳﻲ ﺍﻧﺠﺎﻡ ﻣﻴﺸﻮﺩ ‪ .‬ﺷﻜﻞ ﺯﻳﺮ ﻧﻤﻮﺩﺍﺭ ﺳﺎﺩﻩ ﺷﺪﻩ‬ ‫ﻣﺮﺍﺣﻞ ﻃﺮﺍﺣﻲ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﺭﺍ ﻧﺸﺎﻥ ﻣﻲ ﺩﻫﺪ‪.‬‬

‫‪-٤-٢‬ﻃﺮﺍﺣﻲ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﺍﺑﺰﺍﺭﻫﺎﻱ ‪Case‬‬

‫ﺑـﺮﺍﻱ ﻃﺮﺍﺣﻲ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﺍﺑﺰﺍﺭﻫﺎﻱ ﻣﺨﺘﻠﻔﻲ ﺍﺭﺍﺋﻪ ﺷﺪﻩ ﺍﻧﺪ ‪ .‬ﺍﻳﻦ ﺍﺑﺰﺍﺭﻫﺎ ﺑﻪ ﻃﺮﺍﺡ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻛﻤﻚ ﻣﻴﻜﻨﻨﺪ ﺗﺎ ﺩﺭﻣﺮﺍﺣﻞ‬ ‫ﻣﺨـﺘﻠﻒ ﻣﺪﻟﺴـﺎﺯﻱ ﻭ ﻃﺮﺍﺣـﻲ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ‪،‬ﺗﺼﻤﻴﻢ ﮔﻴﺮﻱ ﻣﻨﺎﺳﺐ ﺭﺍ ﺍﻧﺠﺎﻡ ﺩﻫﺪ‪.‬ﺍﻳﻦ ﺍﺑﺰﺍﺭﻫﺎ ﺍﻣﻜﺎﻥ ﺗﺮﺳﻴﻢ ﻧﻤﻮﺩﺍﺭ ‪ E/R‬ﺭﺍ ﺑﺎ‬ ‫ﺍﺳـﺘﻔﺎﺩﻩ ﺍﺯ ﺍﻧـﺘﺨﺎﺏ ﺍﺷـﻴﺎﺀ ﺍﺯ ﻳـﻚ ﺟﻌـﺒﻪ ﺍﺑـﺰﺍﺭﺭﺍ ﺑﻮﺟـﻮﺩ ﻣـﻲ ﺁﻭﺭﻧـﺪ‪.‬ﺑﻄﻮﺭ ﻛﻠﻲ ﻣﺰﺍﻳﺎﻱ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺍﻳﻦ ﺍﺑﺰﺍﺭﻫﺎ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ‬ ‫ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﻧﺎﻡ ﺑﺮﺩ ‪:‬‬ ‫‪ -١‬ﺳﺎﺩﮔﻲ ﻓﺮﺍﻳﻨﺪ ﺍﻳﺠﺎﺩ ﻧﻤﻮﺩﺍﺭﻫﺎ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢١ /‬‬

‫‪ -٢‬ﺗﻮﻟﻴﺪ ﺧﻮﺩﻛﺎﺭ ﺟﻤﻼﺕ ‪ SQL‬ﺑﺮﺍﻱ ﺗﻌﺮﻳﻒ ﺟﺪﻭﻟﻬﺎ ‪ ،‬ﻣﺤﺪﻭﺩﻳﺖ ﻫﺎ ‪ ،‬ﺍﻧﺪﻳﺲ ﻫﺎ ﻭ ﺩﻳﮕﺮ ﺍﺷﻴﺎﺀ ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ‪.‬‬ ‫‪ -٣‬ﺍﻣﻜﺎﻥ ﻣﺴﺘﻨﺪ ﺳﺎﺯﻱ ﻫﺮ ﻣﻮﺟﻮﺩﻳﺖ ‪ ،‬ﺻﻔﺖ ﺧﺎﺻﻪ ‪ ،‬ﺭﺍﺑﻄﻪ ﻭ ﻣﺤﺪﻭﺩﻳﺖ‪.‬‬ ‫‪-٤‬‬ ‫ﺑﺮﺧﻲ ﺍﺑﺰﺍﺭ ﻫﺎ ﻳﻲ ﻛﻪ ﺩﺭ ﺣﺎﻝ ﺣﺎﺿﺮ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﻧﺪ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ‪::‬‬ ‫‪ ER STUDIO -١‬ﺑﺮﺍﻱ ﻣﺪﻟﺴﺎﺯﻱ ‪ E/R‬ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ‬ ‫‪ DB Atrisan -٢‬ﺑﺮﺍﻱ ﻣﺪﻳﺮﻳﺖ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﺍﻣﻨﻴﺖ ﺁﻥ‬ ‫‪ Oracle Developer 2000 & Designer 2000 -٣‬ﺑﺮﺍﻱ ﻣﺪﻟﺴﺎﺯﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻭ ﺗﻮﺳﻌﻪ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ‬ ‫‪ Platinum Enterprise Modeling suite : ER Win , BpWin -٤‬ﺑﺮﺍﻱ ﻣﺪﻟﺴﺎﺯﻱ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﭘﺮﺩﺍﺯﺵ ﻫﺎ‬ ‫‪ RW Metro -٥‬ﺑﺮﺍﻱ ﺗﺒﺪﻳﻞ ﺍﺯ ‪ O-O‬ﺑﻪ ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ‪.‬‬ ‫‪ Rational Rose -٦‬ﺑﺮﺍﻱ ﻣﺪﻟﺴﺎﺯﻱ ‪ UML‬ﻭ ﺗﻮﻟﻴﺪ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﺑﻪ ﺯﺑﺎﻥ ﺟﺎﻭﺍ ﻭ ‪.C++‬‬ ‫‪ Visio Enterprise Visual Basic -٧‬ﺑﺮﺍﻱ ﻣﺪﻟﺴﺎﺯﻱ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﻃﺮﺍﺣﻲ ﻡ ﻣﻬﻨﺪﺳﻲ ﻣﺠﺪﺩ‪.‬‬ ‫‪ X Case -٨‬ﺑﺮﺍﻱ ﻣﺪﻟﺴﺎﺯﻱ ﻣﻔﻬﻮﻣﻲ ‪.‬‬ ‫‪ Case Studio -٩‬ﺑﺮﺍﻱ ﻣﺪﻟﺴﺎﺯﻱ ‪ E/R‬ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ‪.‬‬ ‫ﺗﻤﺮﻳﻦ‪ :‬ﻧﻤﻮﺩﺍﺭ ‪ E/R‬ﻫﺮ ﻳﻚ ﺍﺯ ﻣﺤﻴﻄﻬﺎﻱ ﻋﻤﻠﻴﺎﺗﻲ ﺯﻳﺮ ﺭﺍ ﺭﺳﻢ ﻛﻨﻴﺪ‪:‬‬ ‫‪-‬‬

‫ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﻳﻚ ﻧﻤﺎﻳﺸﮕﺎﻩ ﺑﻴﻦ ﺍﻟﻤﻠﻠﻲ‬

‫‪-‬‬

‫ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﮔﻴﺎﻫﺎﻥ‬

‫‪-‬‬

‫ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﺷﺨﺼﻲ )‪( P I S‬‬

‫‪-‬‬

‫ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﺁﺯﻣﺎﻳﺸﮕﺎﻩ ﻃﺒﻲ‬

‫‪-‬‬

‫ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﺗﻌﻤﻴﺮ ﻭ ﻧﮕﻬﺪﺍﺭﻱ ﻛﺎﻣﭙﻴﻮﺗﺮ ﻫﺎ‬

‫‪-‬‬

‫ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﺩﺍﺭﻭﺧﺎﻧﻪ ﻳﻚ ﺑﻴﻤﺎﺭﺳﺘﺎﻥ‬

‫‪-‬‬

‫ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﻓﻌﺎﻟﻴﺘﻬﺎﻱ ﻛﻠﻮﭖ ﻓﻴﻠﻢ‬

‫ ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﻣﺴﺎﺑﻘﺎﺕ ﻋﻠﻤﻲ‬‫‪-‬‬

‫ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﻳﻚ ﺑﺎﻧﻚ‬

‫‪-‬‬

‫ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﻣﻮﺳﻴﻘﻲ ﻭ ﻣﻮﺳﻴﻘﻲ ﺩﺍﻧﺎﻥ‬

‫‪-‬‬

‫ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﻧﻘﺎﺷﻲ ﻭ ﻧﻘﺎﺷﺎﻥ‬

‫‪ -‬ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ﻳﻚ ﻣﺮﻛﺰ ﺗﺤﻘﻴﻘﺎﺗﻲ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢٢ /‬‬

‫ﺧﻼﺻﻪ ﺷﻜﻠﻬﺎﻱ ﺑﻜﺎﺭﺭﻓﺘﻪ ﺩﺭ ﻧﻤﻮﺩﺍﺭ ‪E/R‬‬

‫ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ‬

‫ﺻﻔﺖ ﺧﺎﺻﻪ‬

‫‪E‬‬

‫ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﺿﻌﻴﻒ‬

‫‪A‬‬ ‫‪A‬‬

‫ﺻﻔﺖ ﺧﺎﺻﻪ ﭼﻨﺪ ﻣﻘﺪﺍﺭﻱ‬

‫‪E‬‬

‫‪A‬‬ ‫‪R‬‬

‫ﻧﻮﻉ ﺭﺍﺑﻄﻪ‬

‫ﺭﺍﺑﻄﻪ ﺑﻴﻦ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ ﻭ ﻣﻮﺟﻮﺩﻳﺖ ﺿﻌﻴﻒ‬ ‫ﻛﻠﻴﺪ ﺍﺻﻠﻲ‬

‫ﺭﺍﺑﻄﻪ ﭼﻨﺪ ﺑﻪ ﭼﻨﺪ‬ ‫ﺭﺍﺑﻄﻪ ﻳﻚ ﺑﻪ ﻳﻚ‬

‫ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﺸﺘﻖ‬ ‫ﺷﺮﻛﺖ ﻛﺎﻣﻞ )ﺍﻟﺰﺍﻣﻲ(ﻣﻮﺟﻮﺩﻳﺖ ﺩﺭ ﺭﺍﺑﻄﻪ‬

‫‪R‬‬

‫‪R‬‬

‫‪E2‬‬

‫‪A‬‬

‫*‬

‫‪R‬‬

‫‪R‬‬

‫‪١‬‬

‫‪R‬‬

‫‪E1‬‬

‫‪R‬‬ ‫*‬

‫ﺭﺍﺑﻄﻪ ﻳﻚ ﺑﻪ ﭼﻨﺪ‬

‫*‬

‫‪١‬‬ ‫‪١‬‬

‫‪R‬‬

‫‪R‬‬ ‫ﻣﺤﺪﻭﺩﻳﺘﻬﺎﻱ ‪Cardinality‬‬

‫‪E‬‬

‫‪R‬‬

‫‪ISA‬‬

‫)‪(Specialization or Generalization‬‬

‫‪E2 IS-A E1‬‬

‫‪E1‬‬ ‫‪E2‬‬ ‫‪E2‬‬

‫‪ISA‬‬

‫‪E1‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢٣ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢٤ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬ ‫‪ -٥-٢‬ﭼﻨﺪ ﻣﺜﺎﻝ ﺍﺯ ﻧﻤﻮﺩﺍﺭ ‪E/R‬‬

‫ﻣﺜﺎﻟﻲ ﺍﺯ ﻳﻚ ﺳﻴﺴﺘﻢ ﻛﺎﺭﻣﻨﺪ ‪ -‬ﭘﺮﻭﮊﻩ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢٥ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻧﻤﻮﺩﺍﺭ ‪ E/R‬ﻳﻚ ﺳﻴﺴﺘﻢ ﺑﺎﻧﻜﻲ‪:‬‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢٦ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫‹ﻣﺜﺎﻟﻲ ﺍﺯ ﺗﺨﺼﻴﺺ ﻭ ﺗﻌﻤﻴﻢ‪:‬‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢٧ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢٨ /‬‬

‫ﺗﻤﺮﻳﻨﺎﺕ ﻓﺼﻞ ﺩﻭﻡ‪:‬‬ ‫‪ -١‬ﺩﺭ ﻣـﺪﻝ ﺳـﺎﺯﻱ ﺩﺍﺩﻩ ﻫـﺎ ﺑـﺎ ﺭﻭﺵ ‪ E/R‬ﮔـﺎﻩ ﻣﺸـﻜﻼﺗﻲ ﺑـﺮﻭﺯ ﻣﻲ ﻧﻤﺎﻳﺪ ﻛﻪ ﺍﺯ ﺟﻤﻠﻪ ﺁﻧﻬﺎﺗﻠﻪ‬ ‫ﺍﺭﺗﺒﺎﻃﻲ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﻧﺎﻡ ﺑﺮﺩ‪.‬ﺩﻭ ﺣﺎﻟﺖ ﺭﺍﻳﺞ ﺗﺮ ﺍﻳﻦ ﺗﻠﻪ ﺍﺭﺗﺒﺎﻃﻲ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ ‪:‬ﺗﻠﻪ ﻳﻚ ﭼﻨﺪﻱ ﻭ‬ ‫ﺗﻠﻪ ﺷﻜﺎﻑ ‪ ،‬ﺑﺎ ﺫﻛﺮ ﻣﺜﺎﻟﻲ ﺍﻳﻦ ﺩﻭ ﺣﺎﻟﺖ ﺭﺍ ﺗﻮﺿﻴﺢ ﺩﻫﻴﺪ‪.‬‬

‫‪٣‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٢٩ /‬‬

‫ﻓﺼﻞ ﺳﻮﻡ ‪:‬‬ ‫ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ‬ ‫‪ -١-٣‬ﺗﻌﺮﻳﻒ ﺭﺍﺑﻄﻪ ‪:‬‬ ‫ﺭﺍﺑﻄﻪ ﺍﺯ ﺩﻭ ﻣﺠﻤﻮﻋﻪ ﺗﺸﻜﻴﻞ ﺷﺪﻩ ﺍﺳﺖ ‪ :‬ﻳﻜﻲ ﻣﻮﺳﻮﻡ ﺑﻪ ﻣﺠﻤﻮﻋﻪ ﻋﻨﻮﺍﻥ ﻳﺎ ‪ h eading‬ﺭﺍﺑﻄﻪ ﻭ ﺩﻳﮕﺮﻱ ﻣﺠﻤﻮﻋﻪ‬ ‫ﺑﺪﻧـﻪ ﻳـﺎ ‪ . body‬ﻋﻨﻮﺍﻥ‪ ،‬ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺛﺎﺑﺖ ﺍﺯ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ‪ An ........A1‬ﺍﺳﺖ ﻛﻪ ﺍﻳﻦ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻫﺮ ﻳﻚ ﻣﻘﺎﺩﻳﺮﺷﺎﻥ‬ ‫ﺭﺍ ﺍﺯ ﻳـﻚ ﻣـﻴﺪﺍﻥ ) ﺣـﻮﺯﻩ( ﻣﻲ ﮔﻴﺮﻧﺪ‪ .‬ﻣﺠﻤﻮﻋﻪ ﺑﺪﻧﻪ ﻣﺠﻤﻮﻋﻪ ﺍﻳﺴﺖ ﻣﺘﻐﻴﺮ ﺩﺭ ﺯﻣﺎﻥ ﺍﺯ ﭼﻨﺪ ﺗﺎﻳﻲ ﻣﻘﺎﺩﻳﺮ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺑﻨﺎﻡ‬ ‫ﻻ ﺩﺭ ﻣـﺪﻝ ﺭﺍﺑﻄـﻪ ﺍﻱ ﺍﺯ ﺍﺻـﻼﺡ ﺟـﺪﻭﻝ ﺑﺠﺎﻱ ﺭﺍﺑﻄﻪ ﻧﻴﺰﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﺩ‪ .‬ﻳﻌﻨﻲ ﺟﺪﻭﻝ ﺍﻣﻜﺎﻧﻲ ﺍﺳﺖ‬ ‫ﺗﺎﭘـﻞ) ‪ .( tuple‬ﻣﻌﻤـﻮ ﹰ‬ ‫ﺑـﺮﺍﻱ ﻧﻤـﺎﻳﺶ ﻣﻔﻬـﻮﻡ ﺭﺍﺑﻄﻪ ﺑﺨﺎﻃﺮ ﺗﺎﻣﻴﻦ ﻭ ﻭﺿﻮﺡ ﻛﺎﺭﺑﺮﺩﻱ‪ .‬ﻣﻌﻤﻮﻻ ﺭﺍﺑﻄﻪ ﺭﺍ ﺑﺼﻮﺭﺕ ) ‪ r ( R‬ﻧﻤﺎﻳﺶ ﻣﻴﺪﻫﻨﺪ ﻛﻪ ﺑﻪ ‪R‬‬ ‫ﺷﻤﺎﻱ ﺭﺍﺑﻄﻪ ﻧﻴﺰ ﮔﻔﺘﻪ ﻣﻴﺸﻮﺩ‪R = ( A1,A2,A3,…) .‬‬ ‫‪CITY‬‬

‫‪-١-١-٣‬ﺗﻌﺮﻳﻒ ﺩﺍﻣﻨﻪ ‪ /‬ﻣﻴﺪﺍﻥ ‪:‬‬

‫‪STAT‬‬

‫‪SNAME‬‬

‫ﻣﺠﻤﻮﻋﻪ ﺍﻳﺴﺖ ﻛﻪ ﻣﻘﺎﺩﻳﺮﻳﻚ ﺻﻔﺖ ﺧﺎﺻﻪ ﺍﺯ ﺁﻥ ﺑﺮﮔﺮﻓﺘﻪ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬ ‫ﻣﺜﺎﻝ‪ :‬ﻣﻮﺟﻮﺩﻳﺖ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﻣﻲ ﮔﻴﺮﻳﻢ‪:‬‬ ‫ﻣﺠﻤﻮﻋﻪ ﻋﻨﻮﺍﻥ‬

‫ﻣﺠﻤﻮﻋﻪ ﺑﺪﻧﻪ‬

‫‪S#‬‬

‫‪City‬‬

‫‪Status‬‬

‫‪SNAME‬‬

‫‪S#‬‬

‫ﺗﻬﺮﺍﻥ‬

‫‪٢٠‬‬

‫ﻧﺎﻡ‪١‬‬

‫‪١٠٠‬‬

‫ﻗﺰﻭﻳﻦ‬

‫‪٣٠‬‬

‫ﻧﺎﻡ‪٢‬‬

‫‪٢٠٠‬‬

‫ﻛﺮﺝ‬

‫‪٥٠‬‬

‫ﻧﺎﻡ ‪٣‬‬

‫‪٣٠٠‬‬

‫ﺗﺒﺮﻳﺰ‬

‫‪١٥‬‬

‫ﻧﺎﻡ‪٤‬‬

‫‪٢٥٠‬‬

‫ﺍﺭﺗﺒﺎﻁ ﺑﻴﻦ ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ ﻭ ﻧﻤﺎﻳﺶ ﺟﺪﻭﻟﻲ‪:‬‬ ‫ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ)ﺗﺌﻮﺭﻳﺴﻴﻦ(‬

‫ﺳﺎﺧﺘﺎﺭ ﺟﺪﻭﻟﻲ)ﻃﺮﺍﺡ(‬

‫ﺭﺍﺑﻄﻪ‬

‫ﺟﺪﻭﻝ‬

‫ﺗﺎﭘﻞ‬

‫ﺳﻄﺮ‬

‫ﺻﻔﺖ ﺧﺎﺻﻪ‬

‫ﺳﺘﻮﻥ‬

‫ﻣﻴﺪﺍﻥ‬

‫ﻣﻘﺎﺩﻳﺮ ﻣﺠﺎﺯ ﻳﻚ ﺳﺘﻮﻥ‬

‫ﻭﻗﺘـﻴﻜﻪ ﺍﺳﻢ ﻭ ﻣﺠﻤﻮﻋﻪ ﻋﻨﻮﺍﻥ ﺭﺍﺑﻄﻪ ﻣﺸﺨﺺ ﺑﺎﺷﺪ ﮔﻮﻳﻨﺪ ﺫﺍﺕ ﻳﺎ ﺟﻮﻫﺮ ﺭﺍﺑﻄﻪ ) ‪ ( I ntension‬ﻣﻌﻠﻮﻡ ﺍﺳﺖ‪ .‬ﺑﻪ ﺑﺪﻧﻪ ﺭﺍﺑﻄﻪ‬ ‫ﺑﺴﻂ ﺭﺍﺑﻄﻪ )‪ (Extension‬ﻧﻴﺰ ﮔﻮﻳﻨﺪ‪.‬‬ ‫ﻧﻜﺘﻪ‪ :‬ﺫﺍﺕ ﺭﺍﺑﻄﻪ ﺛﺎﺑﺖ ﺩﺭ ﺯﻣﺎﻥ ﺍﺳﺖ ﺍﻣﺎ ﺑﺴﻂ ﺭﺍﺑﻄﻪ ﺩﺭ ﺯﻣﺎﻥ ﻣﺘﻐﻴﺮ ﺍﺳﺖ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣٠ /‬‬

‫‪-٢-١-٣‬ﺩﺭﺟﻪ ﺭﺍﺑﻄﻪ‪:‬‬ ‫ﺗﻌـﺪﺍﺩ ﺻـﻔﺎﺕ ﺧﺎﺻـﻪ ﺭﺍﺑﻄـﻪ ﺭﺍ ﺩﺭﺟـﻪ ﺁﻥ ﮔﻮﻳـﻨﺪ‪ .‬ﺍﮔﺮ ﺩﺭﺟﻪ ﺭﺍﺑﻄﻪ ﻳﻚ ﺑﺎﺷﺪ ﺭﺍﺑﻄﻪ ﻳﮕﺎﻧﻲ ‪ ،‬ﺭﺍﺑﻄﻪ ﺩﺭﺟﻪ ﺩﻭ ﺭﺍ ﺩﻭﮔﺎﻧﻲ‬ ‫)‪ ، (binary‬ﺭﺍﺑﻄﻪ ﺩﺭﺟﻪ ﺳﻪ ﺭﺍ ﺳﻪ ﮔﺎﻧﻲ )‪ (Ternary‬ﻭ ﺭﺍﺑﻄﻪ ﺑﺎ ﺩﺭﺟﻪ ‪ N‬ﺭﺍ ‪N‬ﮔﺎﻧﻲ )‪(N-ray‬ﮔﻮﻳﻨﺪ‪.‬‬ ‫‪-٣-١-٣‬ﻛﺎﺭﺩﻳﻨﺎﻟﻴﺘﻲ ﺭﺍﺑﻄﻪ‪:‬‬ ‫ﺑـﻪ ﺗﻌـﺪﺍﺩ ﺗﺎﭘﻠﻬﺎﻱ ﺭﺍﺑﻄﻪ ﺩﺭ ﻳﻚ ﻟﺤﻈﻪ ﺍﺯ ﺣﻴﺎﺕ ﺁﻥ ﻛﺎﺭﺩﻳﻨﺎﻟﻴﺘﻲ ﺭﺍﺑﻄﻪ ﮔﻮﻳﻨﺪ‪ .‬ﻛﺎﺭﺩﻳﻨﺎﻟﻴﺘﻲ ﺭﺍﺑﻄﻪ ﺩﺭ ﻃﻮﻝ ﺣﻴﺎﺕ ﺭﺍﺑﻄﻪ‬ ‫ﻣﺘﻐﻴﺮ ﺍﺳﺖ‪ .‬ﺑﻌﻨﻮﺍﻥ ﻣﺜﺎﻝ‪ ،‬ﺭﺍﺑﻄﻪ ﺍﺯ ﺩﺭﺟﻪ ﺭﺍﺑﻄﻪ ‪ ٤‬ﻣﻴﺒﺎﺷﺪ‪.‬‬ ‫‪ -٤-١-٣‬ﺧﺼﻮﺻﻴﺎﺕ ﺭﺍﺑﻄﻪ‪:‬‬ ‫‪ _١‬ﺑﻪ ﻛﻤﻚ ﻳﻚ ﺳﺎﺧﺘﺎﺭ ﺳﺎﺩﻩ ﺑﻨﺎﻡ ﺟﺪﻭﻝ ﻗﺎﺑﻞ ﻧﻤﺎﻳﺶ ﺍﺳﺖ‪.‬‬ ‫‪ _٢‬ﺗﺎﭘـﻞ ﺗﻜـﺮﺍﺭﻱ ﺩﺭ ﺭﺍﺑﻄـﻪ ﻭﺟـﻮﺩ ﻧـﺪﺍﺭﺩ‪ .‬ﺯﻳـﺮﺍ ﺑﺪﻧـﻪ ﺭﺍﺑﻄﻪ ﻣﺠﻤﻮﻋﻪ ﺍﺳﺖ ﻭ ﺩﺭ ﻣﺠﻤﻮﻋﻪ ﻋﻨﺎﺻﺮ ﺗﻜﺮﺍﺭﻱ ﻭﺟﻮﺩ‬ ‫ﻧﺪﺍﺭﺩ‪.‬‬ ‫‪ _٣‬ﺗﺎﭘﻠﻬﺎﺩﺭ ﺭﺍﺑﻄﻪ ﻧﻈﻢ ﺧﺎﺻﻲ ﻧﺪﺍﺭﻧﺪ‪.‬ﺍﻳﻦ ﺧﺎﺻﻴﺖ ﻧﻴﺰ ﺍﺯ ﻣﺠﻤﻮﻋﻪ ﺑﻮﺩﻥ ﺑﺪﻧﻪ ﺭﺍﺑﻄﻪ ﻧﺘﻴﺠﻪ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪ _٤‬ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻧﻈﻢ ﻧﺪﺍﺭﻧﺪ‪ .‬ﺍﻳﻦ ﺧﺎﺻﻴﺖ ﻧﻴﺰ ﺍﺯ ﻣﺠﻤﻮﻋﻪ ﺑﻮﺩﻥ ﻋﻨﻮﺍﻥ ﺭﺍﺑﻄﻪ ﻧﺘﻴﺠﻪ ﻣﻲ ﺷﻮﺩ‬ ‫‪ _٥‬ﻋﻨﺎﺻـﺮ ﺗﺸﻜﻴﻞ ﺩﻫﻨﺪﻩ ﺗﺎﭘﻞ ﺍﺗﻤﻴﻚ ﻫﺴﺘﻨﺪ ﻳﻌﻨﻲ ﺗﺠﺰﻳﻪ ﻧﺸﺪﻧﻲ ﻣﻲ ﺑﺎﺷﻨﺪ‪ .‬ﺑﻌﺒﺎﺭﺗﻲ ﮔﻮﺋﻴﻢ ﻳﻚ ﻓﻘﺮﻩ ﺩﺍﺩﻩ ﺗﺠﺰﻳﻪ‬ ‫ﻧﺸـﺪﻧﻲ ﺍﺳـﺖ ﺍﮔـﺮ ﻧـﺘﻮﺍﻥ ﺁﻥ ﺭﺍ ﺑﻪ ﻣﻘﺎﺩﻳﺮ ﺩﻳﮕﺮ ﺗﺠﺰﻳﻪ ﻛﺮﺩ‪.‬ﺑﻌﻨﻮﺍﻥ ﻣﺜﺎﻝ‪ :‬ﻣﻘﺎﺩﻳﺮ ﺗﺎﺭﻳﺦ ﻣﺎﻫﻴﺘﻲ ﻏﻴﺮ ﺍﺗﻤﻴﻚ ﺩﺍﺭﺩ ﺯﻳﺮﺍ ﺍﺯ ﺳﻪ‬ ‫ﺟـﺰﺀ ﻣـﺎﻩ ‪ ،‬ﺳـﺎﻝ ﻭ ﺭﻭﺯ ﺗﺸﻜﻴﻞ ﺷﺪﻩ ﺍﺳﺖ ‪.‬ﺩﺭ ﺍﻳﻦ ﻣﺜﺎﻝ ﺧﺎﺹ ﺍﺗﻤﻴﻚ ﻭ ﻳﺎ ﻏﻴﺮ ﺍﺗﻤﻴﻚ ﺑﻮﺩﻥ ﺗﺎﺭﻳﺦ ﺑﺴﺘﮕﻲ ﺑﻪ ﺩﻳﺪ ﻃﺮﺍﺡ‬ ‫ﺩﺭ ﻃﺮﺍﺣﻲ ﺩﺍﺭﺩ ﺑﻨﺎﺑﺮﺍﻳﻦ ﺍﻳﻦ ﺩﻭ ﻣﻔﻬﻮﻡ ﻣﻄﻠﻖ ﻧﻴﺴﺘﻨﺪ ﻭ ﺑﻪ ﻣﻌﻨﺎﻳﻲ ﻛﻪ ﻃﺮﺍﺡ ﺑﺮﺍﻱ ﺩﺍﺩﻩ ﻫﺎ ﻗﺎﺋﻞ ﻣﻲ ﺷﻮﺩ ﺑﺴﺘﮕﻲ ﺩﺍﺭﺩ‪.‬‬ ‫‪ -٢-٣‬ﻣﻔﻬﻮﻡ ﻣﻴﺪﺍﻥ ﻭ ﻧﻘﺶ ﺁﻥ ﺩﺭ ﻋﻤﻠﻴﺎﺕ ﺭﻭﻱ ﺑﺎﻧﻚ‪:‬‬ ‫ﻣﻴﺪﺍﻥ ‪ :‬ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﻣﻘﺎﺩﻳﺮ ﺍﺳﺖ ﻛﻪ ﻳﻚ ﻳﺎ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﺻﻔﺖ ﺧﺎﺻﻪ ﺍﺯ ﺁﻥ ﻣﻘﺪﺍﺭ ﻣﻲ ﮔﻴﺮﻧﺪ‪ .‬ﻣﻴﺪﺍﻥ ﺩﺭ ﻋﻤﻠﻴﺎﺕ ﺭﻭﻱ‬ ‫ﺑﺎﻧﻚ ﻣﺰﺍﻳﺎﻳﻲ ﺩﺍﺭﺩ ﻛﻪ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ‪:‬‬ ‫‪ -١-٢-٣‬ﺳﺒﺐ ﺳﺎﺩﻩ ﺗﺮ ﺷﺪﻥ ﻭ ﻛﻮﺗﺎﻫﺘﺮ ﺷﺪﻥ ﺷﻤﺎﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻣﻴﮕﺮﺩﺩ‪ ).‬ﺍﺯ ﻧﻈﺮ ﺗﻌﺪﺍﺩ ﺍﺣﻜﺎﻡ ( ‪ .‬ﺯﻳﺮﺍ ﻻﺯﻡ ﻧﻴﺴﺖ ﻛﻪ ﺩﺭ‬ ‫ﺗﻤﺎﻡ ﺭﺍﺑﻄﻪ ﻫﺎ ‪ ،‬ﻫﺮﺑﺎﺭ ﻣﺸﺨﺼﺎﺕ ﺻﻔﺎﺕ ﺭﺍ ﺑﺪﻫﻴﻢ‪٠.‬‬ ‫‪ _٢-٢-٣‬ﻛﻨﺘﺮﻝ ﻣﻘﺪﺍﺭﻱ ﻋﻤﻠﻴﺎﺕ ﺩﺭ ﭘﺎﻳﮕﺎﻩ‪.‬‬ ‫ﻣﻘﺎﺩﻳـﺮ ﻳـﻚ ﺻـﻔﺖ ﺧﺎﺻﻪ ﺩﺭ ﻃﻮﻝ ﺣﻴﺎﺕ ﺭﺍﺑﻄﻪ‪ ،‬ﺍﺯ ﻣﻘﺎﺩﻳﺮ ﻣﻴﺪﺍﻥ ﺑﺮﮔﺮﻓﺘﻪ ﻣﻲ ﺷﻮﻧﺪ‪ .‬ﺑﻌﺒﺎﺭﺕ ﺩﻳﮕﺮ ﺑﺎﻳﺪ ﺩﺭ ﻣﻴﺪﺍﻥ ﻭﺟﻮﺩ‬ ‫ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ‪ .‬ﺑﻨﺎﺑﺮﺍﻳﻦ ﺑﻪ ﻛﻤﻚ ﻣﻔﻬﻮﻡ ﻣﻴﺪﺍﻥ ﻣﻲ ﺗﻮﺍﻥ ﻋﻤﻠﻴﺎﺕ ﺭﻭﻱ ﺑﺎﻧﻚ ﺭﺍ ﺍﺯ ﻧﻈﺮ ﻣﻘﺎﺩﻳﺮ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻛﻨﺘﺮﻝ ﻛﺮﺩ‪.‬‬ ‫ﺑﻄـﻮﺭ ﻣـﺜﺎﻝ ﺍﮔـﺮ ﻣﻴﺪﺍﻥ ﻣﻘﺎﺩﻳﺮ ‪ STAUS‬ﺑﺼﻮﺭﺕ } ‪ Domain STATUS = {10,20,30,40,50‬ﺑﺎﺷﺪ ﺍﻣﻜﺎﻥ ﺩﺭﺝ ﺍﻃﻼﻉ‬ ‫) ﺗﻬﺮﺍﻥ ﻭ ‪ ( S7, Sn7, 60‬ﺩﺭ ﺑﺎﻧﻚ ﻣﻴﺴﺮ ﻧﻤﻲ ﺑﺎﺷﺪ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣١ /‬‬

‫‪ -٣-٢-٣‬ﺍﻣﻜﺎﻧﻲ ﺍﺳﺖ ﺑﺮﺍﻱ ﻛﻨﺘﺮﻝ ﻣﻌﻨﺎﻳﻲ ﭘﺮﺱ ﻭ ﺟﻮﻫﺎ‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺷﻤﺎﺭﻩ ﻗﻄﻌﺎﺗﻲ ﺭﺍ ﺑﺪﻫﻴﺪ ﻛﻪ ﻭﺯﻥ ﺁﻧﻬﺎ ﺑﺮﺍﺑﺮ ﺗﻌﺪﺍﺩ ﺗﻬﻴﻪ ﺷﺪﻩ ﺁﻧﻬﺎ ﺑﺎﺷﺪ‪.‬‬ ‫ﺻـﻔﺎﺕ ﻭﺯﻥ ﻭ ﺗﻌﺪﺍﺩ ﺑﻪ ﺍﻋﺘﺒﺎﺭ ﻫﻤﻨﻮﻉ ﺑﻮﺩﻥ ﻗﺎﺑﻞ ﻣﻘﺎﻳﺴﻪ ﺍﻧﺪ ﻭ ﺳﻴﺴﺘﻢ ﻣﻲ ﺗﻮﺍﻧﺪ ﺑﺎ ﺍﻧﺠﺎﻡ ﻣﻘﺎﻳﺴﻪ ﻫﺎﻱ ﻻﺯﻡ ‪ ،‬ﺑﻪ ﭘﺮﺳﺶ ﻛﺎﺭﺑﺮ‬ ‫ﭘﺎﺳﺦ ﺩﻫﺪ‪ .‬ﺍﻣﺎ ﺍﻳﻦ ﺩﻭ ﺻﻔﺖ ﺑﻪ ﻟﺤﺎﻅ ﻣﻔﻬﻮﻣﻲ ﻏﻴﺮ ﻗﺎﺑﻞ ﻣﻘﺎﻳﺴﻪ ﺍﻧﺪ‪ ،‬ﺯﻳﺮﺍ ﺭﻭﻱ ﺩﻭ ﻣﻴﺪﺍﻥ ﻣﺎﻫﻴﺘﹰﺎ ﻣﺘﻔﺎﻭﺕ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺍﻧﺪ‪.‬‬ ‫‪_٤-٢-٣‬ﭘﺎﺳﺨﮕﻮﻳﻲ ﺑﻪ ﺑﻌﻀﻲ ﺍﺯ ﭘﺮﺱ ﻭ ﺟﻮﻫﺎ ﺭﺍ ﺁﺳﺎﻥ ﻣﻴﻜﻨﺪ‪.‬‬ ‫ﺍﮔﺮ ﺍﻣﻜﺎﻥ ﺗﻌﺮﻳﻒ ﻣﻴﺪﺍﻥ ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ﺍﻳﻦ ﺗﻌﺮﻳﻒ ﻭﺍﺭﺩ ﻛﺎﺗﺎﻟﻮﮒ ﺳﻴﺴﺘﻢ ﺑﻌﻨﻮﺍﻥ ﺑﺨﺸﻲ ﺍﺯ ﺷﻤﺎﻱ ﺍﺩﺭﺍﻛﻲ ﭘﺎﻳﮕﺎﻩ ﻣﻲ‬ ‫ﺷﻮﺩ ﻭ ﺩﺭ ﺷﺮﺍﻳﻄﻲ ﺑﺮﺧﻲ ﺍﺯ ﻛﺎﺭﺑﺮﺍﻥ ﻣﻲ ﺗﻮﺍﻧﻨﺪ ﺍﺯ ﺁﻥ ﺍﺳﺘﻔﺎﺩﻩ ﻛﻨﻨﺪ‪.‬‬ ‫ﻣﺜﺎﻝ‪ :‬ﺩﺭﭼﻪ ﺭﺍﺑﻄﻪ ﻫﺎﻳﻲ ﺍﺯ ﭘﺎﻳﮕﺎﻩ ﺍﻃﻼﻋﺎﺗﻲ ﺍﺯ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﻭﺟﻮﺩ ﺩﺍﺭﺩ؟‬ ‫ﺍﮔﺮ ﻣﻴﺪﺍﻥ ﻫﺎ ﺗﻌﺮﻳﻒ ﺷﻮﻧﺪ ﺑﺮﺍﻱ ﭘﺎﺳﺨﮕﻮﻳﻲ ﺑﻪ ﺍﻳﻦ ﭘﺮﺱ ﻭ ﺟﻮ ﻓﻘﻂ ﻣﺮﺍﺟﻌﻪ ﺑﻪ ﻛﺎﺗﺎﻟﻮﮒ ﻛﻔﺎﻳﺖ ﻣﻲ ﻛﻨﺪ ‪.‬‬ ‫‪ -٣-٣‬ﻣﻔﻬﻮﻡ ﻛﻠﻴﺪ ﺩﺭ ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ‪:‬‬ ‫ﺩﺭ ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ ﭼﻨﺪ ﻣﻔﻬﻮﻡ ﺩﺭ ﺧﺼﻮﺹ ﻛﻠﻴﺪ ﻣﻄﺮﺡ ﺍﺳﺖ ﻛﻪ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ ‪:‬‬ ‫•‬

‫ﺍﺑﺮ ﻛﻠﻴﺪ‬

‫•‬

‫ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ‬

‫•‬

‫ﻛﻠﻴﺪ ﺍﺻﻠﻲ‬

‫•‬

‫ﻛﻠﻴﺪ ﺑﺪﻳﻞ‬

‫•‬

‫ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ‬

‫‪ -١-٣-٣‬ﻣﻔﻬﻮﻡ ﺍﺑﺮ ﻛﻠﻴﺪ ‪super key‬‬ ‫ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯﻳﻚ ﻳﺎ ﭼﻨﺪ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺭﺍ ﻛﻪ ﺩﺍﺭﺍﻱ ﻳﻜﺘﺎﻳﻲ ﻣﻘﺪﺍﺭ ﺑﺎﺷﻨﺪ ﺍﺑﺮﻛﻠﻴﺪ ﮔﻮﻳﻨﺪ‪ .‬ﺑﻪ ﺑﻴﺎﻥ ﺩﻳﮕﺮ ‪ ،‬ﻫﺮ ﺗﺮﻛﻴﺒﻲ ﺍﺯ‬ ‫ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺭﺍﺑﻄﻪ ﻛﻪ ﺩﺭ ﻫﻴﭻ ﺩﻭ ﺗﺎﭘﻞ ﻣﻘﺪﺍﺭ ﻳﻜﺴﺎﻥ ﻧﺪﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫‪ ١_٣ _٤‬ﻛﻠﻴﺪ)ﻧﺎﻣﺰﺩ( ﻛﺎﻧﺪﻳﺪ‪:‬‬

‫‪Candidate Key‬‬

‫ﺍﺑـﺮ ﻛﻠـﻴﺪﻱ ﻛـﻪ ﺧﺎﺻـﻴﺘﻲ ﻛـﺎﻫﺶ ﻧﺎﭘﺬﻳـﺮﻱ ﺩﺍﺷـﺘﻪ ﺑﺎﺷـﺪ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﮔﻮﻳﻨﺪ‪ .‬ﺑﻌﺒﺎﺭﺕ ﺩﻳﮕﺮ ﻫﺮ ﺯﻳﺮ ﻣﺠﻤﻮﻋﻪ ﺍﺯ ﻣﺠﻤﻮﻋﻪ‬ ‫ﻋﻨﻮﺍﻥ ) ‪ ( Ai, Aj ..Ak‬ﻛﻪ ﺩﻭ ﺧﺎﺻﻴﺖ ﺯﻳﺮ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﮔﻮﻳﻨﺪ‪.‬‬ ‫‪ _١‬ﻳﻜﺘﺎﻳﻲ ﻣﻘﺪﺍﺭ ) ‪( Uniqueness‬‬ ‫ﺑﻪ ﺍﻳﻦ ﻣﻌﻨﺎ ﻛﻪ ﺩﺭ ﻫﺮ ﻟﺤﻈﻪ ﺍﺯ ﺣﻴﺎﺕ ﺭﺍﺑﻄﻪ ﻣﻘﺪﺍﺭ ) ‪ ( A i , Aj ..Ak‬ﻳﻜﺘﺎ ﺑﺎﺷﺪ‪.‬‬ ‫‪ _٢‬ﻛﺎﻫﺶ ﻧﺎﭘﺬﻳﺮﻱ ‪minimatlity‬‬

‫ﺑـﻪ ﺍﻳـﻦ ﻣﻌﻨـﻲ ﺍﺳﺖ ﻛﻪ ﺍﺯ ﻧﻈﺮ ﺗﻌﺪﺍﺩ ﺍﺟﺰﺍﺀ ﺩﺭ ﺣﺪﺍﻗﻞ ﺑﺎﺷﺪ ﺩﺭ ﻋﻴﻦ ﺣﺎﻝ ﻛﻪ ﻳﻜﺘﺎﻳﻲ ﻣﺤﻔﻮﻅ ﺑﻤﺎﻧﺪ‪ .‬ﮔﻮﺋﻴﻢ ﺯﻳﺮ ﻣﺠﻤﻮﻋﻪ‬ ‫ﺍﻱ ﻛـﺎﻫﺶ ﻧﺎﭘﺬﻳـﺮ ﺍﺳـﺖ ﻳـﺎ ﺣﺪﺍﻗﻞ ﺍﺟﺰﺍﺀ ﺩﺍﺭﺩ ﺍﮔﺮ ﻳﻜﻲ ﺍﺯ ﻋﻨﺎﺻﺮ ﺍﻳﻦ ﺯﻳﺮﻣﺠﻤﻮﻋﻪ ﺣﺬﻑ ﺷﻮﺩ ﺩﺭ ﺯﻳﺮﻣﺠﻤﻮﻋﻪ ﺑﺎﻗﻴﻤﺎﻧﺪﻩ‬ ‫ﺧﺎﺻﻴﺖ ﻳﻜﺘﺎﻳﻲ ﻣﻘﺪﺍﺭﺍﺯ ﺑﻴﻦ ﺑﺮﻭﺩ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣٢ /‬‬

‫ﺑـﺎ ﺗـﻮﺟﻪ ﺑـﻪ ﺗﻌﺎﺭﻳﻒ ﻣﻲ ﺑﻴﻨﻴﻢ ﻫﺮ ﺍﺑﺮﻛﻠﻴﺪ ﻟﺰﻭﻣﺎ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﻧﻴﺴﺖ ﺍﻣﺎ ﻫﺮ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺟﺰﺀ ﻣﺠﻤﻮﻋﻪ ﻫﺎﻱ ﺍﺑﺮ ﻛﻠﻴﺪ ﺭﺍﺑﻄﻪ‬ ‫ﻫﺴﺖ‪.‬‬ ‫ﻣﺜﺎﻝ‪ :‬ﺩﺭ ﺭﺍﺑﻄﻪ ‪ S‬ﺻﻔﺖ ﺧﺎﺻﻪ ‪ S#‬ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺍﺳﺖ ﻭ ﺩﺭ ﺭﺍﺑﻄﻪ ‪ ( S#, P# ) SP‬ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺍﺳﺖ‪.‬‬ ‫ﻧﻜﺘﻪ‪ :١ :‬ﺭﺍﺑﻄﻪ ﻣﻤﻜﻦ ﺍﺳﺖ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫ﻧﻜـﺘﻪ ‪ _٢‬ﻭﺟـﻮﺩ ﺣـﺪﺍﻗﻞ ﻳﻚ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺩﺭ ﺭﺍﺑﻄﻪ ﺗﻀﻤﻴﻦ ﺍﺳﺖ ﺯﻳﺮﺍ ﺩﺭ ﺑﺪﺗﺮﻳﻦ ﺣﺎﻟﺖ ﺑﺎ ﺗﺮﻛﻴﺐ ﺗﻤﺎﻡ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺑﻪ‬ ‫ﻳﻜﺘﺎﻳـﻲ ﻣﻘـﺪﺍﺭ ﻣـﻲ ﺭﺳـﻴﻢ‪ .‬ﺑﻪ ﺭﺍﺑﻄﻪ ﺍﻱ ﻛﻪ ﻣﺠﻤﻮﻋﻪ ﻋﻨﻮﺍﻧﺶ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺁﻥ ﺑﺎﺷﺪ ﺍﺻﻄﻼﺣﹰﺎ ﺭﺍﺑﻄﻪ ﺗﻤﺎﻡ ﻛﻠﻴﺪ‬

‫‪(All‬‬

‫)‪ key‬ﻧﺎﻣﻴﺪﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﻧﻜﺘﻪ ‪ _٣‬ﻧﻘﺶ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ‪ :‬ﺍﻣﻜﺎﻧﻲ ﺍﺳﺖ ﺑﺮﺍﻱ ﺍﺭﺟﺎﻉ ﺑﻪ ﺗﺎﭘﻞ ﻳﻌﻨﻲ ﻧﻮﻋﻲ ﻣﻜﺎﻧﻴﺴﻢ ﺁﺩﺭﺱ ﺩﻫﻲ ﺩﺭ ﺳﻄﺢ ﺗﺎﭘﻞ ﺍﺳﺖ‪.‬‬ ‫‪ ٢_٣ _٣‬ﻛﻠﻴﺪ ﺍﺻﻠﻲ‪Primary Key :‬‬

‫ﻳﻜـــﻲ ﺍﺯ ﻛﻠـــﻴﺪﻫﺎﻱ ﻛﺎﻧﺪﻳـــﺪ ﺍﺳـــﺖ ﻛـــﻪ ﻃـــﺮﺍﺡ ﺑـــﺎ ﺗـــﻮﺟﻪ ﺑـــﻪ ﻣﻼﺣﻀـــﺎﺕ ﻣﺤـــﻴﻂ ﻋﻤﻠﻴﺎﺗـــﻲ‪ ،‬ﺧـــﻮﺩ ﺍﻧـــﺘﺨﺎﺏ‬ ‫ﻣﻲ ﻛﻨﺪ‪ .‬ﺩﻭ ﺿﺎﺑﻄﻪ ﺩﺭ ﺗﻌﻴﻴﻦ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺍﺯ ﺑﻴﻦ ﻛﻠﻴﺪﻫﺎﻱ ﻛﺎﻧﺪﻳﺪ ﺑﺎﻳﺪ ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺘﻪ ﺷﻮﻧﺪ‪.‬‬ ‫‪ _١‬ﻧﻘﺶ ﻭ ﺍﻫﻤﻴﺖ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻧﺴﺒﺖ ﺑﻪ ﺳﺎﻳﺮ ﻛﻠﻴﺪ ﻫﺎﻱ ﻛﺎﻧﺪﻳﺪ ﺩﺭ ﭘﺎﺳﺨﮕﻮﻳﻲ ﺑﻪ ﻧﻴﺎﺯ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺍﻥ‬ ‫‪ _٢‬ﻛﻮﺗﺎﻫﺘﺮ ﺑﻮﺩﻥ ﻃﻮﻝ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺍﺯ ﻧﻈﺮ ﻃﻮﻝ ﺭﺷﺘﻪ ﺑﺎﻳﺘﻲ ﺣﺎﺻﻠﻪ ﺍﺯ ﺗﺮﻛﻴﺐ ﺻﻔﺎﺕ ﺧﺎﺻﻪ‪.‬‬ ‫ﻛﻠـﻴﺪ ﺍﺻـﻠﻲ ﺷﻨﺎﺳـﻪ ﺗﺎﭘـﻞ ﺍﺳـﺖ ﻭ ﺑﺎﻳﺴـﺘﻲ ﺑـﻪ ﻧﻮﻋـﻲ ﺑـﻪ ﺳﻴﺴﺘﻢ ﻣﻌﺮﻓﻲ ﺷﻮﺩ ﻛﻪ ﻣﻌﻤﻮﻻ ﺩﺭ ﺳﻴﺴﺘﻤﻬﺎﻱ ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﺎ ﻋﺒﺎﺭﺕ‬ ‫)‪ Primary Key (Attribute‬ﺗﻌﺮﻳﻒ ﻣﻴﺸﻮﺩ‪.‬‬ ‫‪ - ٣ _٣ _٣‬ﻛﻠﻴﺪ ﻧﺎﻣﺰﺩ)ﺑﺪﻳﻞ(‬

‫‪Alternate Key‬‬

‫ﻫـﺮ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﻏﻴﺮ ﺍﺯ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻛﻠﻴﺪ ﺑﺪﻳﻞ ﻧﺎﻣﻴﺪﻩ ﻣﻲ ﺷﻮﺩ‪.‬ﺍﮔﺮ ﻫﻤﻪ ﻛﻠﻴﺪ ﻫﺎﻱ ﻛﺎﻧﺪﻳﺪ ﺭﺍﺑﻄﻪ ﻭ ﻧﻴﺰ ﺧﻮﺩ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺑﻪ‬ ‫ﺳﻴﺴﺘﻢ ﻣﻌﺮﻓﻲ ﺷﻮﻧﺪ ‪ ،‬ﺩﻳﮕﺮ ﻧﻴﺎﺯﻱ ﺑﻪ ﺗﺼﺮﻳﺢ ﻛﻠﻴﺪ ﺩﻳﮕﺮ ﺑﺎ ﻋﺒﺎﺭﺕ ‪ Alternate Key‬ﻧﻴﺴﺖ‪.‬‬ ‫‪ : ٤ _٣ _٣‬ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ‬

‫‪Foreign Key‬‬

‫ﻼ ‪ Ri‬ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺑﺎﺷﺪ ﻛﻠﻴﺪ‬ ‫ﻫـﺮ ﺻـﻔﺖ ﺧﺎﺻـﻪ ﺍﻱ ﺍﺯ ﺭﺍﺑﻄـﻪ ‪ ) Rj‬ﺳـﺎﺩﻩ ﻳﺎ ﻣﺮﻛﺐ ( ﻣﺎﻧﻨﺪ ‪ Ai‬ﻛﻪ ﺩﺭ ﺭﺍﺑﻄﻪ ﺍﻱ ﺩﻳﮕﺮ ﻣﺜ ﹰ‬ ‫ﺧﺎﺭﺟﻲ ‪ Rj‬ﻧﺎﻣﻴﺪﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺻﻔﺖ ﺧﺎﺻﻪ ‪ S#‬ﺩﺭ ﺟﺪﻭﻝ ‪ SP‬ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺍﺳﺖ ﻭ ﺻﻔﺖ ﺧﺎﺻﻪ ‪ P#‬ﺩﺭ ﺭﺍﺑﻄﻪ ‪ SP‬ﻧﻴﺰ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺍﺳﺖ‪.‬‬ ‫ﻧﻜـﺘﻪ‪ :‬ﻟﺰﻭﻣـﻲ ﻧـﺪﺍﺭﺩ ﻛـﻪ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﻳﻚ ﺭﺍﺑﻄﻪ ﺟﺰﺀ ﺗﺸﻜﻴﻞ ﺩﻫﻨﺪﻩ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻫﻤﺎﻥ ﺭﺍﺑﻄﻪ ﺑﺎﺷﺪ ﻫﺮ ﭼﻨﺪ ﺩﺭ ﻣﺜﺎﻝ ﺑﺎﻻ‬ ‫ﭼﻨﻴﻦ ﺍﺳﺖ‪.‬‬ ‫ﻣﺜﺎﻝ‪Department ( Dept # , Dname , manager - Emp #, budget ) :‬‬ ‫) ‪Employe ( Emp # , Ename, Dept # , Salary‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣٣ /‬‬

‫ﺩﺭ ﺭﺍﺑﻄـﻪ ‪ deparment‬ﺻـﻔﺖ ﺧﺎﺻـﻪ ‪ dept #‬ﻛﻠـﻴﺪ ﺍﺻـﻠﻲ ﺍﺳـﺖ ﻟـﺬﺍ ﺩﺭ ﺭﺍﺑﻄﻪ ‪ Employe‬ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺍﺳﺖ ﻭ ﻧﻴﺰ‬ ‫ﺻـﻔﺖ ﺧﺎﺻـﻪ ‪ Emp #‬ﺩﺭ ﺟـﺪﻭﻝ ‪ Employe‬ﻛﻠـﻴﺪ ﺍﺻـﻠﻲ ﺍﺳﺖ ﭘﺲ ﺻﻔﺖ ﺧﺎﺻﻪ ‪ Manager - Emp #‬ﺩﺭ ﺭﺍﺑﻄﻪ‬ ‫‪ department‬ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺍﺳﺖ ﻭ ﺟﺰﺋﻲ ﺍﺯ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺍﻳﻦ ﺭﺍﺑﻄﻪ ﻫﻢ ﻧﻴﺴﺖ‪.‬‬ ‫ﻧﻜﺘﻪ ‪ :‬ﻟﺰﻭﻣﻲ ﻧﺪﺍﺭﺩ ‪ Rj‬ﺍﺯ ‪ Ri‬ﻣﺘﻤﺎﻳﺰ ﺑﺎﺷﺪ‪:‬‬ ‫) ‪E mploye ( Emp # , Ename, Manager -Emp # , Salay‬‬

‫ﺭﺍﺑﻄﻪ‪ :‬ﻛﺎﺭﻣﻨﺪ ﻣﺪﻳﺮ ﺍﺳﺖ ‪.‬‬ ‫ﺳﻮﺍﻝ ‪ :‬ﻧﻘﺶ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﭼﻴﺴﺖ؟‬ ‫ﻛﻠـﻴﺪ ﺧﺎﺭﺟـﻲ ﺍﻣﻜﺎﻧﻲ ﺍﺳﺖ ﺑﺮﺍﻱ ﺍﻳﺠﺎﺩ ﺍﺭﺗﺒﺎﻁ ﺑﻴﻦ ﺗﺎﭘﻠﻬﺎ‪ .‬ﺑﻌﻨﻮﺍﻥ ﻣﺜﺎﻝ ﻭﺟﻮﺩ ﻛﻠﻴﺪ ﻫﺎﻱ ﺧﺎﺭﺟﻲ ‪ P #, S#‬ﺩﺭ ﺭﺍﺑﻄﻪ ‪Sp‬‬

‫ﻧﻤﺎﻳﺸﮕﺮ ﺍﺭﺗﺒﺎﻃﻲ ﺍﺳﺖ ﻛﻪ ﺑﻴﻦ ﺗﺎﭘﻠﻬﺎﻱ ﺭﺍﺑﻄﻪ ‪ S‬ﻭ ﺗﺎﭘﻠﻬﺎﻱ ﺭﺍﺑﻄﻪ ‪ P‬ﻭﺟﻮﺩ ﺩﺍﺭﺩ‪.‬‬ ‫ﻧﻜﺘﻪ‪ :‬ﺁﻳﺎ ﺗﻨﻬﺎ ﻋﺎﻣﻞ ﺑﺮﻗﺮﺍﺭﻱ ﺍﺭﺗﺒﺎﻁ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺍﺳﺖ؟‬ ‫ﭘﺎﺳﺦ ﻣﻨﻔﻲ ﺍﺳﺖ ﻫﺮ ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﺸﺘﺮﻙ ﺩﺭ ﻋﻨﻮﺍﻥ ﺩﻭ ﺭﺍﺑﻄﻪ ﺍﻣﻜﺎﻧﻲ ﺍﺳﺖ ﺑﺮﺍﻱ ﺍﻳﺠﺎﺩ ﻭ ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ ﻧﻮﻋﻲ ﺍﺭﺗﺒﺎﻁ‪.‬‬ ‫ﻣﺜﺎﻝ‪, S (S#, ...,city ) :‬‬

‫) ‪... city‬‬

‫‪P ( P#,‬‬

‫ﻭﺟﻮﺩ ‪ City‬ﺩﺭ ﺭﺍﺑﻄﻪ ﺍﻣﻜﺎﻥ ﺍﺭﺗﺒﺎﻁ ﺑﻴﻦ ﺩﻭ ﻣﻮﺟﻮﺩﻳﺖ ﺭﺍ ﺑﻮﺟﻮﺩ ﻣﻲ ﺁﻭﺭﺩ‪ .‬ﺩﺭ ﺻﻮﺭﺗﻴﻜﻪ ‪ C ity‬ﻧﻪ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ‪ S‬ﻭ ﻧﻪ‬ ‫ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ‪ P‬ﺍﺳﺖ‪.‬‬ ‫ﻧﻜﺘﻪ‪:‬ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺭﺍﺑﻄﻪ ﺭﺍ ﻧﻴﺰ ﺑﺎﻳﺪ ﺑﻪ ﺳﻴﺴﺘﻢ ﻣﻌﺮﻓﻲ ﻧﻤﻮﺩ ‪ .‬ﺑﺮﺍﻱ ﺍﻳﻦ ﻣﻨﻈﻮﺭ ﺍﺯ ﺩﺳﺘﻮﺭ ﺯﻳﺮ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻴﺸﻮﺩ ‪:‬‬ ‫‪Relation name‬‬

‫‪FOREIGN KEY (Attribute) REFERENCE‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣٤ /‬‬

‫‪ -٤-٣‬ﺗﺒﺪﻳﻞ ﻣﺪﻝ ‪ E/R‬ﺑﻪ ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ‬ ‫ﻳـﻚ ﭘﺎﻳﮕـﺎﻩ ﺩﺍﺩﻩ ﻃﺮﺍﺣـﻲ ﺷـﺪﻩ ﺑـﺮ ﺍﺳﺎﺱ ﻣﺪﻝ ﻣﻮﺟﻮﺩﻳﺖ‪/‬ﺍﺭﺗﺒﺎﻁ ﻣﻲ ﺗﻮﺍﻧﺪ ﺗﻮﺳﻂ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﺟﺪﻭﻝ ﻫﺎ ﻧﻤﺎﻳﺶ‬ ‫ﺩﺍﺩﻩ ﺷـﻮﺩ‪.‬ﺑـﺮﺍﻱ ﺗـﺒﺪﻳﻞ ﻣـﺪﻝ ﻣﻮﺟـﻮﺩﻳﺖ‪/‬ﺍﺭﺗﺒﺎﻁ ﺑﻪ ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ ﺍﺯ ﻳﻜﺴﺮﻱ ﻗﻮﺍﻧﻴﻦ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﺩﺭ ﺍﺩﺍﻣﻪ ﺁﻭﺭﺩﻩ‬ ‫ﺷﺪﻩ ﺍﻧﺪ‪:‬‬

‫ﻗﺎﻋﺪﻩ ‪ :١‬ﻫﺮ ﻣﻮﺟﻮﺩﻳﺖ ﻗﻮﻱ ﺗﻮﺳﻂ ﻳﻚ ﺟﺪﻭﻝ ﺑﺎ ﻫﻤﺎﻥ ﺻﻔﺎﺕ ﻣﻮﺭﺩ ﻧﻈﺮ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺻـﻔﺎﺕ ﻣـﺮﻛﺐ ﺩﺭ ﻣـﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ ﻭﺟﻮﺩ ﻧﺪﺍﺷﺘﻪ ﺑﻠﻜﻪ ﻓﻘﻂ ﺻﻔﺎﺕ ﺟﺰﺀ ﺁﻥ ﺻﻔﺎﺕ ﻣﺮﻛﺐ ﺑﻄﻮﺭ ﻣﺠﺰﺍ ﺩﺭ ﺟﺪﻭﻝ‬ ‫ﻗﺮﺍﺭ ﻣﻲ ﮔﻴﺮﻧﺪ‪.‬‬ ‫ﺻـﻔﺖ ﭼـﻨﺪ ﻣﻘﺪﺍﺭﻱ ‪ M‬ﺍﺯ ﻣﻮﺟﻮﺩﻳﺖ ‪ E‬ﺑﺎ ﻳﻚ ﺟﺪﻭﻝ ﻣﺠﺰﺍﻱ ‪ EM‬ﻧﺸﺎﻥ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﺩ‪ .‬ﺍﻳﻦ ﺟﺪﻭﻝ ﺩﺍﺭﺍﻱ‬ ‫ﺳﺘﻮﻧﻬﺎﻱ ﻣﺘﻨﺎﻇﺮ ﺑﺎ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ‪E‬ﻭ ﺻﻔﺖ ‪ M‬ﺧﻮﺍﻫﺪ ﺑﻮﺩ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﻣﻮﺟﻮﺩﻳﺖ ‪ Employee‬ﺑﺎ ﺻﻔﺖ ﭼﻨﺪ ﻣﻘﺪﺍﺭﻱ ‪Skill‬‬

‫‪Last_Name‬‬

‫‪Employee_Name‬‬

‫‪EMPLOYEE‬‬

‫‪Skill‬‬

‫‪First_Name‬‬

‫‪Employee_ID‬‬

‫‪EMPLOYEE‬‬ ‫‪Last_Nam‬‬

‫‪First_Name‬‬

‫‪Employee_ID‬‬

‫‪SKILL‬‬ ‫‪Skill‬‬

‫‪Employee_I‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣٥ /‬‬

‫ﻗﺎﻋـﺪﻩ ‪ :٢‬ﻫـﺮ ﻣﻮﺟـﻮﺩﻳﺖ ﺿـﻌﻴﻒ ﺗﻮﺳـﻂ ﻳﻚ ﺟﺪﻭﻝ ﺑﺎ ﻫﻤﺎﻥ ﺻﻔﺎﺕ ﻣﻮﺭﺩ ﻧﻈﺮ ﺑﻪ ﻫﻤﺮﺍﻩ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻣﻮﺟﻮﺩﻳﺖ ﻗﻮﻱ‬ ‫)ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺍﻳﻦ ﺟﺪﻭﻝ( ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺟﺪﻭﻝ ﺟﺪﻳﺪ ‪،‬ﺗﺮﻛﻴﺒﻲ ﺍﺳﺖ ﺍﺯ ﺷﻨﺎﺳﻪ ﻣﻮﺟﻮﺩﻳﺖ ﺿﻌﻴﻒ ﻭ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻣﻮﺟﻮﺩﻳﺖ ﻗﻮﻱ ﻣﻮﺭﺩ ﻧﻈﺮ ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﻣﻮﺟﻮﺩﻳﺖ ﺿﻌﻴﻒ‪DEPENDENT‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣٦ /‬‬

‫ﻗﺎﻋﺪﻩ ‪ : ٣‬ﺍﺭﺗﺒﺎﻃﺎﺕ ﺩﺭﺟﻪ ‪. ٢‬‬ ‫ﻫﺮ ﺍﺭﺗﺒﺎﻁ ﺩﺭﺟﻪ ﺩﻭ ﭼﻨﺪ ﺑﻪ ﭼﻨﺪ ﺑﺎ ﻳﻚ ﺟﺪﻭﻝ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﺳﺘﻮﻧﻬﺎﻳﺶ ﺍﺯ ﻛﻠﻴﺪﻫﺎﻱ ﺍﺻﻠﻲ ﺩﻭ‬ ‫ﻣﻮﺟﻮﺩﻳﺖ ﻣﺸﺎﺭﻛﺖ ﻳﺎﻓﺘﻪ ﺩﺭ ﺍﺭﺗﺒﺎﻁ ﺑﻪ ﻫﻤﺮﺍﻩ ﺻﻔﺎﺕ ﺩﻳﮕﺮ ﻣﺠﻤﻮﻋﻪ ﺍﺭﺗﺒﺎﻁ ﺗﺸﻜﻴﻞ ﻣﻲ ﮔﺮﺩﻧﺪ‪.‬‬ ‫ﺍﺭﺗﺒﺎﻃﺎﺕ ﭼﻨﺪ ﺑﻪ ﻳﻚ ﻳﺎ ﻳﻚ ﺑﻪ ﭼﻨﺪ ﺩﺭ ﻃﺮﻑ ﭼﻨﺪ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺻﻔﺖ ﺍﺿﺎﻓﻪ ﺷﺪﻩ ﻛﻪ ﻫﻤﺎﻥ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻃﺮﻑ‬ ‫ﻳﻚ ﻣﻲ ﺑﺎﺷﺪ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﻧﺪ‪).‬ﺟﺪﻭﻝ ﻣﺠﺰﺍ ﻧﺨﻮﺍﻫﺪ ﺑﻮﺩ(ﺑﻪ ﻋﺒﺎﺭﺕ ﺩﻳﮕﺮ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻃﺮﻑ ﻳﻚ ﺑﻪ ﻋﻨﻮﺍﻥ‬ ‫ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﻃﺮﻑ ﭼﻨﺪ ﻣﻨﻈﻮﺭ ﻣﻲ ﮔﺮﺩﺩ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺩﺭ ﺷﻜﻞ ﺯﻳﺮ ‪،‬ﺑﺠﺎﻱ ﺍﻳﺠﺎﺩ ﻳﻚ ﺟﺪﻭﻝ ﺑﺮﺍﻱ ﺍﺭﺗﺒﺎﻁ ‪ account-branch‬ﺻﻔﺖ ‪ branchname‬ﺑﻪ ﺟﺪﻭﻝ‬ ‫‪ account‬ﺍﺿﺎﻓﻪ ﻣﻲ ﺷﻮﺩ‪.‬‬

‫ﺩﺭ ﺍﺭﺗـﺒﺎﻃﺎﺕ ﻳـﻚ ﺑـﻪ ﻳـﻚ ‪ ،‬ﻫـﺮ ﻃﺮﻓـﻲ ﻣﻲ ﺗﻮﺍﻧﺪ ﺑﻪ ﻋﻨﻮﺍﻥ ﭼﻨﺪ ﺍﻧﺘﺨﺎﺏ ﺷﻮﺩ‪.‬ﺑﺪﻳﻦ ﻣﻌﻨﻲ ﻛﻪ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻃﺮﻑ‬ ‫ﻣﻬﻤﺘﺮ ﺑﻪ ﻋﻨﻮﺍﻥ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﻃﺮﻑ ﻛﻢ ﺍﻫﻤﻴﺖ ﺗﺮ ﺍﺿﺎﻓﻪ ﻣﻲ ﺷﻮﺩ‪.‬‬

‫ﻗﺎﻋﺪﻩ ‪ : ٤‬ﺍﺭﺗﺒﺎﻃﺎﺕ ﺩﺭﺟﻪ ﻳﻚ)ﺑﺎﺯﮔﺸﺘﻲ(‪.‬‬ ‫ﻫﺮ ﺍﺭﺗﺒﺎﻁ ﺩﺭﺟﻪ ﻳﻚ ﭼﻨﺪ ﺑﻪ ﭼﻨﺪ ﺑﺎ ﻳﻚ ﺟﺪﻭﻝ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺍﺵ ﺩﻭ ﻓﻴﻠﺪ ﺑﺮﮔﺮﻓﺘﻪ ﺍﺯ‬ ‫ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻣﻮﺟﻮﺩﻳﺖ ﺍﺳﺖ ﻛﻪ ﺑﺎ ﺗﻐﻴﻴﺮ ﻧﺎﻡ ﻳﻜﻲ ﺍﺯ ﺁﻧﻬﺎ ﺍﺯﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻣﻮﺟﻮﺩﻳﺖ ﻣﺮﺗﺒﻂ ﺗﺸﻜﻴﻞ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺩﺭ ﺍﺭﺗﺒﺎﻁ ﺑﺎﺯﮔﺸﺘﻲ ﻳﻚ ﺑﻪ ﭼﻨﺪ ‪ ،‬ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺑﺎﺯﮔﺸﺘﻲ ﺩﺭ ﻫﻤﺎﻥ ﺟﺪﻭﻝ ﻣﺮﺑﻮﻁ ﺑﻪ ﻣﻮﺟﻮﺩﻳﺖ )ﺑﺎ ﺗﻐﻴﻴﺮ ﻧﺎﻡ‬ ‫ﻛﻠﻴﺪ ﺍﺻﻠﻲ( ﺩﺍﺭﻳﻢ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺜﺎﻝ ‪:‬‬

‫ﺟﺪﻭﻝ ‪ EMPLOYEE‬ﺑﺎ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺑﺎﺯﮔﺸﺘﻲ‬

‫ﺏ( ﺩﻭﺟﺪﻭﻝ ﺑﺪﺳﺖ ﺁﻣﺪﻩ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣٧ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣٨ /‬‬

‫ﻗﺎﻋﺪﻩ ‪ : ٥‬ﺍﺭﺗﺒﺎﻃﺎﺕ ﺩﺭﺟﻪ ‪ ٣‬ﻭ ﺑﻴﺸﺘﺮ ‪.‬‬ ‫ﻫﺮ ﺍﺭﺗﺒﺎﻁ ‪n‬ﺗﺎﻳﻲ ﺑﺎ ﻳﻚ ﺟﺪﻭﻝ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺍﺵ ‪ n‬ﻓﻴﻠﺪ ﺑﺮﮔﺮﻓﺘﻪ ﺍﺯ ﻛﻠﻴﺪ ﺍﺻﻠﻲ‬ ‫ﻣﻮﺟﻮﺩﻳﺘﻬﺎﻱ ﻣﺸﺎﺭﻛﺖ ﻳﺎﻓﺘﻪ ﺩﺭ ﺍﺭﺗﺒﺎﻁ ‪ n‬ﺗﺎﻳﻲ ﻣﻲ ﺑﺎﺷﺪ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٣٩ /‬‬

‫ﻗﺎﻋﺪﻩ ‪ : ٦‬ﺍﺭﺗﺒﺎﻃﺎﺕ ﺗﻌﻤﻴﻢ‪/‬ﺗﺨﺼﻴﺺ ‪.‬‬ ‫ﺭﻭﺵ ﺍﻭﻝ‪ :‬ﺑﺎﺯﺍﻱ ﻫﺮ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﺑﺎﻻ ﻭ ﭘﺎﻳﻴﻦ ﻳﻚ ﺟﺪﻭﻝ ﺟﺪﺍﮔﺎﻧﻪ ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺘﻪ ﺷﺪﻩ ﻛﻪ ﺩﺭ ﺟﺪﻭﻝ ﺳﻄﺢ‬ ‫ﭘﺎﻳﻴﻦ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﺑﺎﻻﺗﺮ ﺑﻪ ﻋﻨﻮﺍﻥ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﻗﺮﺍﺭ ﻣﻲ ﮔﻴﺮﺩ‪.‬‬ ‫‪table‬‬ ‫‪table attributes‬‬ ‫) ‪person(name, street, city‬‬ ‫)‪customer (name, credit-rating‬‬ ‫)‪employee(name, salary‬‬ ‫ﻧﻜﺘﻪ ‪ :‬ﺍﺷﻜﺎﻝ ﺍﻳﻦ ﺭﻭﺵ ؟ ﺟﻤﻊ ﺁﻭﺭﻱ ﺍﻃﻼﻋﺎﺕ ﻣﺴﺘﻠﺰﻡ ﻣﺮﺍﺟﻌﻪ ﺑﻪ ﺩﻭ ﺟﺪﻭﻝ ﺍﺳﺖ ‪.‬‬ ‫ﺭﻭﺵ ﺩﻭﻡ ‪ :‬ﺑﺎﺯﺍﻱ ﻫﺮ ﻣﻮﺟﻮﺩﻳﺖ ﺻﻔﺎﺕ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻭ ﻏﻴﺮﻩ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﺑﺎﻻﺗﺮ ﺩﺭ ﻣﻮﺟﻮﺩﻳﺖ ﺳﻄﺢ ﭘﺎﻳﻴﻨﺘﺮ‬ ‫ﻗﺮﺍﺭ ﻣﻲ ﮔﻴﺮﺩ‪ .‬ﺩﺭ ﺻﻮﺭﺗﻲ ﺗﻌﻤﻴﻢ ﻛﺎﻣﻞ ﺑﺎﺷﺪ ﻧﻴﺎﺯﻱ ﺑﻪ ﻭﺟﻮﺩ ﺟﺪﻭﻝ ﺳﻄﺢ ﺑﺎﻻﺗﺮ ﻧﺨﻮﺍﻫﺪ ﺑﻮﺩ‪.‬‬ ‫‪table table attributes‬‬ ‫‪person‬‬ ‫)‪(name, street, city‬‬ ‫)‪customer ( name, street, city, credit-rating‬‬ ‫)‪employee ( name, street, city, salary‬‬ ‫ﻧﻜﺘﻪ ‪ :‬ﺍﺷﻜﺎﻝ ﺍﻳﻦ ﺭﻭﺵ ؟ ﺍﻓﺰﻭﻧﮕﻲ‬ ‫ﻗﺎﻋﺪﻩ ‪ :٧‬ﺗﺠﻤﻊ ‪ :‬ﺑﺮﺍﻱ ﻧﻤﺎﻳﺶ ﺗﺠﻤﻊ ‪ ،‬ﻳﻚ ﺟﺪﻭﻝ ﺷﺎﻣﻞ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺍﺭﺗﺒﺎﻁ ﺗﺠﻤﻊ ﺷﺪﻩ ‪ ،‬ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻣﺠﻤﻮﻋﻪ‬ ‫ﻣﻮﺟﻮﺩﻳﺖ ﻣﺸﺎﺭﻛﺖ ﻳﺎﻓﺘﻪ ‪،‬ﺻﻔﺎﺕ ﻣﻮﺭﺩ ﻧﻈﺮ ﺍﻳﺠﺎﺩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺭﺍﺑﻄﻪ ﺗﺠﻤﻊ ‪ manages‬ﺑﻴﻦ ﺍﺭﺗﺒﺎﻃﺎﺕ‪ Works-on , manager‬ﺑﺼﺌﺮﺕ ﻳﻚ ﺟﺪﻭﻝ ﺯﻳﺮ ﺍﺳﺖ ‪:‬‬ ‫)‪manages(employee-id, branch-name, title, manager-name‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٤٠ /‬‬

‫ﻣﺜﺎﻝ‪ -۴ :‬ﻧﻤﻮﺩﺍﺭ ‪ E/R‬ﺯیﺮ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﺑﮕیﺮیﺪ ﺳﭙﺲ ﺟﺪﺍﻭﻝ ﭘﺎیﮕﺎﻩ ﺩﺍﺩﻩ ﺭﺍ ﺑﺮ ﺍﺳﺎﺱ ﻧﻤﻮﺩﺍﺭ‬ ‫ﺍﺳﺘﺨﺮﺍﺝ ﻧﻤﺎییﺪ‪) .‬ﮐﻠیﺪ ﻫﺎﯼ ﺧﺎﺭﺟﯽ ﻭ ﺍﺻﻠﯽ ﻣﺸﺨﺺ ﮔﺮﺩﻧﺪ (‪.‬‬ ‫‪PATIENT :‬ﺑیﻤﺎﺭ ‪DOCTOR :‬‬

‫ﭘﺰﺷﮏ ‪DRUG :‬‬

‫ﺩﺍﺭﻭﺧﺎﻧﻪ ‪PHARM-CO :‬ﺷﺮﮐﺖ ﺩﺍﺭﻭ ﺳﺎﺯﯼ‬

‫‪!Error‬‬

‫ﺩﺍﺭﻭ ‪PHARMACY :‬‬

٤١ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

Phone

Name Phone-pharm PHARM-CO Name

Address

DRUG Name(pharmco)

Trade-name

PHARMACY Name

formula

price

address

phone

Contract Name(pharm- Name(pharmacy) from co) PATEIENT ssn

Name(pharmacy)

name

to

age

text

address

supervisor

Ssn(doctor)

Prescrip Ssn(doctor)

ssn(patient)

Trade-name

date

Doctor ssn

name

specialty

Yrs-or-exp

qty

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٤٢ /‬‬

‫‪ -٥-٣‬ﻗﻮﺍﻧﻴﻦ ﺟﺎﻣﻌﻴﺖ ﺩﺭ ﺳﻴﺴﺘﻢ ﻫﺎﻱ ﺭﺍﺑﻄﻪ ﺍﻱ‪:‬‬ ‫ﺟﺎﻣﻌـﻴﺖ ﭘﺎﻳﮕـﺎﻩ ﺩﺍﺩﻩ ﻳﻌﻨـﻲ ‪ :‬ﺻـﺤﺖ ‪ ،‬ﺩﻗـﺖ ﻭ ﺳـﺎﺯﮔﺎﺭﻱ ﺩﺍﺩﻩ ﻫـﺎﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺩﺭ ﭘﺎﻳﮕﺎﻩ ﺩﺭ ﺗﻤﺎﻡ ﻟﺤﻈﺎﺕ ‪ .‬ﻫﺮ ﺳﻴﺴﺘﻢ‬ ‫ﻣﺪﻳـﺮﻳﺖ ﭘﺎﻳﮕـﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﺑﺎﻳﺪ ﺑﺘﻮﺍﻧﺪ ﺟﺎﻣﻌﻴﺖ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﺭﺍ ﻛﻨﺘﺮﻝ ﻭ ﺗﻀﻤﻴﻦ ﻧﻤﺎﻳﺪ‪.‬ﺑﺮﺍﻱ ﻛﻨﺘﺮﻝ ﻭ ﺗﻀﻤﻴﻦ ﺟﺎﻣﻌﻴﺖ ‪ ،‬ﻧﻴﺎﺯ‬ ‫ﺑـﻪ ﻣﺠﻤـﻮﻋﻪ ﺍﻱ ﺍﺯ ﻗـﻮﺍﻋﺪ ﻭ ﻣﺤﺪﻭﺩﻳﺘﻬﺎﺳـﺖ ﻛـﻪ ﺩﺭ ﻳـﻚ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﺧﺎﺹ ﺭﻭﻱ ﺩﺍﺩﻩ ﻫﺎﻱ ﻫﻤﺎﻥ ﻣﺤﻴﻂ ﺑﺎﻳﺪ ﺍﻋﻤﺎﻝ‬ ‫ﺷﻮﻧﺪ ﻭﺑﻨﺎﻡ ﻗﻮﺍﻧﻴﻦ ﺟﺎﻣﻌﻴﺘﻲ ﺧﻮﺍﻧﺪﻩ ﻣﻲ ﺷﻮﻧﺪ‪ .‬ﺍﻳﻦ ﻗﻮﺍﻋﺪ ﺑﻄﻮﺭ ﻛﻠﻲ ﺑﻪ ﺩﻭ ﺩﺳﺘﻪ ﺗﻘﺴﻴﻢ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬ ‫ﺍﻟﻒ ـ ﻗﻮﺍﻋﺪ ﺧﺎﺹ ﻳﻚ ﻣﺤﻴﻂ )ﻛﺎﺭﺑﺮﻱ(‬ ‫ﻗـﻮﺍﻋﺪﻱ ﻫﺴـﺘﻨﺪ ﻛﻪ ﺗﻮﺳﻂ ﻳﻚ ﻛﺎﺭﺑﺮ ﻣﺠﺎﺯ ﺗﻌﺮﻳﻒ ﻣﻲ ﺷﻮﻧﺪ ‪ .‬ﺍﻳﻦ ﻗﻮﺍﻋﺪ ﺩﺭ ﻣﻮﺭﺩ ﻳﻚ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺧﺎﺹ ﻣﻄﺮﺡ ﺷﺪﻩ ﻭ‬ ‫ﻋﻤﻮﻣﻴﺖ ﻧﺪﺍﺭﻧﺪ‪ .‬ﮔﺎﻩ ﺑﻪ ﺍﻳﻦ ﻗﻮﺍﻋﺪ ‪،‬ﻗﻮﺍﻋﺪ ﻣﺤﻴﻄﻲ ﻭﺍﺑﺴﺘﻪ ﺑﻪ ﺩﺍﺩﻩ ﻭ ﻳﺎ ﻣﺤﺪﻭﺩﻳﺘﻬﺎﻱ ﺟﺎﻣﻌﻴﺖ ﻣﻌﻨﺎﻳﻲ ﻧﻴﺰ ﻣﻲ ﮔﻮﻳﻨﺪ‪.‬‬ ‫ﺑﻄﻮﺭ ﻣﺜﺎﻝ ‪،‬ﺩﺭ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺕ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﻭ ﻗﻄﻌﺎﺕ ﻣﻲ ﺗﻮﺍﻥ ﻗﺎﻋﺪﻩ ﺍﻱ ﺭﺍ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺗﻌﺮﻳﻒ ﻛﺮﺩ‪:‬‬ ‫ﻣﻘـﺪﺍﺭ ‪ Qty‬ﻫﻤﻴﺸـﻪ ﺑﻴﻦ ﺻﻔﺮ ﻭ ‪ ١٠٠٠٠‬ﺑﺎﺷﺪ‪ .‬ﻭﺟﻮﺩ ﭼﻨﻴﻦ ﻗﺎﻋﺪﻩ ﺍﻱ ﺩﺭ ﺑﺎﻧﻚ ﺍﻳﺠﺎﺏ ﻣﻲ ﻛﻨﺪ ﻛﻪ ﺳﻴﺴﺘﻢ ﺍﺯ ﺍﻧﺠﺎﻡ ﻫﺮﮔﻮﻧﻪ‬ ‫ﻋﻤﻠﻲ ﻛﻪ ﺳﺒﺐ ﻣﻲ ﺷﻮﺩ ﻣﻘﺪﺍﺭ ‪ Q ty‬ﺧﺎﺭﺝ ﺍﺯ ﻃﻴﻒ ﻣﻘﺎﺩﻳﺮ ﺑﺸﻮﺩ ‪ ،‬ﺟﻠﻮﮔﻴﺮﻱ ﻛﻨﺪ‪.‬‬ ‫ﺩﺭ ﺳﻴﺴـﺘﻤﻬﺎﻱ ﻣﻮﺟـﻮﺩ ﺑـﺮﺍﻱ ﻣﻌﺮﻓـﻲ ﺍﻳـﻦ ﻗﻮﺍﻋﺪ ﺍﺯ ﻣﻜﺎﻧﻴﺴﻢ ﺍﻇﻬﺎﺭ )‪ (Assertion‬ﺍﺳﺘﻔﺎﺩﻩ ﻣﻴﺸﻮﺩ‪ .‬ﺍﻇﻬﺎﺭ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ‬ ‫ﺷﺮﻁ ﻭ ﻳﺎ ﺷﺮﺍﻳﻄﻲ ﺍﺳﺖ ﻛﻪ ﻫﻤﻴﺸﻪ ﺑﺎﻳﺪ ﺩﺭﺭﻭﻱ ﻋﻤﻠﻴﺎﺕ ﭘﺎﻳﮕﺎﻩ ﺭﻋﺎﻳﺖ ﺷﻮﻧﺪ‪ .‬ﺩﺳﺘﻮﺭ ﺗﻌﺮﻳﻒ ﺍﻇﻬﺎﺭ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﻣﻲ ﺑﺎﺷﺪ‬ ‫‪CREATE ASSERTION CHECK < Predicate>:‬‬ ‫ﺏ ـ ﻗﻮﺍﻋﺪ ﺟﺎﻣﻌﻴﺖ ﻋﺎﻡ‬ ‫ﻗﻮﺍﻋﺪ ﻋﺎﻡ ﻗﻮﺍﻋﺪﻱ ﻫﺴﺘﻨﺪ ﻛﻪ ﺑﺴﺘﮕﻲ ﺑﻪ ﺳﻴﺴﺘﻢ ﻭ ﺑﺎﻧﻚ ﺧﺎﺹ ﻧﺪﺍﺭﻧﺪ ﺑﻠﻜﻪ ﺩﺭ ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ ﻣﻄﺮﺡ ﺑﻮﺩﻩ ﻭ ﻗﺎﺑﻞ ﺍﻋﻤﺎﻝ ﺩﺭ‬ ‫ﻫﺮ ﺳﻴﺴﺘﻢ ﺭﺍﺑﻄﻪ ﺍﻱ ﻫﺴﺘﻨﺪ‪ .‬ﺑﻪ ﺍﻳﻦ ﻗﻮﺍﻋﺪ ﻣﺘﺎ ﻗﺎﻋﺪﻩ ﻧﻴﺰ ﮔﻔﺘﻪ ﻣﻴﺸﻮﺩ‪.‬‬ ‫ﺩﺭ ﻣـﺪﻝ ﺭﺍﺑﻄـﻪ ﺍﻱ ﺩﻭ ﻗﺎﻋـﺪﻩ ﺟﺎﻣﻌـﻴﺖ ﻭﺟـﻮﺩ ﺩﺍﺭﺩ‪ :‬ﻳﻜـﻲ ﻧﺎﻇﺮ ﺑﻪ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻭ ﺩﻳﮕﺮﻱ ﻧﺎﻇﺮ ﺑﻪ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺍﻳﻦ ﻗﻮﺍﻋﺪ‬ ‫ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ ‪:‬‬ ‫‪١‬ـ ﻗﺎﻋﺪﻩ ﺟﺎﻣﻌﻴﺖ ﻣﻮﺟﻮﺩﻳﺘﻲ ‪Entity Integrity Rule‬‬ ‫‪٢‬ـ ﻗﺎﻋﺪﻩ ﺟﺎﻣﻌﻴﺖ ﺍﺭﺟﺎﻋﻲ ‪Referential Integrity Rule‬‬ ‫‪٣‬ـ‪٥‬ـ‪١‬ـ ﻗﺎﻋﺪﻩ ﺟﺎﻣﻌﻴﺖ ﻣﻮﺟﻮﺩﻳﺘﻲ‪C1 :‬‬

‫ﻫﻴﭻ ﺟﺰ ﺗﺸﻜﻴﻞ ﺩﻫﻨﺪﻩ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻧﺒﺎﻳﺪ ﺩﺍﺭﺍﻱ " ﻣﻘﺪﺍﺭ ﻫﻴﭻ ")‪ (NuLL‬ﺑﺎﺷﺪ‪.‬‬ ‫‪ NullValue‬ﻣﻔﻬﻮﻣـﻲ ﺩﺭ ﺑﺎﻧـﻚ ﺍﻃﻼﻋﺎﺗـﻲ ﺍﺳـﺖ ﻛﻪ ﺩﺭ ﻭﺍﻗﻊ ﻣﻘﺪﺍﺭﻱ ﺍﺳﺖ ﻛﻪ ﺑﺮﺍﻱ ﻧﻤﺎﻳﺶ ﻣﻘﺪﺍﺭ ﻧﺎﺷﻨﺎﺧﺘﻪ ﻳﺎ ﻣﻘﺪﺍﺭ ﻏﻴﺮ‬ ‫ﻗﺎﺑﻞ ﺍﻋﻤﺎﻝ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ ﻭ ﺑﺎ ﻓﻀﺎﻱ ﺧﺎﻟﻲ ﻭ ﺻﻔﺮ ﻓﺮﻕ ﺩﺍﺭﺩ‪.‬‬ ‫‪: NullValue‬‬ ‫‪١‬ــ ﻣﻘـﺪﺍﺭ ﻧﺎﺷـﻨﺎﺧﺘﻪ‪ :‬ﻣﺜﻞ ﻛﺎﺭﻣﻨﺪﻱ ﻛﻪ ﻛﺪ ﺍﺩﺍﺭﻩ ﺍﺵ ﻣﺸﺨﺺ ﻧﻴﺴﺖ ﻭ ﻳﺎ ﺧﺎﻧﻪ ﺍﻱ ﺩﺭ ﻛﻮﭼﻪ ﺍﻱ ﺳﺎﺧﺘﻪ ﺷﺪ ﻭ ﻫﻨﻮﺯ ﭘﻼﻙ‬ ‫ﺷﻬﺮﺩﺍﺭﻱ ﻧﺪﺍﺭﺩ‪.‬‬ ‫‪٢‬ـ ﻣﻘﺪﺍﺭ ﻏﻴﺮ ﻗﺎﺑﻞ ﺍﻋﻤﺎﻝ )ﺑﺮﺍﻱ ﻳﻚ ﺻﻔﺖ ﻓﺎﺻﻠﻪ( ﻣﺜﻞ ﻣﺸﺨﺼﺎﺕ ﻫﻤﺴﺮ ﻛﺎﺭﻣﻨﺪﻱ ﻛﻪ ﻣﺠﺮﺩ ﺍﺳﺖ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫•‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٤٣ /‬‬

‫ﺩﻟﻴﻞ ﻗﺎﻋﺪﻩ ﺟﺎﻣﻌﻴﺖ ﻣﻮﺟﻮﺩﻳﺘﻲ‪:‬‬

‫ﭼـﻮﻥ ﻛﻠـﻴﺪ ﺍﺻـﻠﻲ ﺷﻨﺎﺳـﻪ ﺗﺎﭘـﻞ ﺍﺳـﺖ ﻭ ﺍﺯ ﺳﻮﻱ ﺩﻳﮕﺮ ﺷﻨﺎﺳﻪ ﻳﻜﻲ ﻧﻤﻮﻧﻪ ﻣﺸﺨﺺ ﻭ ﻣﺘﻤﺎﻳﺰ ﺍﺯ ﻳﻚ ﻧﻮﻉ ﻣﻮﺟﻮﺩﻳﺖ ﺍﺳﺖ‬ ‫ﭼﮕﻮﻧﻪ ﻣﻲ ﺗﻮﺍﻧﺪ ﻋﺎﻣﻞ ﺗﻤﺎﻳﺰ ﺧﻮﺩﺵ ﻧﺎﺷﻨﺎﺧﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫ﺍﻳﻦ ﻗﺎﻋﺪﻩ ﺍﺯ ﻃﺮﻳﻖ ﻣﻌﺮﻓﻲ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺩﺭ ﺗﻌﺮﻳﻒ ﺭﺍﺑﻄﻪ ﺑﺮ ﺳﻴﺴﺘﻢ ﺍﻋﻤﺎﻝ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪ -٢-٥-٣‬ﻗﺎﻋﺪﻩ ﺟﺎﻣﻌﻴﺖ ﺍﺭﺟﺎﻋﻲ ‪C2 :‬‬

‫ﺍﮔـﺮ ﺻـﻔﺖ ﺧﺎﺻـﻪ ‪ AI‬ﺍﺯ ﺭﺍﺑﻄﻪ ‪ ، R2‬ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺩﺭ ﺍﻳﻦ ﺭﺍﺑﻄﻪ ﺑﺎﺷﺪ )ﻛﻪ ﻣﻌﻨﺎﻳﺶ ﺍﻳﻦ ﺍﺳﺖ ﺩﺭ ﺭﺍﺑﻄﻪ ﺩﻳﮕﺮ ﻛﻠﻴﺪ ﺍﺻﻠﻲ‬ ‫ﺍﺳﺖ(‬ ‫ﺻﻔﺖ ﺧﺎﺻﻪ ‪:Ai‬‬ ‫‪١‬ـ ﻣﻲ ﺗﻮﺍﻧﺪ ﻫﻴﭻ ﻣﻘﺪﺍﺭ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ﺩﺭ ﻏﻴﺮ ﺍﻳﻨﺼﻮﺭﺕ‬ ‫‪٢‬ـ ﺣﺘﻤﺎ ﺑﺎﻳﺪ ﻣﻘﺪﺍﺭ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ﻛﻪ ﺩﺭ ﺭﺍﺑﻄﻪ ﺍﻱ ﻛﻪ ﺩﺭ ﺁﻧﺠﺎ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺍﺳﺖ ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫ﺑﻪ ﺭﺍﺑﻄﻪ ‪ R2‬ﺭﺍﺑﻄﻪ ﺍﺭﺟﺎﻉ ﺩﻫﻨﺪﻩ ﻳﺎ ﺭﺟﻮﻉ ﻛﻨﻨﺪﻩ ‪ Referencing‬ﻭ ﺑﻪ ﺭﺍﺑﻄﻪ ﺩﻳﮕﺮ ﺭﺍﺑﻄﻪ ﻣﺮﺟﻊ ﻳﺎ ﻣﻘﺼﺪ ﮔﻮﻳﻨﺪ‪.‬‬ ‫ﻣﺜﺎﻝ‪ sp.s# :‬ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺩﺭ ‪ Sp‬ﺍﺳﺖ‪ .‬ﻣﻘﺎﺩﻳﺮ ‪ S#‬ﺩﺭ ‪ Sp‬ﺑﺎﻳﺪ ﭼﻨﺎﻥ ﺑﺎﺷﻨﺪ ﻛﻪ ﺣﺘﻤﹰﺎ ﺑﺎﻳﺪ ﺩﺭ ‪ s‬ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ‪.‬‬ ‫ﻧﻜﺘﻪ‪ :‬ﺩﺭ ﺍﻳﻦ ﻣﺜﺎﻝ ﺧﺎﺹ ‪ S#‬ﺩﺭ ‪ Sp‬ﻧﻤﻲ ﺗﻮﺍﻧﺪ ﻣﻘﺪﺍﺭ ‪ Null‬ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ﺯﻳﺮﺍ ﺧﻮﺩ ﺟﺰﺋﻲ ﺍﺯ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺍﺳﺖ‪.‬‬ ‫•‬

‫ﺩﻟﻴﻞ ﺗﻮﺟﻴﻪ ﻛﻨﻨﺪﻩ ﻗﺎﻋﺪﻩ ﺟﺎﻣﻌﻴﺖ ﺍﺭﺟﺎﻋﻲ‪:‬‬

‫ﻧﻤﻲ ﺗﻮﺍﻥ ﺑﻪ ﻧﻤﻮﻧﻪ ﻣﻮﺟﻮﺩﻳﺘﻲ ﺍﺭﺟﺎﻉ ﺩﺍﺩ ﻛﻪ ﺩﺭ ﺟﻬﺎﻥ ﻭﺍﻗﻌﻲ ﻭﺟﻮﺩ ﻧﺪﺍﺭﺩ‪.‬‬ ‫ﺍﻳﻦ ﻗﺎﻋﺪﻩ ﺍﺯ ﻃﺮﻳﻖ ﺣﻜﻢ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﻭ ﺗﻌﺮﻳﻒ ﺭﺍﺑﻄﻪ ﺑﻪ ﺳﻴﺴﺘﻢ ﺍﻋﻼﻡ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪٣‬ـ‪٥‬ـ‪٣‬ـ ﺗﺒﻌﺎﺕ ﻗﻮﺍﻋﺪ ﺟﺎﻣﻌﻴﺖ‪:‬‬ ‫ﻗـﻮﺍﻋﺪ ﺟﺎﻣﻌﻴﺖ ﺑﺎﻳﺪ ﺩﺭ ﺗﻤﺎﻡ ﻣﺪﺕ ﺣﻴﺎﺕ ﺭﺍﺑﻄﻪ ﻫﺎﻱ ﻳﻚ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﺑﺮﻗﺮﺍﺭ ﺑﻮﺩﻩ‪ ،‬ﺭﻋﺎﻳﺖ ﺷﻮﻧﺪ ﺍﺯ ﺁﻧﺠﺎﺋﻴﻜﻪ ﺍﻳﻦ ﺩﻭ‬ ‫ﻗﺎﻋـﺪﻩ ﻧﺎﻇـﺮ ﺑﺮﻭﺿـﻌﻴﺖ ﺑﺎﻧـﻚ ﻫﺴـﺘﻨﺪ‪ .‬ﻫـﺮ ﻭﺿـﻌﻴﺘﻲ ﺍﺯ ﺑﺎﻧﻚ ﻛﻪ ﺩﺭ ﺁﻥ ﺍﻳﻦ ﻗﻮﺍﻋﺪ ﺭﻋﺎﻳﺖ ﻧﺸﺪﻩ ﺑﺎﺷﻨﺪ ﻧﺎﺻﺤﻴﺢ ﺗﻠﻘﻲ ﻣﻲ‬ ‫ﮔﺮﺩﺩ‪.‬‬ ‫ﻓﺮﺽ ﻛﻨﻴﺪ ﺩﺳﺘﻮﺭ‬

‫ﺩﺭ ﺧﻮﺍﺳﺖ ﺷﺪﻩ ﺑﺎﺷﺪ‪.‬‬

‫ﻭ ﺳﻴﺴﺘﻢ ﺑﺨﻮﺍﻫﺪ ﺗﺎﭘﻞ ‪ S2‬ﺭﺍ ﺍﺯ ‪ S‬ﺣﺬﻑ ﻛﻨﺪ ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﻗﺎﻋﺪﻩ ﺩﻭﻡ ﺧﺪﺷﻪ ﺩﺍﺭﻣﻲ ﺷﻮﺩ ﻣﮕﺮ ﺍﻳﻨﻜﻪ ﺳﻴﺴﺘﻢ ﺭﻭﺵ ﺧﺎﺻﻲ‬ ‫ﺩﺭ ﺣﻞ ﺍﻳﻦ ﻣﺸﻜﻞ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫ﺍﺭﺟﺎﻉ ‪ Sp‬ﺑﻪ ‪ S‬ﻣﺸﻜﻞ ﺧﻮﺍﻫﺪ ﺩﺍﺷﺖ ﺯﻳﺮﺍ ‪ S2‬ﻭﺟﻮﺩ ﻧﺪﺍﺭﺩ‪.‬‬ ‫‪SP‬‬

‫‪S‬ﻣﺮﺟﻊ‬

‫ﺭﺟﻮﻉ ﻛﻨﻨﺪﻩ‬

‫‪Qty‬‬

‫‪P#‬‬

‫‪S#‬‬

‫‪S#‬‬

‫‪100‬‬ ‫‪70‬‬ ‫‪200‬‬ ‫‪60‬‬

‫‪P1‬‬ ‫‪P1‬‬ ‫‪P3‬‬ ‫‪P2‬‬

‫‪S1‬‬ ‫‪S2‬‬ ‫‪S1‬‬ ‫‪S4‬‬

‫‪S1‬‬ ‫‪S2‬‬ ‫‪S3‬‬ ‫‪S4‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٤٤ /‬‬

‫ﺑﺮﺍﻱ ﺣﻔﻆ ﻗﺎﻋﺪﻩ ﺟﺎﻣﻌﻴﺖ ﺍﺭﺟﺎﻋﻲ ﭼﻬﺎﺭ ﺭﻭﺵ ﻣﺸﻬﻮﺭ ﺍﺳﺖ‪:‬‬ ‫ﺍﻟﻒ ـ ﺭﻭﺵ ‪) Restricted‬ﻣﺤﺪﻭﺩ ﺷﺪﻩ(ﻭﻳﺎ ﺣﺬﻑ ﺗﻌﻮﻳﻘﻲ‬ ‫ﺩﺭ ﺍﻳـﻦ ﺭﻭﺵ ﺍﮔـﺮ ﺩﺭﺧﻮﺍﺳـﺖ ﺣـﺬﻑ ﺗﺎﭘﻠـﻲ ﺍﺯ ﺭﺍﺑﻄﻪ ﻣﺮﺟﻊ ﺷﻮﺩ ﺗﺎ ﺯﻣﺎﻧﻴﻜﻪ ﺗﺎﭘﻠﻬﺎﻳﻲ ﺩﺭ ﺭﺍﺑﻄﻪ ﺭﺟﻮﻉ ﻛﻨﻨﺪﻩ ﻭﺟﻮﺩ ﺩﺍﺭﻧﺪ‬ ‫ﻛﻪ ﺑﻪ ﺍﻳﻦ ﺗﺎﭘﻞ ﺍﺭﺟﺎﻉ ﻣﻲ ﺩﻫﻨﺪ ﻋﻤﻞ ﺣﺬﻑ ﺍﻧﺠﺎﻡ ﻧﻤﻲ ﺷﻮﺩ‪.‬‬ ‫ﺏ ـ ﺭﻭﺵ ﺁﺑﺸﺎﺭﻱ ﻳﺎ ﺗﺴﻠﺴﻠﻲ ‪Cascaded‬‬

‫ﺩﺭ ﺍﻳﻦ ﺭﻭﺵ ﺑﺎﺣﺬﻑ ﻳﻚ ﺗﺎﭘﻞ ﺍﺯ ﺭﺍﺑﻄﻪ ﻣﺮﺟﻊ ﺗﻤﺎﻡ ﺗﺎﭘﻠﻬﺎﻱ ﺭﺟﻮﻉ ﻛﻨﻨﺪﻩ ﺑﻪ ﺁﻥ ﺗﺎﭘﻞ ﻧﻴﺰ ﺣﺬﻑ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬ ‫ﺑﻄﻮﺭ ﻣﺜﺎﻝ ﺍﮔﺮ ﺩﺭﺧﻮﺍﺳﺖ‬

‫ﺑﻴﺎﻳﺪ ﭘﺲ ﺍﺯ ﺍﺟﺮﺍﻱ ﺁﻥ ﺣﻜﻢ ﺑﺎﻳﺴﺘﻲ ﺣﻜﻢ ﺯﻳﺮ ﻧﻴﺰ ﺍﺟﺮﺍ ﺷﻮﺩ ‪:‬‬

‫ﺍﻳـﻦ ﺣﻜـﻢ ﻣﻤﻜـﻦ ﺍﺳﺖ ﺑﻄﻮﺭ ﺍﺗﻮﻣﺎﺗﻴﻚ ﺗﻮﺳﻂ ‪ D BMS‬ﺗﻮﻟﻴﺪ ﺷﻮﺩ ﻭ ﻣﻤﻜﻦ ﺍﺳﺖ ﻻﺯﻡ ﺑﺎﺷﺪ ﻃﺮﺍﺡ ﺁﻥ ﺭﺍ ﺑﻨﻮﻳﺴﺪ ﻻﺯﻡ‬ ‫ﺑﻪ ﺫﻛﺮ ﺍﺳﺖ ﺍﮔﺮ ﺩﺳﺘﻮﺭ ﺩﻭﻡ ﺭﺍ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ ﻋﻜﺲ ﺁﻥ ﺻﺎﺩﻕ ﻧﻴﺴﺖ ﻳﻌﻨﻲ ﻧﻴﺎﺯ ﺑﻪ ﺣﺬﻑ ﺩﺭ ‪ S‬ﻧﻤﻲ ﺑﺎﺷﺪ‪.‬‬ ‫ﺝ ـ ﺭﻭﺵ ﻫﻴﭻ ﻣﻘﺪﺍﺭ ﮔﺬﺍﺭﻱ ‪Nullified‬‬

‫ﺩﺭ ﺍﻳﻦ ﺭﻭﺵ ﺍﮔﺮ ﺩﺭﺧﻮﺍﺳﺖ ﺷﻮﺩ ﺗﺎﭘﻠﻲ ﺍﺯ ﺭﺍﺑﻄﻪ ﻣﺮﺟﻊ ﺣﺬﻑ ﺷﻮﺩ‪ ،‬ﺍﻳﻦ ﺣﺬﻑ ﺍﻧﺠﺎﻡ ﻣﻲ ﺷﻮﺩ ﺍﻣﺎ ﺩﺭ ﭘﻲ ﺁﻥ ﻣﻘﺪﺍﺭ ﻛﻠﻴﺪ‬ ‫ﺧﺎﺭﺟﻲ ﺩﺭ ﺭﺍﺑﻄﻪ ﺍﺭﺟﺎﻉ ﺩﻫﻨﺪﻩ ‪ NULL‬ﮔﺬﺍﺷﺘﻪ ﻣﻲ ﺷﻮﺩ‪) .‬ﺑﺸﺮﻁ ﺍﻳﻨﻜﻪ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺟﺰ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻧﺒﺎﺷﺪ(‬

‫ﻣﺜﺎﻝ‪:‬‬ ‫‪Delete From S‬‬ ‫’‪Where S# = ‘S2‬‬ ‫‪Update SP‬‬ ‫‪Set S# = Null‬‬ ‫’‪Where S# = ‘S2‬‬

‫ﺗﻮﺟﻪ ‪ :‬ﺩﺭ ﻣﺜﺎﻝ ﺑﺎﻻ ﻧﻤﻲ ﺗﻮﺍﻥ ﺭﻭﺵ ﻫﻴﭻ ﻣﻘﺪﺍﺭﮔﺬﺍﺭﻱ ﺭﺍ ﺍﻧﺠﺎﻡ ﺩﺍﺩ ﺯﻳﺮﺍ ‪ S #‬ﺩﺭ ‪ SP‬ﺟﺰ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺍﺳﺖ‪.‬‬ ‫ﻧﻜﺘﻪ ‪ :‬ﺑﻪ ﻣﺠﻤﻮﻋﻪ ﺟﺪﺍﻭﻝ ﻭ ﺗﻌﺎﺭﻳﻒ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻭ ﻛﻠﻴﺪﻫﺎﻱ ﺩﻳﮕﺮ ﻭ ﻣﺤﺪﻭﺩﻳﺘﻬﺎ ﻧﻴﺰ ﺷﻤﺎﻱ ﺭﺍﺑﻄﻪ ﮔﻔﺘﻪ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺩ ـ ﺭﻭﺵ ﻣﻘﺪﺍﺭﮔﺬﺍﺭﻱ ﺑﺎ ﻣﻘﺪﺍﺭ ﭘﻴﺶ ﻓﺮﺽ ‪SET TO DEFAULT‬‬ ‫ﺩﺭ ﺍﻳـﻦ ﺭﻭﺵ ‪ ،‬ﺑـﺎ ﺣـﺬﻑ ﺗﺎﭘﻞ ﻣﺮﺟﻊ ‪ ،‬ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ ﺩﺭ ﺗﺎﭘﻞ ﻫﺎﻱ ﺭﺟﻮﻉ ﻛﻨﻨﺪﻩ ﺑﻪ ﺁﻥ ﺑﺎ ﻣﻘﺪﺍﺭ ﭘﻴﺶ ﻓﺮﺽ ﻣﻘﺪﺍﺭﮔﺬﺍﺭﻱ‬ ‫ﻣﻴﺸﻮﺩ‪.‬‬ ‫‪٣‬ـ‪٥‬ـ‪٤‬ـ ﺭﺍﻫﻬﺎﻱ ﺍﻋﻤﺎﻝ ﻗﻮﺍﻋﺪ ﺟﺎﻣﻌﻴﺖ ‪:‬‬ ‫ﺑﻄﻮﺭ ﻛﻠﻲ ﻣﻴﺘﻮﺍﻥ ﺭﺍﻫﻬﺎﻱ ﺍﻋﻤﺎﻝ ﻗﻮﺍﻋﺪ ﺟﺎﻣﻌﻴﺖ ﺭﺍ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﻧﺎﻡ ﺑﺮﺩ ‪:‬‬ ‫‪ -١‬ﻣﻌﺮﻓﻲ ﻛﻠﻴﺪ ﺍﺻﻠﻲ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٤٥ /‬‬

‫‪ -٢‬ﺍﻋﻼﻡ ﺻﻔﺖ ﻫﻴﭽﻤﻘﺪﺍﺭ ﻧﺎﭘﺬﻳﺮ‬ ‫‪ -٣‬ﻣﻌﺮﻓﻲ ﻛﻠﻴﺪ ﺧﺎﺭﺟﻲ‬ ‫‪ -٤‬ﺍﻋﻼﻥ ﻣﺤﺪﻭﺩﻳﺘﻬﺎﻱ ﻣﻮﺭﺩ ﻧﻈﺮ ﺩﺭ ﺷﻤﺎﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ‬ ‫‪ -٥‬ﻧﻮﺷﺘﻦ ﺭﺍﻩ ﺍﻧﺪﺍﺯ )‪(Trigger‬‬ ‫ﺭﺍﻩ ﺍﻧـﺪﺍﺯ ﻣﻜﺎﻧﻴﺴـﻤﻲ ﺍﺳـﺖ ﺑـﺮﺍﻱ ﺭﺍﻩ ﺍﻧﺪﺍﺯﻱ ﺍﺟﺮﺍﻱ ﻳﻚ ﻋﻤﻞ ﺩﺭ ﭘﻲ ﺍﻧﺠﺎﻡ ﻳﻚ ﻋﻤﻞ ﺩﻳﮕﺮ ‪ .‬ﺑﻪ ﺑﻴﺎﻥ ﺩﻳﮕﺮ ﺩﺭﺻﻮﺭﺕ‬ ‫ﺑـﺮﻭﺯ ﻳـﻚ ﺭﻭﻳﺪﺍﺩ ‪ ،‬ﻋﻤﻠﻲ ﺑﺎﻳﺪ ﺍﻧﺠﺎﻡ ﺷﻮﺩ ﺗﺎ ﺳﺎﺯﮔﺎﺭﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺗﺎﻣﻴﻦ ﮔﺮﺩﺩ‪.‬ﻣﺜﻼ ﺩﺭ ﭘﻲ ﺍﻧﺠﺎﻡ ﻳﻚ ﻋﻤﻞ ﺑﻬﻨﮕﺎﻡ ﺳﺎﺯﻱ‬ ‫ﺩﺭ ﺗﺎﭘﻠﻲ ﺍﺯ ﻳﻚ ﺭﺍﺑﻄﻪ ‪ ،‬ﺗﺎﭘﻞ)ﻫﺎﻳﻲ( ﺍﺯ ﺭﺍﺑﻄﻪ ﻫﺎﻱ ﺩﻳﮕﺮ ﻧﻴﺰ ﺑﻬﻨﮕﺎﻡ ﺩﺭ ﻣﻲ ﺁﻳﻨﺪ‪.‬‬ ‫‪ -٦‬ﻣﻌﺮﻓﻲ ﻣﻴﺪﺍﻥ ﻭ ﻣﻘﺎﺩﻳﺮ ﺁﻥ‬ ‫‪ -٧‬ﻣﻌﺮﻓﻲ ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ ﺗﺎﺑﻌﻲ ﺑﻴﻦ ﺻﻔﺎﺕ ﺧﺎﺻﻪ )ﺑﻪ ﻓﺼﻞ ﻫﻔﺘﻢ ﻣﺮﺍﺟﻌﻪ ﺷﻮﺩ (‪.‬‬ ‫‪٣‬ـ‪ -٦‬ﻣﺸﺨﺼﺎﺕ ﺳﻴﺴﺘﻢ ﻫﺎﻱ ﺭﺍﺑﻄﻪ ﺍﻱ‪:‬‬ ‫ﺩﺭﺟﻪ ﻳﺎ ﻣﻴﺰﺍﻥ ﻳﺎ ﺣﺪ ﺭﺍﺑﻄﻪ ﺑﻮﺩﻥ ﺳﻴﺴﺘﻤﻬﺎﻱ ﺭﺍﺑﻄﻪ ﺍﻱ ﻣﺘﻔﺎﻭﺕ ﺍﺳﺖ‪ .‬ﺍﺯ ﻧﻈﺮ ‪ C ODD‬ﺳﻴﺴﺘﻤﻲ ﺩﺭ ﺣﺪﺍﻗﻞ ﺭﺍﺑﻄﻪ ﺍﻱ ﺍﺳﺖ‪.‬‬ ‫ﺍﮔﺮ ‪:‬‬ ‫‪١‬ـ ﭘﺎﻳﮕﺎﻩ ﺟﺪﻭﻟﻲ ﺭﺍ ﺑﺮﺍﻱ ﻛﺎﺭﺑﺮ ﺗﺎﻣﻴﻦ ﻛﻨﺪ‪.‬‬ ‫‪٢‬ـ ﺳﻪ ﻋﻤﻞ ﺍﺳﺎﺳﻲ ﺍﺯ ﻋﻤﻠﻴﺎﺕ ﺩﺭ ﺭﺍﺑﻄﻪ ﻫﺎ ﺭﺍ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪ :‬ﻋﻤﻞ ﮔﺰﻳﻨﺶ ﻳﺎ ﺗﺤﺪﻳﺪ ‪ ،‬ﻋﻤﻞ ﭘﺮﺗﻮ ﻭ ﻋﻤﻞ ﭘﻴﻮﻧﺪ‬ ‫ﻼ ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﺎﻳﺪ ﺧﺼﻮﺻﻴﺎﺕ ﺯﻳﺮ ﺭﺍ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪:‬‬ ‫ﺍﻣﺎ ﻳﻚ ﺳﻴﺴﺘﻢ ﻛﺎﻣ ﹰ‬ ‫‪١‬ـ ﭘﺎﻳﮕﺎﻩ ﺭﺍﺑﻄﻪ ﺍﻱ ﺭﺍ ﺍﻳﺠﺎﺩ ﻛﻨﺪ‪ :‬ﺍﻣﻜﺎﻧﺎﺕ ﻛﺎﻣﻞ ﺗﻌﺮﻳﻒ ﺍﻧﻮﺍﻉ ﺭﺍﺑﻄﻪ ﻫﺎ ﺭﺍ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫‪٢‬ـ ﺍﻣﻜﺎﻧﺎﺕ ﻛﺎﻣﻞ ‪ DML‬ﺭﺍﺑﻄﻪ ﺍﻱ‬ ‫‪٣‬ـ ﺍﻣﻜﺎﻥ ﺗﻌﺮﻳﻒ ﻣﺠﻤﻮﻋﻪ ﻛﺎﻣﻠﻲ ﺍﺯ ﻗﻮﺍﻧﻴﻦ ﺟﺎﻣﻌﻴﺖ ﺑﺸﺮﺡ ﺩﻳﺪﻩ ﺷﺪﻩ ﺭﺍ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫•‬

‫ﻳﻚ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺭﺍﺑﻄﻪ ﺍﻱ ﺩﺍﺭﺍﻱ ﺳﻪ ﻣﺆﻟﻔﻪ ﺍﺳﺎﺳﻲ ﺍﺳﺖ ‪:‬‬

‫‪ Objects -١‬ﺍﺯ ﻧﻈﺮ ﺳﺎﺧﺘﺎﺭﻱ ﺭﺍﺑﻄﻪ ﺍﻧﺪ‬ ‫‪ Operators -٢‬ﻋﻤﻠﮕﺮﻫﺎﻱ ﺭﺍﺑﻄﻪ ﺍﻱ‬ ‫‪ Rules -٣‬ﻗﻮﺍﻧﻴﻦ ﺟﺎﻣﻌﻴﺖ‬ ‫ﺗﻤﺮﻳﻦ ‪:‬‬ ‫‪ -١‬ﻧﺤﻮﻩ ﺗﻌﺮﻳﻒ ﺍﻧﻮﺍﻉ ﻛﻠﻴﺪ ﺭﺍ ﺩﺭ ﻳﻚ ﺳﻴﺴﺘﻢ ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﺮﺭﺳﻲ ﻧﻤﺎﻳﻴﺪ ‪:‬‬ ‫‪ -٢‬ﺭﺍﻫﻬﺎﻱ ﻗﻮﺍﻋﺪ ﺟﺎﻣﻌﻴﺖ ﺭﺍ ﺩﺭ ﻳﻚ ﺳﻴﺴﺘﻢ ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﺮﺭﺳﻲ ﻧﻤﺎﻳﻴﺪ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٤٦ /‬‬

‫ﻓﺼﻞ ﭼﻬﺎﺭﻡ ‪ :‬ﻣﺪﻝ ﺭﺍﺑﻄﻪ ﺍﻱ ‪-‬ﻋﻤﻠﻴﺎﺕ ﺭﻭﻱ ﺭﺍﺑﻄﻪ ﻫﺎ‬ ‫‪ -١-٤‬ﻣﻘﺪﻣﻪ ‪:‬‬ ‫ﺯﺑﺎﻥ ﻛﺎﺭ ﺑﺎ ﺩﺍﺩﻩ ﻫﺎ ﺩﺍﺭﺍﻱ ﻣﺠﻤﻮﻋﻪ ﺍﻳﺴﺖ ﺍﺯ ﻋﻤﻠﮕﺮﻫﺎ ﻛﻪ ﺩﺭ ﻛﺎﺩﺭ ﻣﺪﻝ ﺩﺍﺩﻩ ﺍﻱ ﻋﻤﻞ ﻣﻲ ﻛﻨﻨﺪ ‪ .‬ﺩﺭ ﺳﻴﺴﺘﻢ ﺑﺎﻧﻚ ﺭﺍﺑﻄﻪ‬ ‫ﺍﻱ ﻋﻤﻠﮕﺮﻫﺎﻱ ﻋﻤﻞ ﻛﻨﻨﺪﻩ ﺭﻭﻱ ﺭﺍﺑﻄﻪ ﻋﻤﻠﮕﺮﻫﺎﻱ ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﻭ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﻣﻲ ﺑﺎﺷﻨﺪ‪.‬‬ ‫‪٤‬ـ‪ -٢‬ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ‪:‬‬ ‫‪ Codd‬ﺩﺭ ﻣﻘﺎﻟﻪ ﺧﻮﺩ ‪ ٨‬ﻋﻤﻠﮕﺮ ﺑﺮﺍﻱ ﻛﺎﺭ ﺑﺎ ﺭﺍﺑﻄﻪ ﻫﺎ ﺗﻌﺮﻳﻒ ﻛﺮﺩﻩ ﺍﺳﺖ ﻛﻪ ﺍﻳﻦ ﻋﻤﻠﮕﺮﻫﺎ ﺑﻪ ﺩﻭ ﺩﺳﺘﻪ ﺗﻘﺴﻴﻢ ﻣﻲ ﺷﻮﻧﺪ‪:‬‬ ‫ﺍﻟﻒ‪ :‬ﻋﻤﻠﮕﺮﻫﺎﻱ ﻣﺘﻌﺎﺭﻑ ﺩﺭ ﻣﺠﻤﻮﻋﻪ ﻫﺎ ﻧﻈﻴﺮ‪ :‬ﺍﺟﺘﻤﺎﻉ ‪ ،‬ﺍﺷﺘﺮﺍﻙ ‪ ،‬ﺗﻔﺎﺿﻞ ﻭ ﺿﺮﺏ ﺩﻛﺎﺭﺗﻲ‬ ‫ﺏ‪ :‬ﻋﻤﻠﮕﺮﻫﺎﻱ ﺧﺎﺹ ﻧﻈﻴﺮ‪ :‬ﻣﺤﺪﻭﺩﻳﺖ ‪ ،‬ﺗﺼﻮﻳﺮ ﻳﺎ ﭘﺮﺗﻮ ‪ ،‬ﺗﺮﻛﻴﺐ ﻳﺎ ﭘﻴﻮﻧﺪ ﻭ ﺗﻘﺴﻴﻢ‬ ‫‪ -١ -٢-٤‬ﻋﻤﻠﮕﺮ ﮔﺰﻳﻨﺶ ﻳﺎ ﺗﺤﺪﻳﺪ )‪(Select‬‬

‫ﺍﻳﻦ ﻋﻤﻠﮕﺮ ﺗﺎﭘﻠﻬﺎﻳﻲ ﺭﺍ ﺍﺯ ﻳﻚ ﺭﺍﺑﻄﻪ ﮔﺰﻳﻨﺶ ﻣﻲ ﻛﻨﺪ‪ .‬ﺑﻌﺒﺎﺭﺗﻲ ﺯﻳﺮ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﻓﻘﻲ ﺍﺯ ﻳﻚ ﺭﺍﺑﻄﻪ ﺭﺍ ﺑﺮ ﻣﻲ ﺩﺍﺭﺩ‪ .‬ﮔﺰﻳﻨﺶ‬ ‫ﻻ ﺑﺮ ﺍﺳﺎﺱ ﺷﺮﻁ ﻳﺎ ﺷﺮﺍﻳﻄﻲ ﺻﻮﺭﺕ ﻣﻲ ﭘﺬﻳﺮﺩ‪.‬‬ ‫ﺗﺎﭘﻞ ﻳﺎ ﺗﺎﭘﻠﻬﺎﻳﻲ ﺍﺯ ﺭﺍﺑﻄﻪ‪ ،‬ﻣﻌﻤﻮ ﹰ‬ ‫•‬

‫ﻧﻤﺎﺩ ﺗﺤﺪﻳﺪ ‪бp( r ) :‬‬

‫•‬

‫‪ P‬ﺷﺮﻁ ﮔﺰﻳﻨﺶ ﺍﺳﺖ ‪ r ،‬ﺭﺍﺑﻄﻪ )ﺟﺪﻭﻝ(‬

‫•‬ ‫ﻛﻪ ‪ p‬ﻓﺮﻣﻮﻟﻲ ﻣﺤﺎﺳﺒﺎﺗﻲ ﺍﺳﺖ ﺷﺎﻣﻞ ‪ not ،Or،and‬ﻳﺎ ﻫﺮ ﻳﻚ ﺍﺯ ﺟﻤﻼﺕ ﺑﻔﺮﻡ ‪:‬‬ ‫})‪p(t‬‬

‫‪бp( r ) = {t | t∈r and‬‬

‫>‪ opor< constant‬ﻛﻪ ‪ op‬ﻳﻜﻲ ﺍﺯ = ‪، ≤ ،≥ ، <، > ، #،‬ﺍﺳﺖ‪.‬‬ ‫‪D‬‬

‫‪C‬‬

‫‪7‬‬ ‫‪10‬‬

‫‪1‬‬ ‫‪23‬‬

‫‪B‬‬ ‫‪α‬‬ ‫‪β‬‬

‫‪A‬‬

‫‪D‬‬

‫‪C‬‬

‫‪B‬‬

‫‪A‬‬

‫‪α‬‬ ‫‪β‬‬

‫‪7‬‬ ‫‪17‬‬

‫‪1‬‬ ‫‪5‬‬

‫‪α‬‬ ‫‪β‬‬

‫‪α‬‬ ‫‪α‬‬

‫‪12‬‬ ‫‪β‬‬ ‫‪Relation r:‬‬

‫‪β‬‬

‫‪10‬‬ ‫)‪бA = B ∧ D > 5 (r‬‬

‫‪٢-٤‬ـ‪ ٢‬ﻋﻤﻠﮕﺮ ﭘﺮﺗﻮ ‪Project‬‬

‫ﺍﻳـﻦ ﻋﻤﻠﮕـﺮ ﺯﻳـﺮ ﻣﺠﻤـﻮﻋﻪ ﺍﻱ ﻋﻤـﻮﺩﻱ ﺍﺯ ﻳﻚ ﺭﺍﺑﻄﻪ ﺭﺍ ﺍﺳﺘﺨﺮﺍﺝ ﻣﻲ ﻛﻨﺪ ﺻﻔﺎﺕ ﺧﺎﺻﻪ )ﺳﺘﻮﻧﻬﺎﻱ( ﭘﺎﺳﺦ ﺍﻋﻤﺎﻝ ﻋﻤﻠﮕﺮ‬ ‫ﺩﺍﺭﺍﻱ ﺗﺮﺗﻴﺒﻲ ﻫﺴﺘﻨﺪ ﻛﻪ ﺩﺭ ﻋﻤﻠﮕﺮ ﻣﺸﺨﺺ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫•‬

‫ﻧﻤﺎﺩ ﻋﻤﻠﮕﺮ‬

‫•‬

‫ﻧﺘـﻴﺠﻪ ﺑﻌـﻨﻮﺍﻥ ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﺎ ‪ K‬ﺳﺘﻮﻥ ﺗﻌﺮﻳﻒ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﺑﺎ ﺣﺬﻑ ﺳﺘﻮﻧﻬﺎﻳﻲ ﻛﻪ ﺩﺭ ﻟﻴﺴﺖ ﻗﺮﺍﺭ ﻧﺪﺍﺭﻧﺪ ﺑﺪﺳﺖ ﺁﻣﺪﻩ‬

‫) ‪(r‬‬

‫‪ π A , A ,... A‬ﻛﻪ ‪ ... A2 , A1‬ﺍﺳﺎﻣﻲ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻭ ‪ r‬ﻧﺎﻡ ﺭﺍﺑﻄﻪ ﺍﺳﺖ‬

‫‪K‬‬

‫‪2‬‬

‫‪1‬‬

‫ﺍﺳﺖ‪.‬‬ ‫•‬

‫ﺳﻄﺮﻫﺎﻱ ﺗﻜﺮﺍﺭﻱ ﺍﺯ ﻧﺘﻴﺠﻪ ﺣﺬﻑ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬

‫•‬

‫ﻣﺜﺎﻝ ‪:‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫‪C‬‬

‫‪A‬‬

‫‪C‬‬

‫‪A‬‬

‫‪1‬‬ ‫‪1‬‬ ‫‪2‬‬

‫‪α‬‬ ‫‪β‬‬ ‫‪β‬‬

‫‪1‬‬ ‫‪1‬‬ ‫‪1‬‬ ‫‪2‬‬

‫‪α‬‬ ‫‪α‬‬ ‫‪β‬‬ ‫‪β‬‬

‫=‬

‫)‪∏ A,C (r‬‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٤٧ /‬‬ ‫‪C‬‬

‫‪B‬‬

‫‪A‬‬

‫‪1‬‬ ‫‪1‬‬ ‫‪1‬‬ ‫‪2‬‬

‫‪10‬‬ ‫‪20‬‬ ‫‪30‬‬ ‫‪40‬‬

‫‪α‬‬ ‫‪α‬‬ ‫‪β‬‬ ‫‪β‬‬

‫‪٤‬ـ‪٢‬ـ‪٣‬ـ ﻋﻤﻠﮕﺮ ﺍﺟﺘﻤﺎﻉ ‪union‬‬

‫‪R1‬‬

‫ﺍﺟﺘﻤﺎﻉ ﺩﻭ ﺭﺍﺑﻄﻪ ﺭﺍﺑﻄﻪ ﺍﻳﺴﺖ ﻛﻪ ﺗﺎﭘﻠﻬﺎﻳﺶ ﺩﺭ ﻳﻚ ﻳﺎ ﻫﺮ ﺩﻭ ﺭﺍﺑﻄﻪ ﻭﺟﻮﺩ ﺩﺍﺭﻧﺪ‪.‬‬ ‫‪R2‬‬

‫‪R = R1 union R2‬‬

‫•‬

‫ﻧﻤﺎﺩ ﻋﻤﻠﮕﺮ‪:‬‬

‫•‬ ‫•‬

‫}‪r ∪ s = {t | t∈r or t∈s‬‬ ‫‪ r ∪ s‬ﻣﻮﻗﻌﻲ ﻣﻌﺘﺒﺮ ﺍﺳﺖ ﻛﻪ ‪:‬‬

‫‪r∪s‬‬

‫‪١‬ـ ‪ r,s‬ﺑﺎﻳﺴﺘﻲ ﺗﻌﺪﺍﺩ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺑﺮﺍﺑﺮ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ‪.‬‬ ‫‪٢‬ــ ﺣـﻮﺯﻩ )ﻣـﻴﺪﺍﻥ ( ﺻـﻔﺎﺕ ﺧﺎﺻـﻪ ﺩﻭ ﻣﺠﻤﻮﻋﻪ ﺑﺎﻳﺴﺘﻲ ﺳﺎﺯﮔﺎﺭ ﺑﺎﺷﻨﺪ‪ .‬ﺑﻌﻨﻮﺍﻥ ﻣﺜﺎﻝ ﺻﻔﺖ ﺧﺎﺻﻪ ‪ i‬ﺍﻡ ﺍﺯ ﻫﺮ ﺩﻭ‬ ‫ﺭﺍﺑﻄﻪ ﻳﻜﺴﺎﻥ ﺑﺎﺷﻨﺪ‪.‬‬ ‫ﻣﺜﺎﻝ‪:‬‬ ‫‪B‬‬

‫‪A‬‬

‫‪1‬‬ ‫‪2‬‬ ‫‪1‬‬ ‫‪3‬‬

‫‪α‬‬ ‫‪α‬‬ ‫‪β‬‬ ‫‪β‬‬

‫‪r∪s:‬‬

‫‪B‬‬

‫‪A‬‬

‫‪B‬‬

‫‪A‬‬

‫‪2‬‬ ‫‪3‬‬

‫‪α‬‬ ‫‪β‬‬

‫‪1‬‬ ‫‪2‬‬ ‫‪1‬‬

‫‪α‬‬ ‫‪α‬‬ ‫‪β‬‬

‫‪s‬‬

‫‪Relation r,s‬‬

‫‪r‬‬ ‫‪R1‬‬

‫‪ : ٤-٢-٤‬ﺍﺷﺘﺮﺍﻙ‬

‫‪R2‬‬

‫‪Intersect‬‬

‫ﺍﺷﺘﺮﺍﻙ ﺩﻭ ﺭﺍﺑﻄﻪ‪،‬ﺭﺍﺑﻄﻪ ﺍﻳﺴﺖ ﻛﻪ ﺗﺎﭘﻠﻬﺎﻳﺶ ﺩﺭ ﻫﺮ ﺩﻭ ﺭﺍﺑﻄﻪ ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ‬ ‫•‬

‫ﻧﻤﺎﺩ‬

‫•‬ ‫•‬

‫}‪t∈s‬‬ ‫‪ s‬ﻭ ‪ r‬ﺑﺎﻳﺪ ﺍﺯ ﻧﻈﺮ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺑﺮﺍﺑﺮ ﻭ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻣﺘﻨﺎﻇﺮ ﺍﺯ ﻳﻚ ﻣﻴﺪﺍﻥ ﺑﺮ ﮔﺮﻓﺘﻪ ﺷﻮﻧﺪ‬

‫‪B‬‬

‫‪r∩s‬‬ ‫‪and‬‬

‫‪R = R1 ∩ R2‬‬ ‫‪r ∩ s = {t | t ∈ r‬‬

‫‪A‬‬

‫‪B‬‬

‫‪A‬‬

‫‪B‬‬

‫‪A‬‬

‫‪1‬‬ ‫‪α‬‬ ‫‪r1 ∩ r2‬‬

‫‪1‬‬ ‫‪3‬‬

‫‪α‬‬ ‫‪β‬‬

‫‪1‬‬ ‫‪2‬‬ ‫‪1‬‬

‫‪α‬‬ ‫‪α‬‬ ‫‪β‬‬

‫‪r2‬‬

‫‪r1‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٤٨ /‬‬

‫‪set difference‬‬

‫‪ : ٥-٢-٤‬ﻋﻤﻠﮕﺮ ﺗﻔﺎﺿﻞ ‪:‬‬

‫ﺗﻔﺎﺿﻞ ﺩﻭ ﺭﺍﺑﻄﻪ ‪ ،‬ﺭﺍﺑﻄﻪ ﺍﻳﺴﺖ ﻛﻪ ﺗﺎﭘﻠﻬﺎﻳﺶ ﺩﺭ ﺭﺍﺑﻄﻪ ﺍﻭﻝ ﻣﻮﺟﻮﺩ ﺑﺎﺷﻨﺪ ﻭ ﺩﺭ ﺭﺍﺑﻄﻪ ﺩﻭﻡ ﻭﺟﻮﺩ ﻧﺪﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ ‪R1 .‬‬ ‫‪r–s‬‬

‫ﻧﻤﺎﺩ ‪:‬‬

‫‪R2‬‬

‫•‬

‫ﺗﻌﺮﻳﻒ ﻋﻤﻠﮕﺮ ‪t ∉ s } :‬‬

‫•‬

‫ﺍﺧﺘﻼﻑ ﺩﻭ ﻣﺠﻤﻮﻋﻪ ﺑﻴﻦ ﺩﻭ ﻣﺠﻤﻮﻋﻪ ﺳﺎﺯﮔﺎﺭ ﺍﻧﺠﺎﻡ ﻣﻲ ﺷﻮﺩ ‪ s .‬ﻭ ‪ r‬ﺑﺎﻳﺪ ﺩﺍﺭﺍﻱ ﺳﺘﻮﻧﻬﺎﻱ ﻳﻜﺴﺎﻥ ﺑﺎﺷﻨﺪ‪.‬‬

‫•‬

‫ﻣﺜﺎﻝ ‪:‬‬

‫‪r - s = {t | t ∈ r‬‬

‫‪and‬‬

‫‪B‬‬

‫‪A‬‬

‫‪B‬‬

‫‪A‬‬

‫‪B‬‬

‫‪A‬‬

‫‪1‬‬ ‫‪1‬‬

‫‪α‬‬ ‫‪β‬‬

‫‪2‬‬ ‫‪3‬‬

‫‪α‬‬ ‫‪β‬‬

‫‪1‬‬ ‫‪2‬‬

‫‪α‬‬ ‫‪α‬‬

‫‪1‬‬

‫‪β‬‬

‫‪s‬‬

‫‪r–s‬‬

‫‪r‬‬ ‫‪Cartesian Product‬‬

‫‪ : ٦-٢-٤‬ﺣﺎﺻﻠﻀﺮﺏ ﻛﺎﺭﺗﺰﻳﻦ ‪:‬‬

‫ﺣﺎﺻﻞ ﺭﺍﺑﻄﻪ ﺍﻳﺴﺖ ﺣﺎﻭﻱ ﺗﺮﻛﻴﺐ ﻫﺎﻱ ﻣﻤﻜﻦ ﺗﺎﭘﻠﻬﺎﻱ ﺩﻭ ﺭﺍﺑﻄﻪ ﻛﻪ ﺑﺎﻳﺪ ﺩﺭ ﻫﻢ ﺿﺮﺏ ﺷﻮﻧﺪ ‪.‬‬ ‫•‬

‫ﻧﻤﺎﺩ ﻋﻤﻠﮕﺮ ‪:‬‬

‫•‬

‫ﺗﻌﺮﻳﻒ ﻋﻤﻠﮕﺮ ‪:‬‬

‫•‬

‫ﻓﺮﺽ ﻣﻲ ﺷﻮﺩ ﺻﻔﺎﺕ ﺧﺎﺻﻪ )‪ r(R‬ﻭ )‪ s(S‬ﻣﺠﺰﺍ ﺑﺎﺷﻨﺪ‬

‫•‬

‫ﺍﮔﺮ ﺻﻔﺎﺕ ﺧﺎﺻﻪ )‪ r(R‬ﻭ )‪ s(S‬ﻣﺠﺰﺍ ﻧﺒﺎﺷﻨﺪ ﺗﻐﻴﻴﺮ ﻧﺎﻡ ﺑﺎﻳﺴﺘﻲ ﺻﻮﺭﺕ ﭘﺬﻳﺮﺩ ‪.‬‬

‫•‬

‫ﻣﺜﺎﻝ ‪:‬‬

‫‪E‬‬

‫‪r×s‬‬ ‫} ‪r × s = {(t,q) | t ∈ r and q ∈ s‬‬

‫‪D‬‬

‫‪C‬‬

‫‪B‬‬

‫‪A‬‬

‫‪a‬‬ ‫‪a‬‬ ‫‪b‬‬

‫‪10‬‬ ‫‪10‬‬ ‫‪10‬‬

‫‪α‬‬ ‫‪β‬‬ ‫‪γ‬‬

‫‪1‬‬ ‫‪1‬‬ ‫‪1‬‬

‫‪α‬‬ ‫‪α‬‬ ‫‪α‬‬

‫‪a‬‬ ‫‪a‬‬ ‫‪b‬‬

‫‪10‬‬ ‫‪10‬‬ ‫‪10‬‬

‫‪α‬‬ ‫‪β‬‬ ‫‪γ‬‬

‫‪2‬‬ ‫‪2‬‬ ‫‪2‬‬

‫‪β‬‬ ‫‪β‬‬ ‫‪β‬‬

‫‪ : ٧-٢-٤‬ﺗﺮﻛﻴﺐ )ﭘﻴﻮﻧﺪ(‬

‫‪E‬‬

‫‪r×s:‬‬

‫‪a‬‬ ‫‪a‬‬ ‫‪b‬‬

‫∅ = ‪R ∩S‬‬

‫‪D‬‬

‫‪C‬‬

‫‪10‬‬ ‫‪10‬‬ ‫‪10‬‬

‫‪α‬‬ ‫‪β‬‬ ‫‪γ‬‬

‫‪A‬‬

‫‪B‬‬

‫‪α‬‬ ‫‪β‬‬

‫‪1‬‬ ‫‪2‬‬

‫‪r‬‬

‫‪S‬‬

‫‪join‬‬

‫)‪(Natural join‬‬

‫ﺣﺎﺻﻞ ﺭﺍﺑﻄﻪ ﺍﻱ ﺍﺳﺖ ﻛﻪ ﺗﺎﭘﻠﻬﺎﻱ ﺁﻥ ﺍﺯ ﭘﻴﻮﻧﺪ )ﺗﺮﻛﻴﺐ( ﺗﺎﭘﻠﻬﺎﻳﻲ ﺍﺯ ﺩﻭ ﺭﺍﺑﻄﻪ ﺑﺪﺳﺖ ﻣﻲ ﺁﻳﺪ ﺑﺸﺮﻁ ﺗﺴﺎﻭﻱ ﻣﻘﺎﺩﻳﺮ ﻳﻚ ﻳﺎ‬ ‫ﺑﻴﺶ ﺍﺯ ﻳﻚ ﺻﻔﺖ ﺧﺎﺻﻪ ‪.‬‬ ‫•‬

‫ﻧﻤﺎﺩ ﻋﻤﻠﮕﺮ ‪:‬‬

‫‪r ∞s‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫•‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٤٩ /‬‬

‫ﻓـﺮﺽ ‪ r‬ﺭﺍﺑﻄﻪ ﺭﻭﻱ ﺍﺳﻜﻴﻤﺎﻱ ‪ R‬ﻭ ‪ s‬ﺭﺍﺑﻄﻪ ﺍﻱ ﺭﻭﻱ ﺍﺳﻜﻴﻤﺎﻱ ‪ S‬ﺑﺎﺷﺪ ‪.‬ﻧﺘﻴﺠﻪ ﺭﺍﺑﻄﻪ ﺍﻱ ﺩﺭ ﺍﺳﻜﻴﻤﺎﻱ ‪ R ∪ S‬ﺍﺳﺖ‬ ‫ﻛﻪ ﺑﺎ ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺘﻦ ﻫﺮ ﺟﻔﺖ ﺗﺎﭘﻞ ‪ tr‬ﺍﺯ ‪ r‬ﻭ ‪ ts‬ﺍﺯ ‪ s‬ﺑﺪﺳﺖ ﻣﻲ ﺁﻳﺪ ‪.‬‬

‫•‬

‫ﺍﮔـﺮ ‪ tr‬ﻭ‪ ts‬ﺩﺍﺭﺍﻱ ﻣﻘﺎﺩﻳـﺮ ﻳﻜﺴـﺎﻥ ﺩﺭ ﻫـﺮ ﻳﻚ ﺍﺯ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ‪ R ∩S‬ﺑﺎﺷﻨﺪ ﻳﻚ ﺗﺎﭘﻞ ‪ t‬ﺑﻪ ﻧﺘﻴﺠﻪ ﺍﺿﺎﻓﻪ ﻣﻴﺸﻮﺩ‬ ‫ﺑﻄﻮﺭﻳﻜﻪ ‪ t :‬ﻫﻤﺎﻥ ﻣﻘﺎﺩﻳﺮ ‪ tr‬ﺩﺭ ‪ r‬ﻭ ‪ ts‬ﺩﺭ ‪ s‬ﺭﺍﺩﺍﺭﺩ‪.‬‬ ‫)‪R = (A,B,C,D‬‬

‫ﻣﺜﺎﻝ ‪:‬‬

‫)‪S = (E,B,D‬‬ ‫)‪ == (A,B,C,D,E‬ﺍﺳﻜﻴﻤﺎﻱ ﻧﺘﻴﺠﻪ‬

‫‪ r ∞ s‬ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺗﻌﺮﻳﻒ ﻣﻴﺸﻮﺩ ‪:‬‬

‫•‬

‫) )‪( r × s‬‬

‫‪r.D = s.D‬‬

‫‪and‬‬

‫‪∏ r.A,r.B,r.C,r.D,s.E (бr.B = s.B‬‬

‫ﻣﺜﺎﻝ ‪:‬‬ ‫‪E‬‬

‫‪C D‬‬

‫‪B‬‬

‫‪A‬‬

‫‪E‬‬

‫‪D‬‬

‫‪B‬‬

‫‪D‬‬

‫‪C‬‬

‫‪B‬‬

‫‪A‬‬

‫‪α‬‬ ‫‪γ‬‬ ‫‪α‬‬ ‫‪γ‬‬ ‫‪δ‬‬

‫‪α‬‬ ‫‪α‬‬ ‫‪γ‬‬ ‫‪γ‬‬ ‫‪β‬‬

‫‪1‬‬ ‫‪1‬‬ ‫‪1‬‬ ‫‪1‬‬ ‫‪2‬‬

‫‪α‬‬ ‫‪α‬‬ ‫‪α‬‬ ‫‪α‬‬ ‫‪δ‬‬

‫‪α‬‬ ‫‪β‬‬ ‫‪γ‬‬ ‫‪δ‬‬ ‫‪ε‬‬

‫‪a‬‬ ‫‪a‬‬ ‫‪a‬‬ ‫‪b‬‬ ‫‪b‬‬

‫‪1‬‬ ‫‪3‬‬ ‫‪1‬‬ ‫‪2‬‬ ‫‪3‬‬

‫‪a‬‬ ‫‪a‬‬ ‫‪b‬‬ ‫‪a‬‬ ‫‪b‬‬

‫‪α‬‬ ‫‪γ‬‬ ‫‪β‬‬ ‫‪γ‬‬ ‫‪β‬‬

‫‪1‬‬ ‫‪2‬‬ ‫‪4‬‬ ‫‪1‬‬ ‫‪2‬‬

‫‪α‬‬ ‫‪β‬‬ ‫‪γ‬‬ ‫‪α‬‬ ‫‪δ‬‬

‫‪a‬‬ ‫‪a‬‬ ‫‪a‬‬ ‫‪a‬‬ ‫‪b‬‬

‫‪r ∞s‬‬

‫‪ ٨-٢-٤‬ﻋﻤﻠﮕﺮ ﺗﻘﺴﻴﻢ‬

‫‪s‬‬

‫‪r‬‬

‫‪Division‬‬

‫ﺩﻭﺭﺍﺑﻄﻪ ﻳﻜﻲ ﺍﺯ ﺩﺭﺟﻪ ‪ m + n‬ﻭ ﺩﻳﮕﺮﻱ ﺍﺯ ﺩﺭﺟﻪ ‪ n‬ﺭﺍ ﺑﺮﻫﻢ ﺗﻘﺴﻴﻢ ﻣﻲ ﻛﻨﺪ ‪ .‬ﺣﺎﺻﻞ ﺭﺍﺑﻄﻪ ﺍﻳﺴﺖ ﺣﺎﻭﻱ ﻣﻘﺎﺩﻳﺮﻱ ﺍﺯ‬ ‫ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺭﺍﺑﻄﻪ ﺍﺯ ﺩﺭﺟﻪ ‪ m + n‬ﻛﻪ ﻣﻘﺎﺩﻳﺮ ﺻﻔﺖ ﺧﺎﺻﻪ ﺩﻳﮕﺮ ﺑﻪ ﺗﻤﺎﻣﻲ ﺩﺭ ﺭﺍﺑﻄﻪ ﺩﺭﺟﻪ ‪ n‬ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ ‪.‬‬ ‫÷‬

‫•‬

‫ﻧﻤﺎﺩ‬

‫•‬

‫ﺍﻳﻦ ﻋﻤﻠﮕﺮ ﺑﺮﺍﻱ ﺑﺮﺍﻱ ﭘﺮﺱ ﻭ ﺟﻮﻫﺎﻳﻲ ﻛﻪ ﻋﺒﺎﺭﺕ ﺑﺮﺍﻱ ﺗﻤﺎﻡ )‪ (for all‬ﺭﺍ ﺩﺍﺭﻧﺪ ﻣﻨﺎﺳﺐ ﺍﺳﺖ ‪.‬‬

‫•‬

‫ﻓﺮﺽ ﻛﻨﻴﺪ ‪ r‬ﻭ ‪ s‬ﺭﺍﺑﻄﻪ ﻫﺎﻳﻲ ﺭﻭﻱ ﺍﺳﻜﻴﻤﺎﻩ ﺍﻱ ‪ R‬ﻭ ‪ S‬ﺑﺎﺷﻨﺪ ﺑﻄﻮﺭﻳﻜﻪ ‪:‬‬

‫)‪R = (A1,…,Am,B1,…,Bn‬‬ ‫)‪S = (B1,…,Bn‬‬ ‫ﻧﺘﻴﺠﻪ ﺗﻘﺴﻴﻢ ‪ r‬ﺑﺮ ‪ s‬ﺭﺍﺑﻄﻪ ﺍﻳﺴﺖ ﺩﺭ ﺍﺳﻜﻴﻤﺎﻱ ‪R – S‬‬ ‫)‪R – S = (A1,…,Am‬‬ ‫} )‪r ÷ s = {t | t ∈ ∏R – S(r) ∧ ∀ u ∈ s(tu ∈ r‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫•‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٥٠ /‬‬

‫ﻣﺜﺎﻝ ‪:‬‬

‫‪A‬‬

‫‪B‬‬

‫‪B‬‬

‫‪A‬‬

‫‪α‬‬ ‫‪β‬‬ ‫‪r÷s‬‬

‫‪1‬‬ ‫‪2‬‬

‫‪1‬‬ ‫‪2‬‬ ‫‪3‬‬ ‫‪1‬‬ ‫‪1‬‬ ‫‪1‬‬ ‫‪3‬‬ ‫‪4‬‬ ‫‪2‬‬

‫‪α‬‬ ‫‪α‬‬ ‫‪α‬‬ ‫‪β‬‬ ‫‪γ‬‬ ‫‪δ‬‬ ‫‪δ‬‬ ‫‪δ‬‬ ‫‪β‬‬

‫‪s‬‬

‫‪r‬‬ ‫‪C‬‬

‫‪B‬‬

‫‪A‬‬

‫‪E‬‬

‫‪D‬‬

‫‪E‬‬

‫‪D‬‬

‫‪C‬‬

‫‪B‬‬

‫‪A‬‬

‫‪γ‬‬ ‫‪γ‬‬

‫‪a‬‬ ‫‪a‬‬

‫‪α‬‬ ‫‪γ‬‬

‫‪1‬‬ ‫‪1‬‬

‫‪a‬‬ ‫‪b‬‬

‫‪1‬‬ ‫‪1‬‬ ‫‪1‬‬ ‫‪1‬‬ ‫‪3‬‬ ‫‪1‬‬ ‫‪1‬‬ ‫‪1‬‬

‫‪a‬‬ ‫‪a‬‬ ‫‪b‬‬ ‫‪a‬‬ ‫‪b‬‬ ‫‪a‬‬ ‫‪b‬‬ ‫‪b‬‬

‫‪α‬‬ ‫‪γ‬‬ ‫‪γ‬‬ ‫‪γ‬‬ ‫‪γ‬‬ ‫‪γ‬‬ ‫‪γ‬‬ ‫‪β‬‬

‫‪A‬‬ ‫‪A‬‬ ‫‪A‬‬ ‫‪A‬‬ ‫‪A‬‬ ‫‪A‬‬ ‫‪A‬‬ ‫‪A‬‬

‫‪α‬‬ ‫‪α‬‬ ‫‪α‬‬ ‫‪β‬‬ ‫‪β‬‬ ‫‪γ‬‬ ‫‪γ‬‬ ‫‪γ‬‬

‫‪r÷s‬‬

‫‪s‬‬

‫‪r‬‬ ‫‪ - ٣-٤‬ﻋﻤﻠﮕﺮﻫﺎﻱ ﺍﺿﺎﻓﻪ ﺷﺪﻩ ﻭ ﻋﻤﻠﻴﺎﺕ ﺩﻳﮕﺮ ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ‬ ‫‪ : ١-٣-٤‬ﻋﻤﻠﮕﺮ ﺗﻐﻴﻴﺮ ﻧﺎﻡ‬

‫‪Rename‬‬

‫ﺍﻳﻦ ﺍﻣﻜﺎﻥ ﺭﺍ ﻣﻲ ﺩﻫﺪ ﻛﻪ ﺑﻪ ﻳﻚ ﺭﺍﺑﻄﻪ ﺑﺎ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﺍﺳﻢ ﺭﺟﻮﻉ ﺷﻮﺩ ‪.‬‬

‫)‪Px(E‬‬

‫•‬

‫ﻋﺒﺎﺭﺕ ‪ E‬ﺭﺍ ﺗﺤﺖ ﻧﺎﻡ ‪ X‬ﺑﺮ ﻣﻲ ﮔﺮﺩﺍﻧﺪ‪.‬‬ ‫•‬

‫ﺍﮔﺮ ﻳﻚ ﻋﺒﺎﺭﺕ ﺟﺒﺮﺭﺍﺑﻄﻪ ﺍﻱ ‪ n ، E‬ﺳﺘﻮﻥ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‬

‫‪Px(A1, … ,An)E‬‬

‫ﺑﻪ ﻣﻌﻨﻲ ﺁﻥ ﺍﺳﺖ ﻛﻪ ﻧﺘﻴﺠﻪ ﻋﺒﺎﺭﺕ ‪ E‬ﺗﺤﺖ ﻧﺎﻡ ‪ X‬ﺑﺎ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺗﻐﻴﻴﺮ ﻧﺎﻡ ﻳﺎﻓﺘﻪ‬

‫‪An, … ,A1‬‬

‫ﺑﺮ ﻣﻲ‬

‫ﮔﺮﺩﺍﻧﺪ‪.‬‬ ‫‪ : ٢-٣-٤‬ﻋﻤﻠﮕﺮ ﺑﺴﻂ‬

‫‪Extend‬‬

‫ﻋﻤﻠﮕﺮ ﺍﺳﺖ ﻛﻪ ﺑﺮﺍﻱ ﮔﺴﺘﺮﺵ ﻋﻨﻮﺍﻥ ﻳﻚ ﺭﺍﺑﻄﻪ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ ‪ .‬ﻛﻪ ﻣﻌﻤﻮﻻ ﺻﻔﺖ ﺧﺎﺻﻪ ﺍﺿﺎﻓﻪ ﺷﺪﻩ ﻣﻘﺎﺩﻳﺮ ﺁﻥ ﺑﺎ‬ ‫ﺍﺭﺯﻳﺎﺑﻲ ﻳﻚ ﻋﺒﺎﺭﺕ ﻣﺤﺎﺳﺒﺎﺗﻲ ﻣﺸﺨﺺ ﺑﺪﺳﺖ ﻣﻲ ﺁﻳﺪ ‪.‬‬ ‫‪Extend P Add (weight ∗ 454) As GMWT‬‬

‫‪ GMWT‬ﻭﺯﻥ ﻗﻄﻌﺎﺕ ﺑﺮ ﺣﺴﺐ ﮔﺮﻡ ﻣﻲ ﺑﺎﺷﺪ ﻛﻪ ﺩﺭ ﻭﺍﻗﻊ ﺗﺒﺪﻳﻞ ﺷﺪﻩ ﭘﻮﻧﺪ ﺑﻪ ﮔﺮﻡ ﺍﺳﺖ ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٥١ /‬‬

‫‪Aggregate Operator‬‬

‫‪ : ٣-٣-٤‬ﻋﻤﻠﮕﺮ ﻫﺎﻱ ﺟﻤﻌﻲ‬

‫ﻋﻤﻠﮕﺮﻫﺎﻳﻲ ﻛﻪ ﺑﺮﺍﻱ ﺷﻤﺎﺭﺵ‪ ،‬ﻣﺠﻤﻮﻉ‪ ،‬ﻣﻴﺎﻧﮕﻴﻦ ﻭ ﻣﻲ ﻧﻴﻤﻢ ﻭ ﻣﺎﻛﺰﻳﻤﻢ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﻧﺪ‪ .‬ﺩﺭ ﻭﺍﻗﻊ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﻣﻘﺎﺩﻳﺮ‬ ‫ﺭﺍ ﮔﺮﻓﺘﻪ ﻭ ﻳﻚ ﻣﻘﺪﺍﺭ ﺗﻜﻲ ﺭﺍ ﺑﻌﻨﻮﺍﻥ ﺧﺮﻭﺟﻲ ﺑﺎﺯ ﻣﻲ ﮔﺮﺩﺍﻧﻨﺪ‪.‬‬ ‫‪Min , Max , Avg , Sum , Count‬‬ ‫)‪(sp‬‬

‫ﻣﺜﺎﻝ ‪ :‬ﻣﺠﻤﻮﻉ ﻗﻄﻌﺎﺕ ﺗﻬﻴﻪ ﺷﺪﻩ ﺗﻮﺳﻂ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ‪. s1‬‬

‫)‪gsum(Qty) (sp‬‬

‫ﻳﺎ‬ ‫‪ -٤-٣-٤‬ﻋﻤﻠﮕﺮ ﺍﻧﺘﺴﺎﺏ‬

‫)‪бs# = ‘s1’g sum(Qty‬‬

‫‪Assignment‬‬

‫←‬

‫•‬

‫ﻧﻤﺎﺩ‬

‫•‬

‫ﺍﻳﻦ ﻋﻤﻠﮕﺮ ﻳﻚ ﺭﻭﺵ ﻣﻨﺎﺳﺐ ﺑﺮﺍﻱ ﺑﻴﺎﻥ ﭘﺮﺱ ﻭ ﺟﻮﻫﺎﻱ ﭘﻴﭽﻴﺪﻩ ﺍﺳﺖ ‪.‬‬

‫•‬

‫ﺍﻧﺘﺴﺎﺏ ﺑﺎﻳﺴﺘﻲ ﺑﻪ ﻳﻚ ﻣﺘﻐﻴﻴﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﻣﻮﻗﺖ ﻧﺴﺒﺖ ﺩﺍﺩﻩ ﺷﻮﺩ ‪:‬‬

‫‪ -٥-٣-٤‬ﻋﻤﻠﮕﺮ ﻧﻴﻢ ﭘﻴﻮﻧﺪ ‪Semi Join‬‬

‫ﺍﻳﻦ ﻋﻤﻠﮕﺮ ﮔﻮﻧﻪ ﺍﻱ ﺩﻳﮕﺮ ﺍﺯ ﭘﻴﻮﻧﺪ ﻃﺒﻴﻌﻲ ﺍﺳﺖ ﻛﻪ ﺩﺭﺁﻥ ‪ ،‬ﺗﻨﻬﺎ ﺗﺎﭘﻠﻬﺎﻱ ﭘﻴﻮﻧﺪ ﺷﺪﻧﻲ ﺍﺯ ﺭﺍﺑﻄﻪ ﺳﻤﺖ ﭼﭗ ﺩﺭ ﺭﺍﺑﻄﻪ ﺟﻮﺍﺏ‬ ‫ﻭﺍﺭﺩ ﻣﻴﺸﻮﻧﺪ‪ .‬ﺍﻳﻦ ﻋﻤﻠﮕﺮ ﺩﺭ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎﻱ ﺗﻮﺯﻳﻊ ﺷﺪﻩ ﻛﺎﺭﺑﺮﺩ ﺩﺍﺭﺩ ‪.‬‬ ‫)‪R1 ∝ R2 = ∏ Attribute(R1) (R1 ∞ R2‬‬ ‫‪ -٥-٣-٤‬ﻋﻤﻠﮕﺮ ﻧﻴﻢ ﺗﻔﺎﺿﻞ ‪Semi Minus‬‬

‫ﺍﻳﻦ ﻋﻤﻠﮕﺮ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺍﺳﺖ ‪:‬‬ ‫)‪R1 SEMIMINUS R2 = R1 MINUS ( R1 ∝ R2‬‬

‫‪-٤-٤‬ﻣﺠﻤﻮﻋﻪ ﻛﺎﻣﻞ ﻋﻤﻠﮕﺮﻫﺎ ﺩﺭ ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ‪:‬‬ ‫ﺍﺯ ﻋﻤﻠﮕﺮﻫﺎﻱ ﻣﻄﺮﺡ ﺷﺪﻩ ‪ ،‬ﺑﺮﺧﻲ ﻣﺒﻨﺎﻳﻲ ﻫﺴﺘﻨﺪ ﺑﻪ ﺍﻳﻦ ﻣﻌﻨﺎ ﻛﻪ ﻣﺠﻤﻮﻋﻪ ﺁﻧﻬﺎ ﺍﺯ ﻧﻈﺮ ﻋﻤﻠﻴﺎﺗﻲ ﻛﺎﻣﻞ ﺍﺳﺖ ﻭ ﻫﺮ ﻋﻤﻠﮕﺮ‬ ‫ﺩﻳﮕﺮ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﺑﺮ ﺣﺴﺐ ﻋﻤﻠﮕﺮﻫﺎﻱ ﺍﻳﻦ ﻣﺠﻤﻮﻋﻪ ﺑﻴﺎﻥ ﻛﺮﺩ ‪ .‬ﺍﻳﻦ ﻣﺠﻤﻮﻋﻪ ﻛﺎﻣﻞ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ ‪:‬‬ ‫} ‪{Select , Project , Union , Minus, Time‬‬

‫ﺑﺮﺧﻲ ﻋﻤﻠﮕﺮﻫﺎﻱ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺑﺎ ﺍﻳﻦ ﻣﺠﻤﻮﻋﻪ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ ‪:‬‬ ‫)‪R1 ∩ R2 = R1 – (R1 – R2) = R2 – ( R2 – R1‬‬ ‫)‪R1 ∩ R2 = ( R1 ∪ R2 ) – ( R1 – R2) ∪ ( R2 – R1‬‬ ‫]‪R1(Y,X) ÷ R2(X) = R1[Y] – (( R1[Y] × R2 ) – R1 )[Y‬‬

‫‪ -٥-٤‬ﺑﺮﺧﻲ ﺧﻮﺍﺹ ﻋﻤﻠﮕﺮﻫﺎ ‪:‬‬ ‫ﺍﮔﺮ ‪ R,S,T‬ﺭﺍﺑﻄﻪ ﺑﺎﺷﻨﺪ ﺩﺍﺭﻳﻢ ‪:‬‬ ‫‪R∞S=S∞R‬‬ ‫)‪(R ∞ S) ∞ T = R ∞ (S ∞ T‬‬

‫) ‪∏ A1..Ap (∏ Ai..Aj) ( R ) = ∏ A1..Ap ( R‬‬

‫)‪б Ai=’a’ ( R ) U бAi=’a’( S ) = бAi=’a’ (RUS‬‬ ‫)‪б Ai=’a’ ( R ) ∩ бAi=’a’( S ) = бAi=’a’ (R∩S‬‬ ‫)‪б Ai=’a’ ( R ) - бAi=’a’( S ) = бAi=’a’ (R-S‬‬

‫‪1‬‬‫‪2‬‬‫‪3‬‬‫‪4‬‬‫‪5‬‬‫‪6-‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٥٢ /‬‬

‫) ‪∏ A1..Ap ( R ) U ∏ A1..Ap ( S ) = ∏ A1..Ap (R U S‬‬

‫‪7-‬‬

‫ﻣﺜﺎﻝ ‪ :‬ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ‪ ،‬ﻗﻄﻌﺎﺕ‪ ،‬ﭘﺮﻭﮊﻩ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﺑﮕﻴﺮﻳﺪ‪ .‬ﺳﺎﺧﺘﺎﺭ ﺁﻥ ﺩﺭ ﺯﻳﺮ ﺍﺭﺍﺋﻪ ﺷﺪﻩ ﺍﺳﺖ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ‬ ‫ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﻪ ﭘﺮﺱ ﻭ ﺟﻮﻫﺎﻱ ﺯﻳﺮ ﭘﺎﺳﺦ ﺩﻫﻴﺪ ‪.‬‬ ‫)‪S (s# , sname , status , city‬‬ ‫)‪P (p# , pname , color , weight , city‬‬ ‫)‪J (j# , jname , city‬‬ ‫)‪SPJ (s# , p# , j# , Qty‬‬

‫‪ -١‬ﺟﺰﺋﻴﺎﺕ ﻛﺎﻣﻞ ﺗﻤﺎﻡ ﭘﺮﻭﮊﻩ ﻫﺎﻱ ﺷﻬﺮ “ﺗﻬﺮﺍﻥ” ﺭﺍ ﻣﺸﺨﺺ ﻛﻨﻴﺪ ‪.‬‬ ‫‘ ﺗﻬﺮﺍﻥ‘ = ‪J where city‬‬

‫)‪ ‘ (J‬ﺗﻬﺮﺍﻥ‘ = ‪бcity‬‬

‫ﻳﺎ‬

‫‪ -٢‬ﺍﺳﺎﻣﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﻗﻄﻌﻪ ‪ P2‬ﺭﺍ ﺑﺪﻫﻴﺪ ‪:‬‬ ‫)’‪∏Sname (S join SPJ where P# = ‘P2‬‬

‫ﻳﺎ‬

‫))‪∏Sname (бP# = ‘P2’(S ∞ SPJ‬‬

‫‪temp1 ← S join SPJ‬‬

‫ﻳﺎ‬

‫’‪temp2 ← temp1 where P# =’P2‬‬ ‫)‪result ← ∏Sname (temp2‬‬

‫‪ -٣‬ﺍﺳﺎﻣﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻧﻲ ﻛﻪ ﺍﻗﻼ ﻳﻚ ﻗﻄﻌﻪ ﺁﺑﻲ ﺭﺍ ﺗﻬﻴﻪ ﻣﻲ ﻛﻨﻨﺪ ‪:‬‬ ‫]‪ ‘) ∞ SPJ) ∞ S)[sname‬ﺁﺑﻲ‘ = ‪((P where color‬‬ ‫‪ ‘ P) ∞ SPJ) ∞ S‬ﺁﺑﻲ‘ = ‪∏Sname ((бcolor‬‬

‫‪ -٤‬ﺍﺳﺎﻣﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻧﻲ ﺭﺍ ﺑﺪﻫﻴﺪ ﻛﻪ ﺗﻤﺎﻡ ﻗﻄﻌﺎﺕ ﺭﺍ ﺗﻬﻴﻪ ﻣﻲ ﻛﻨﻨﺪ ‪:‬‬ ‫)‪∏Sname ((∏(S# , P#) (SPJ) ÷ ∏P# (P) ∞ S‬‬

‫‪ -٥‬ﺍﺳﺎﻣﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻧﻲ ﻛﻪ ﻗﻄﻌﻪ ‪ P2‬ﺭﺍ ﺗﻬﻴﻪ ﻧﻤﻲ ﻛﻨﻨﺪ ‪:‬‬ ‫]‪(∏S# (S) – (∏S# (бP# = ‘P2’( SPJ)) ∞ S [sname‬‬ ‫]‪(S[S#] – (SPJ where P# = ‘p2’) [S#] ) ∞ S [sname‬‬

‫ﻳﺎ‬

‫‪ -٦‬ﺷﻤﺎﺭﻩ ﻗﻄﻌﺎﺗﻲ ﺭﺍ ﻣﺸﺨﺺ ﻛﻨﻴﺪ ﻛﻪ ﺗﻮﺳﻂ ﻳﻚ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ﺩﺭ ﺷﻬﺮ ﺗﻬﺮﺍﻥ ﻳﺎ ﭘﺮﻭﮊﻩ ﺍﻱ ﺩﺭ ﺷﻬﺮ ﺗﻬﺮﺍﻥ ﻋﺮﺿﻪ ﻣﻲ‬ ‫ﺷﻮﺩ ‪:‬‬ ‫]‪‘ )) [P#‬ﺗﻬﺮﺍﻥ‘ = ‪‘ )) [P#] ∪ SPJ ∞ ( J Where city‬ﺗﻬﺮﺍﻥ‘ = ‪SPJ ∞ ( S Where city‬‬ ‫)‪ ‘ J‬ﺗﻬﺮﺍﻥ‘ = ‪∏P# (SPJ ∞ (бcity‬‬

‫∪ ))‪ ‘ (S‬ﺗﻬﺮﺍﻥ‘ = ‪(SPJ ∞ (бcity‬‬

‫ﻣﺜﺎﻝ ‪ : ٢‬ﻳﻚ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺩﺭ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﺑﺎﻧﻚ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﺑﮕﻴﺮﻳﺪ ﻛﻪ ﺩﺍﺭﺍﻱ ﺟﺪﺍﻭﻝ ﺯﻳﺮ ﻣﻲ ﺑﺎﺷﺪ ‪:‬‬ ‫ﺷﻌﺒﻪ ﺑﺎﻧﻚ )ﻧﺎﻡ ﺷﻌﺒﻪ‪ ،‬ﺷﻬﺮ ﺷﻌﺒﻪ‪ ،‬ﺩﺍﺭﺍﻳﻴﻬﺎ (‬ ‫ﻣﺸﺘﺮﻱ )ﻧﺎﻡ ﻣﺸﺘﺮﻱ‪ ،‬ﺁﺩﺭﺱ (‬ ‫ﺣﺴﺎﺏ )ﺷﻤﺎﺭﻩ ﺣﺴﺎﺏ ‪ ،‬ﻧﺎﻡ ﺷﻌﺒﻪ‪ ،‬ﻣﻮﺟﻮﺩﻱ (‬ ‫ﻭﺍﻡ )ﺷﻤﺎﺭﻩ ﻭﺍﻡ‪ ،‬ﻧﺎﻡ ﺷﻌﺒﻪ‪ ،‬ﻣﻘﺪﺍﺭ ﻭﺍﻡ (‬

‫‪∏P#‬‬

٥٣ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

(‫ ﺷﻤﺎﺭﻩ ﺣﺴﺎﺏ‬،‫ﺳﭙﺮﺩﻩ ﮔﺬﺍﺭﻱ )ﻧﺎﻡ ﻣﺸﺘﺮﻱ‬ (‫ ﺷﻤﺎﺭﻩ ﻭﺍﻡ‬،‫ﻭﺍﻡ ﮔﻴﺮﻧﺪﻩ )ﻧﺎﻡ ﻣﺸﺘﺮﻱ‬ branch (branch_name , branch_city , assests) customer (customer_name , customer_street , customer_city) account (account_number , branch_name , balance) loan (loan_number , branch_name , amount) depositor (customer_name , account_number) borrower (customer_name , loan_number)

depositor

loan_branch

customer street city

loan

borrower

loan_num

amount

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٥٤ /‬‬

‫‪query‬ﻫﺎ ‪:‬‬ ‫‪ -١‬ﺗﻤﺎﻣﻲ ﻭﺍﻣﻬﺎﻱ ﺑﻴﺶ ﺍﺯ ‪١٠٠٠٠٠‬ﺭﻳﺎﻝ ﺭﺍ ﺑﺪﻫﻴﺪ ‪:‬‬

‫)‪бamount > 100000 (loan‬‬ ‫‪ -٢‬ﺷﻤﺎﺭﻩ ﻭﺍﻣﻬﺎﻳﻲ ﺭﺍ ﻛﻪ ﺑﻴﺶ ﺍﺯ ‪١٠٠٠٠٠‬ﺭﻳﺎﻝ ﻣﻲ ﺑﺎﺷﻨﺪ ﺑﺪﻫﻴﺪ ‪:‬‬

‫))‪∏loan_number (бamount > 100000 (loan‬‬ ‫‪ -٣‬ﺍﺳﺎﻣﻲ ﺗﻤﺎﻣﻲ ﻣﺸﺘﺮﻳﺎﻧﻲ ﻛﻪ ﻭﺍﻡ ﮔﺮﻓﺘﻪ ﻭ ﺷﻤﺎﺭﻩ ﺣﺴﺎﺏ ﺩﺍﺭﻧﺪ ﺭﺍ ﺑﺪﻫﻴﺪ ‪:‬‬

‫)‪∏customer_name (borrower) ∩ ∏customer_name (depositor‬‬ ‫‪ -٤‬ﺍﺳﺎﻣﻲ ﺗﻤﺎﻡ ﻣﺸﺘﺮﻳﺎﻧﻲ ﺭﺍ ﻛﻪ ﺩﺭ ﺷﻌﺒﻪ ﻣﺮﻛﺰﻱ ﻭﺍﻡ ﮔﺮﻓﺘﻪ ﺍﻧﺪ ﺑﺪﻫﻴﺪ ‪:‬‬

‫)))‪’ ( бborrower.loan_number = loan .loan_number (borrower × loan‬ﻣﺮﻛﺰﻱ‘ = ‪∏customer_name (бbranch_name‬‬ ‫‪ -٥‬ﺍﺳﺎﻣﻲ ﺗﻤﺎﻡ ﻣﺸﺘﺮﻳﺎﻧﻲ ﻛﻪ ﺩﺭ ﺷﻌﺒﻪ ﻧﺎﺩﺭﻱ ﻭﺍﻡ ﮔﺮﻓﺘﻪ ﺍﻧﺪ ﺭﺍ ﺑﺪﻫﻴﺪ ‪:‬‬ ‫‪’)( бborrower.loan_number = loan .loan_number‬ﻧﺎﺩﺭﻱ‘ = ‪Q1: ∏customer_name (бbranch_name‬‬ ‫)))‪(borrower × loan‬‬ ‫’ﻧﺎﺩﺭﻱ‘ = ‪Q2: ∏customer_name ( бloan .loan_number = borrower.loan_number (бbranch_name‬‬ ‫))‪(loan)) × borrower‬‬

‫‪ -٦‬ﺍﺳﺎﻣﻲ ﺗﻤﺎﻡ ﻣﺸﺘﺮﻳﺎﻧﻲ ﺭﺍ ﻛﻪ ﻳﻚ ﺣﺴﺎﺏ ﺩﺭ ﺗﻤﺎﻡ ﺷﻌﺒﻪ ﻫﺎﻱ ﺷﻬﺮ ﻗﺰﻭﻳﻦ ﺩﺍﺭﻧﺪ ﺭﺍ ﺑﺪﻫﻴﺪ ‪:‬‬ ‫))‪ ” (branch‬ﻗﺰﻭﻳﻦ“ = ‪∞ account) ÷∏branch_name (бbranch_city‬‬

‫•‬

‫‪∏customer_name , branch_name (depositor‬‬

‫ﻧﻜﺎﺕ ﻣﻬﻢ ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ‪:‬‬ ‫‪ -١‬ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﺯﺑﺎﻧﻲ ﺍﺳﺖ ﺭﻭﺷﻤﻨﺪ ﻳﻌﻨﻲ ﺑﺮﻧﺎﻣﻪ ﺳﺎﺯ ﻧﻪ ﺗﻨﻬﺎ ﺑﻪ ﺳﻴﺴﺘﻢ ﻣﻲ ﮔﻮﻳﺪ ﭼﻪ ﻣﻲ ﺧﻮﺍﻫﺪ ﺑﻠﻜﻪ ﻧﺤﻮﻩ‬ ‫ﺑﺪﺳﺖ ﺁﻭﺭﺩﻥ ﺁﻧﭽﻪ ﺭﺍ ﻛﻪ ﻣﻲ ﺧﻮﺍﻫﺪ ﻧﻴﺰ ﺑﻴﺎﻥ ﻣﻲ ﻛﻨﺪ ‪.‬‬ ‫‪ -٢‬ﻣﻌﺎﺩﻝ ﺍﺳﺖ ﺑﺎ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﻳﻌﻨﻲ ﻫﺮﺗﻮﺍﻧﻲ ﻛﻪ ﻣﺠﻤﻮﻋﻪ ﺍﻣﻜﺎﻧﺎﺕ ﻣﺤﺎﺳﺒﺎﺗﻲ ﺩﺍﺭﺩ ﺟﺒﺮﺭﺍﺑﻄﻪ ﺍﻱ ﻧﻴﺰ‬ ‫ﺩﺍﺭﺩ ‪.‬‬ ‫‪ -٣‬ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﻓﻘﻂ ﺑﺮﺍﻱ ﺑﺎﺯﻳﺎﺑﻲ ﻧﻴﺴﺖ ﺑﻠﻜﻪ ﻣﻲ ﺗﻮﺍﻥ ﺩﺭ ﻋﻤﻠﻴﺎﺕ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﻭ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﻧﻴﺰ‬ ‫ﺍﺳﺘﻔﺎﺩﻩ ﻛﺮﺩ ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺩﺭﺝ ﻛﻨﻴﺪ‬

‫> ‪< S7,S n7, ...‬‬

‫ﺩﺭ ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﻣﻲ ﺗﻮﺍﻥ ﺍﺯ ﻋﻤﻠﮕﺮ ﺍﺟﺘﻤﺎﻉ ﺑﺮﺍﻱ ﺩﺭﺝ ﺍﺳﺘﻔﺎﺩﻩ ﻧﻤﻮﺩ ‪r U E :‬‬

‫‪ E‬ﺭﺍﺑﻄﻪ ﺛﺎﺑﺖ ﻭ ﺩﺍﺭﺍﻱ ﻳﻚ ﺗﺎﭘﻠﻲ ﺍﺳﺖ ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺣﺬﻑ ﻛﻨﻴﺪ‬

‫}‪S U {s# = s7, sname =sn7,...‬‬

‫> ‪< S4,Sn4, ...‬‬

‫} ‪S Minus {s# = s4‬‬ ‫‪r‬‬ ‫ﺍﺯ ﻋﻤﻠﮕﺮ ﺗﻔﺮﻳﻖ ﺑﺮﺍﻱ ﺣﺬﻑ ﺍﺯ ﻳﻚ ﺭﺍﺑﻄﻪ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﺩ ‪r - E .‬‬

‫‪ r‬ﺭﺍﺑﻄﻪ ﻭ ‪ E‬ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﺎ ﺷﺮﺍﻳﻂ ﺣﺬﻑ ﻣﻲ ﺑﺎﺷﺪ ‪.‬‬

‫‪r‬‬

‫‪ r ,‬ﺭﺍﺑﻄﻪ ﻭ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫‪ -٦-٥‬ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٥٥ /‬‬

‫‪Relational calculus‬‬

‫ﻣﺤﺎﺳـﺒﺎﺕ ﺭﺍﺑﻄـﻪ ﺍﻱ ﺍﻣﻜـﺎﻥ ﺩﻳﮕـﺮﻱ ﺍﺳﺖ ﺑﺮﺍﻱ ﺍﻧﺠﺎﻡ ﻋﻤﻠﻴﺎﺕ ﺭﻭﻱ ﺭﺍﺑﻄﻪ ﻫﺎ ﻭ ﻛﺎﺭ ﺑﺎ ﺑﺎﻧﻚ ﺭﺍﺑﻄﻪ ﺍﻱ‬

‫ﻣﺤﺎﺳﺒﺎﺕ‬

‫ﺭﺍﺑﻄ ـﻪ ﺍﻱ ﺣﺎﻟــﺖ ﻧﺎﺭﻭﺷــﻤﻨﺪ )ﻏﻴــﺮ ﺭﻭﻳــﻪ ﺍﻱ ( ﺩﺍﺭﺩ ﻳﻌﻨــﻲ ﺩﺭ ﺁﻥ ﻋﻤﻠــﻴﺎﺕ ﻻﺯﻡ ﺑــﺮﺍﻱ ﺍﺷــﺘﻘﺎﻕ ﺭﺍﺑﻄــﻪ ﺍﻱ ﺍﺯ ﺭﺍﺑﻄــﻪ ﻫــﺎﻱ‬ ‫ﺩﻳﮕﺮﺗﺼﺮﻳﺢ ﻧﻤﻲ ﺷﻮﺩ ‪ .‬ﺑﻪ ﻋﺒﺎﺭﺗﻲ ﺗﻨﻬﺎ ﺁﻧﭽﻪ ﻛﻪ ﺑﺎﻳﺪ ﺑﺎﺯﻳﺎﺑﻲ ﺷﻮﺩ ﺗﺸﺮﻳﺢ ﻣﻲ ﺷﻮﺩ ﻭ ﭼﮕﻮﻧﮕﻲ ﺑﺎﺯﻳﺎﺑﻲ ﺁﻧﻬﺎ ﺑﻴﺎﻥ ﻧﻤﻲ ﺷﻮﺩ‬ ‫‪.‬‬ ‫ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﺩﺭ ﺩﻭ ﺷﺎﺧﻪ ﺑﻴﺎﻥ ﻣﻲ ﺷﻮﺩ ‪:‬‬ ‫‪ -١‬ﻣﺤﺎﺳﺒﺎﺕ ﺭﻭﻱ ﺗﺎﭘﻞ ﻫﺎ‬

‫‪Tuple Relational Calculus‬‬

‫‪ -٢‬ﻣﺤﺎﺳﺒﺎﺕ ﺭﻭﻱ ﻣﻴﺪﺍﻥ ﻫﺎ‬

‫‪Domain Relational calculus‬‬

‫ﺍﻳـﺪﻩ ﺍﻭﻟـﻴﻪ ﺍﺳـﺘﻔﺎﺩﻩ ﺍﺯ ﻣﺤﺎﺳـﺒﺎﺕ ﺭﺍﺑﻄـﻪ ﺍﻱ ﻧﺨﺴـﺘﻴﻦ ﺑﺎﺭ ﺗﻮﺳﻂ ‪ Knuth‬ﻣﻄﺮﺡ ﺷﺪ ﻭ ﺳﭙﺲ ﻛﺎﺩ ﻧﺤﻮﻩ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺁﻥ ﺭﺍ‬ ‫ﺑـﺮﺍﻱ ﺍﻧﺠـﺎﻡ ﻋﻤﻠـﻴﺎﺕ ﺭﻭﻱ ﺭﺍﺑﻄﻪ ﻫﺎﻱ ﺑﺎﻧﻚ ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﻴﺎﻥ ﻛﺮﺩ ‪ .‬ﺑﺮ ﺍﺳﺎﺱ ﻛﺎﺭﻫﺎﻱ ﻛﺎﺩ ﺯﺑﺎﻥ ‪ Alpha‬ﻃﺮﺍﺣﻲ ﺷﺪ ﻛﻪ ﺍﻟﺒﺘﻪ‬ ‫ﺑـﻪ ﻣـﺮﺣﻠﻪ ﭘـﻴﺎﺩﻩ ﺳـﺎﺯﻱ ﻧﺮﺳـﻴﺪ ‪ .‬ﺑﻌﺪﻫﺎ ﺯﺑﺎﻧﻲ ﺑﻨﺎﻡ ‪ Quel‬ﺑﺮﮔﺮﻓﺘﻪ ﺍﺯ ‪ Alpha‬ﻃﺮﺍﺣﻲ ﺷﺪ ﻛﻪ ﺑﻪ ﻧﻮﻋﻲ ﻣﻲ ﺗﻮﺍﻥ ﺁﻥ ﺭﺍ ﻧﻤﻮﻧﻪ‬ ‫ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ ‪ Alpha‬ﺩﺍﻧﺴﺖ ‪.‬‬ ‫ﻳﻜـﻲ ﺍﺯ ﻣﻬﻤﺘـﺮﻳﻦ ﺟﻨـﺒﻪ ﻫـﺎﻱ ﻣﺤﺎﺳـﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ‪ ،‬ﻣﻔﻬﻮﻡ ﻣﺘﻐﻴﺮ ﻃﻴﻔﻲ ﻳﺎ ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ﺍﺳﺖ ‪ .‬ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ﻣﺘﻐﻴﺮﻱ ﺍﺳﺖ ﻛﻪ‬ ‫ﻣﻘﺎﺩﻳـﺮﺵ ﺍﺯ ﻳـﻚ ﺭﺍﺑﻄـﻪ ﺑﺮﮔـﺮﻓﺘﻪ ﻣـﻲ ﺷﻮﺩ ﻭﺑﻪ ﻋﺒﺎﺭﺕ ﺩﻳﮕﺮ ‪ ،‬ﻃﻴﻒ ﻣﻘﺎﺩﻳﺮ ﻣﺠﺎﺯﺵ ‪،‬ﻫﻤﺎﻥ ﺗﺎﭘﻠﻬﺎﻱ ﻣﺠﻤﻮﻋﻪ ﺑﺪﻧﻪ ﺭﺍﺑﻄﻪ‬ ‫ﺍﺳﺖ ‪ .‬ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ﺭﺍ ﺑﺎﻳﺴﺘﻲ ﺗﻌﺮﻳﻒ ﻛﺮﺩ ﻛﻪ ﺩﺭ ﺯﺑﺎﻥ ‪Quel‬‬

‫ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ ‪:‬‬

‫; ‪Range of SX is S‬‬ ‫`‪RETRIEVE ( SX.S#) WHERE SX.CITY = `TEHRAN‬‬ ‫ﺩﺭ ﺍﻳﻨﺠﺎ ﻣﺘﻐﻴﺮ ‪ SX‬ﻫﻤﺎﻥ ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ﺍﺳﺖ ﻛﻪ ﻣﻘﺎﺩﻳﺮﺵ ﺗﺎﭘﻠﻬﺎﻱ ‪ S‬ﻫﺴﺘﻨﺪ ‪.‬‬

‫ﺩﺭ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﺎ ﻣﺘﻐﻴﺮ ﻣﻴﺪﺍﻧﻲ ﻧﻴﺰ ﺑﺠﺎﻱ ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ‪ ،‬ﻣﺘﻐﻴﺮ ﻣﻴﺪﺍﻧﻲ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ﻭ ﺯﺑﺎﻧﻬﺎﻱ ﻣﺘﻌﺪﺩﻱ ﻣﺒﺘﻨﻲ ﺑﺮ ﺍﻳﻨﮕﻮﻧﻪ‬ ‫ﺍﺯ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﻃﺮﺍﺣﻲ ﺷﺪﻩ ﺍﻧﺪ ﻛﻪ ﺍﺯ ﺟﻤﻠﻪ ﻣﻲ ﺗﻮﺍﻥ ﺑﻪ ﺯﺑﺎﻧﻬﺎﻱ ﺯﻳﺮ ﺍﺷﺎﺭﻩ ﻛﺮﺩ ‪.‬‬ ‫ ‪ILL‬‬‫‪FQL -‬‬

‫‪Formal Query Language‬‬

‫‪QBE -‬‬

‫‪Query By Example‬‬

‫‪ : ١-٦-٥‬ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﺗﺎﭘﻠﻲ‬ ‫ﮔﺮﺍﻣـﺮ ﺯﺑـﺎﻥ ﻣﺒﺘﻨﻲ ﺑﺮ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﺩﺭ ﻛﺘﺎﺑﻬﺎﻱ ﻣﺨﺘﻠﻒ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺍﺯ ﺟﻤﻠﻪ ﻛﺘﺎﺏ ‪DATE‬‬

‫ﻣﺸـﺎﻫﺪﻩ ﻛـﺮﺩ ﻛـﻪ ﺧـﺎﺭﺝ ﺍﺯ ﺑﺤﺚ ﺍﻳﻦ ﺩﺭﺱ ﻣﻲ ﺑﺎﺷﺪ ‪.‬ﺩﺭ ﺍﻳﻨﺠﺎ ﺑﻄﻮﺭ ﺧﻼﺻﻪ ﺑﺮﺧﻲ ﻣﻔﺎﻫﻴﻢ ﺍﺳﺎﺳﻲ ﻣﻮﺟﻮﺩ ﺩﺭ ﻣﺤﺎﺳﺒﺎﺕ‬ ‫ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﻴﺎﻥ ﻣﻲ ﺷﻮﺩ ﻭ ﺳﭙﺲ ﺑﻪ ﺫﻛﺮ ﭼﻨﺪ ﻣﺜﺎﻝ ﺑﺴﻨﺪﻩ ﻣﻲ ﻛﻨﻴﻢ ‪.‬‬ ‫‪ : ١-١-٦-٥‬ﺗﻌﺮﻳﻒ ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ‪:‬‬ ‫ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ﺑﻪ ﻛﻤﻚ ﺣﻜﻢ ﺯﻳﺮ ﺗﻌﺮﻳﻒ ﻣﻲ ﺷﻮﺩ ‪:‬‬ ‫‪Range of T is x1 ; x2 ; x3 ; ... ; xn‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٥٦ /‬‬

‫ﻛﻪ ﺩﺭ ﺁﻥ‪ T‬ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ﻭ‪ X1‬ﻭ ‪ X2‬ﻭ ‪ Xn ...‬ﻋﺒﺎﺭﺍﺕ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﻫﺴﺘﻨﺪ ﻭ ﻧﻤﺎﻳﺎﻧﮕﺮ ﺭﺍﺑﻄﻪ ﻫﺎﻳﻲ ﻣﺜﻞ‪ R2 , R1‬ﻭ‬ ‫‪ Rn ...‬ﻣﻲ ﺑﺎﺷﻨﺪ ‪ .‬ﺑﺪﻳﻬﻲ ﺍﺳﺖ ﺍﮔﺮ ﺩﺭﻟﻴﺴﺖ ﺭﺍﺑﻄﻪ ﻫﺎ ﺗﻨﻬﺎ ﻳﻚ ﺭﺍﺑﻄﻪ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ﻣﻘﺎﺩﻳﺮﺵ ﺭﺍ‬ ‫ﺍﺯ ﻫﻤﺎﻥ ﺭﺍﺑﻄﻪ ‪ R‬ﻣﻲ ﮔﻴﺮﺩ ‪.‬‬ ‫‪RANGE OF SX IS S‬‬

‫ﻣﺜﺎﻝ ‪:‬‬

‫; ‪RANGEVAR SX RANGES OVER S‬‬

‫ﻳﺎ‬

‫; ‪RANGE OF SPX IS SP‬‬ ‫; ‪ RANGEVAR SPX RANGES OVER SP‬ﻳﺎ‬

‫‪ : ٢-١-٦-٥‬ﻋﻤﻠﮕﺮ ﻫﺎ‬ ‫ﺩﻭ ﻋﻤﻠﮕﺮ ﺩﺭ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺍﻧﺪ ﻛﻪ ﺑﻪ ﺁﻧﻬﺎ ﺳﻮﺭ ﮔﻮﻳﻨﺪ ‪ .‬ﻛﻪ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ ‪:‬‬ ‫‪ -‬ﺳﻮﺭ ﻭﺟﻮﺩﻱ‬

‫‪ Exist Quantifire‬ﺑﻪ ﻣﻌﻨﺎﻱ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪:‬‬

‫‪ -‬ﺳﻮﺭ ﻫﻤﮕﺎﻧﻲ‬

‫‪ FOR.ALL Quantifire‬ﺑﻪ ﻣﻌﻨﺎﻱ ﺑﺮﺍﻱ ﻫﻤﻪ ‪:‬‬

‫ﺑـﻪ ﻛﻤﻚ ﺍﻳﻦ ﺩﻭ ﺳﻮﺭ ﻋﺒﺎﺭﺍﺕ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﻧﻮﺷﺘﻪ ﻣﻲ ﺷﻮﻧﺪ ﻭ ﺩﺭ ﺁﻥ ﮔﺰﺍﺭﻩ ﻫﺎﻳﻲ ﺑﺮ ﻧﻬﺎﺩﻩ ﻣﻴﺸﻮﺩ ‪ .‬ﺣﺎﺻﻞ ﺍﺭﺯﻳﺎﺑﻲ‬ ‫ﺍﻳﻦ ﻋﺒﺎﺭﺍﺕ ﻣﻤﻜﻦ ﺍﺳﺖ ‪ true‬ﻭ ﻳﺎ ‪ false‬ﺑﺎﺷﺪ ‪.‬‬ ‫ﻳﺎﺩﺁﻭﺭﻱ ‪ :‬ﻓﺮﺽ ‪X‬‬

‫‪N‬‬ ‫)‪EXISTS X (X>10‬‬ ‫)‪EXISTS X (X<-5‬‬

‫‪True‬‬ ‫‪False‬‬

‫‪N3‬‬ ‫‪3‬‬ ‫‪4‬‬ ‫‪4‬‬

‫‪1) EXISTS T (T(N1)=1) : True‬‬ ‫‪2) FORALL T (T(N1)=1) : True‬‬ ‫‪3 )EXISTS T (T(N1)=1 AND T(N3)>5) : False‬‬

‫‪N2‬‬ ‫‪2‬‬ ‫‪2‬‬ ‫‪3‬‬

‫‪N1‬‬ ‫‪1‬‬ ‫‪1‬‬ ‫‪1‬‬

‫‪ T‬ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ﺭﻭﻱ ﺟﺪﻭﻝ ‪NumB‬‬

‫ﺗﻮﺟﻪ ‪ :‬ﺳﻮﺭ ﻫﻤﮕﺎﻧﻲ ‪ FORALL‬ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﺑﻪ ﻛﻤﻚ ﺳﻮﺭ ﻭﺟﻮﺩﻱ ‪ EXISTS‬ﺑﻴﺎﻥ ﻧﻤﻮﺩ ‪.‬‬ ‫)‪FORALL X(f) =NOT EXISTS X (NOT f‬‬

‫‪ : ٢-٦-٥‬ﺍﺳﺘﻔﺎﺩﻩ ﺩﺭ ﺣﺴﺎﺏ ﻣﺤﻤﻮﻻﺕ ﺩﺭ ﻓﺮﻣﻮﻟﻪ ﻛﺮﺩﻥ ﭘﺮﺱ ﻭ ﺟﻮ ﻫﺎ ‪:‬‬ ‫ﺳﻮﺍﻝ ‪ : ١‬ﺷﻤﺎﺭﻩ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﺳﺎﻛﻦ ‪ C2‬ﺑﺎ ﻭﺿﻌﻴﺖ ﺑﻴﺸﺘﺮ ﺍﺯ ‪ ٢٠‬ﺭﺍ ﺑﻴﺎﺑﻴﺪ ‪.‬‬ ‫‪Sx.s# WHERE sx.city = `c2` AND sx.STATUS > 20‬‬

‫ﺳﻮﺍﻝ ‪ : ٢‬ﺷﻤﺎﺭﻩ ﺟﻔﺖ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﺳﺎﻛﻦ ﻳﻚ ﺷﻬﺮ ﺭﺍ ﺑﺪﻫﻴﺪ ‪.‬‬ ‫‪WHERE sx.city =sy.city AND sx.s# < sy.s#‬‬

‫‪Sx.s# , Sy. s#‬‬

‫ﺳﻮﺍﻝ ‪ : ٣‬ﺍﺳﺎﻣﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﻗﻄﻌﻪ ‪ p2‬ﺭﺍ ﺑﺪﻫﻴﺪ ‪.‬‬ ‫)`‪Sx.SNAME WHERE EXISTS Spx (Spx.s# = Sx. s# AND Spx.p# = ` p2‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٥٧ /‬‬

‫ﺳﻮﺍﻝ‪ : ٤‬ﻧﺎﻡ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻧﻲ ﺭﺍ ﺑﺪﻫﻴﺪ ﻛﻪ ﺩﺳﺖ ﻛﻢ ﻳﻚ ﻗﻄﻌﻪ ﻗﺮﻣﺰ ﺭﺍ ﺗﻬﻴﻪ ﻣﻲ ﻛﻨﻨﺪ ‪.‬‬ ‫‪SX.SNAME‬‬ ‫‪WHERE EXISTS SPX (SX.S# =SPX.S# AND EXISTS PX (PX.P# =SPX.P# AND‬‬ ‫))`‪PX.COLOR = `RED‬‬

‫ﺳﻮﺍﻝ ‪ : ٥‬ﻧﺎﻡ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻧﻲ ﺭﺍ ﻣﺸﺨﺺ ﻛﻨﻴﺪ ﻛﻪ ﺣﺪﺍﻗﻞ ﻳﻚ ﻗﻄﻌﻪ ﺍﺯ ﻗﻄﻌﺎﺕ ﻋﺮﺿﻪ ﺷﺪﻩ ﺗﻮﺳﻂ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ‪ S2‬ﺭﺍ ﺗﺎﻣﻴﻦ‬ ‫‪SX.SNAME‬‬

‫ﻣﻲ ﻛﻨﻨﺪ ‪.‬‬

‫‪WHERE EXISTS Spx ( EXISTS SPY ( SX.S# =SPX.S# AND SPX.P# =SPY.P# AND SPY.S#‬‬ ‫)) `‪=`S2‬‬

‫ﺳﻮﺍﻝ ‪ : ٦‬ﺍﺳﺎﻣﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻧﻲ ﺭﺍ ﺑﺪﻫﻴﺪ ﻛﻪ ﺗﻤﺎﻡ ﻗﻄﻌﺎﺕ ﺭﺍ ﺗﻬﻴﻪ ﻣﻲ ﻛﻨﻨﺪ ‪.‬‬ ‫‪PX (EXISTS SPX (SPX.S# =SX.S# AND SPX.P#‬‬ ‫)) ‪=PX.P#‬‬ ‫ﺟﻮﺍﺏ ﭘﺮﺱ ﻭ ﺟﻮ ﺑﺪﻭﻥ‬ ‫‪FORALL‬‬

‫‪FORALL‬‬

‫‪WHERE‬‬

‫‪SX.SNAME‬‬

‫‪Sx.SNAME WHERE NOT EXISTS PX (NOT EXISTS SPX (SPX.S# = SX.S# AND SPX‬‬ ‫)) ‪.P# = PX.P#‬‬

‫ﺳﻮﺍﻝ ‪ : ٧‬ﺷﻤﺎﺭﻩ ﻭ ﻭﺯﻥ ﻗﻄﻌﺎﺗﻲ ﺭﺍ ﺗﻬﻴﻪ ﻛﻨﻴﺪ ﻛﻪ ﻭﺯﻥ ﻫﺮ ﻗﻄﻌﻪ ﺑﺮ ﺣﺴﺐ ﮔﺮﻡ ﺑﻴﺸﺘﺮ ﺍﺯ ‪ ١٠٠٠‬ﺑﺎﺷﺪ ‪.‬‬ ‫)‪(px.p# , px.WEIGHT * 454 AS GWMT‬‬ ‫)‪WHERE (px.WEIGHT * 454> 1000‬‬

‫ﺳﻮﺍﻝ ‪ : ٨‬ﺷﻬﺮ ﻗﻄﻌﺎﺗﻲ ﺭﺍ ﻣﺸﺨﺺ ﻛﻨﻴﺪ ﻛﻪ ﺑﻴﺶ ﺍﺯ ﺳﻪ ﻗﻄﻌﻪ ﺁﺑﻲ ﺩﺭ ﺁﻥ ﺍﻧﺒﺎﺭ ﺷﺪﻩ ﺑﺎﺷﺪ ‪.‬‬ ‫‪Px.city‬‬ ‫‪WHERE COUNT (PY WHERE PY.city =px.city AND py.color=`BLUE` )>3‬‬

‫•‬

‫ﻧﻜﺎﺕ ﻣﻬﻢ ﺩﺭ ﺧﺼﻮﺹ ﺁﻧﺎﻟﻴﺰ ﺭﺍﺑﻄﻪ ﺍﻱ ‪:‬‬ ‫‪ -١‬ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﻧﺎﺭﻭﺷﻤﻨﺪ ﺍﺳﺖ ﻭ ﺗﻔﺎﻭﺕ ﺍﺻﻠﻲ ﺍﺵ ﺑﺎ ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﻫﻤﻴﻦ ﺍﺳﺖ ‪.‬‬ ‫‪ -٢‬ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﻭ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﻣﻌﺎﺩﻟﻨﺪ ‪.‬‬ ‫‪ -٣‬ﻫﺮ ﺩﻭ ﺍﻛﻤﺎﻝ ﺭﺍﺑﻄﻪ ﺍﻱ ﺩﺍﺭﻧﺪ ﻳﻌﻨﻲ ﻫﺮ ﺭﺍﺑﻄﻪ ﻣﺘﺼﻮﺭ ﺍﺯ ﺭﺍﺑﻄﻪ ﻫﺎﻱ ﻣﻤﻜﻦ ﻗﺎﺑﻞ ﺍﺷﺘﻘﺎﻕ ﺑﻪ ﻛﻤﻚ ﻫﺮ ﻳﻚ‬ ‫ﺍﺯ ﺍﻳﻦ ﺩﻭ ﺍﻣﻜﺎﻥ ﻣﻲ ﺑﺎﺷﺪ ‪.‬‬ ‫‪ -٤‬ﺯﺑﺎﻧﻬﺎﻱ ﻣﺒﺘﻨﻲ ﺑﺮ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﺑﻪ ﺩﻟﻴﻞ ﻧﺎﺭﻭﺷﻤﻨﺪ ﺑﻮﺩﻥ ﺳﻄﺤﺸﺎﻥ ﺑﺎﻻﺗﺮ ﺍﺳﺖ ‪.‬‬ ‫‪ -٥‬ﻫﺮ ﭘﺮﺱ ﻭ ﺟﻮ ﻣﺒﺘﻨﻲ ﺑﺮ ﻣﺤﺎﺳﺒﺎﺕ ﺭﺍﺑﻄﻪ ﺍﻱ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﺑﻔﺮﻡ } ) ‪ {t /p (t‬ﻧﻴﺰ ﻧﻤﺎﻳﺶ ﺩﺍﺩ ‪.‬‬ ‫ﺑﻄﻮﺭﻳﻜﻪ ‪:‬‬ ‫ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﺗﻤﺎﻡ ﺗﺎﭘﻠﻬﺎﻱ ‪ t‬ﺍﺳﺖ ﻛﻪ ﺷﺮﻁ ‪ p‬ﺑﺮﺍﻱ ﺁﻥ ﺩﺭﺳﺖ ﺍﺳﺖ ‪.‬‬‫ ‪ t‬ﻳﻚ ﻣﺘﻐﻴﺮ ﺗﺎﭘﻠﻲ ﺍﺳﺖ ﻭ ]‪ t[A‬ﻧﺸﺎﻥ ﺩﻫﻨﺪﻩ ﻣﻘﺪﺍﺭ ﺗﺎﭘﻞ ‪ t‬ﺭﻭﻱ ﺻﻔﺖ ﺧﺎ ﺻﻪ ‪ A‬ﻣﻲ ﺑﺎﺷﺪ ‪.‬‬‫‪ t∈ r -‬ﺑﻪ ﺍﻳﻦ ﻣﻌﻨﺎﺳﺖ ﻛﻪ ﺗﺎﭘﻞ ‪ t‬ﺩﺭ ﺭﺍﺑﻄﻪ ‪ r‬ﺍﺳﺖ ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٥٨ /‬‬

‫ ‪p‬ﻳﻚ ﻓﺮﻣﻮﻝ ﺍﺳﺖ ﻛﻪ ﺷﺮﻁ ﻣﺤﺎﺳﺒﺎﺕ ﻣﻲ ﺑﺎﺷﺪ ‪.‬‬‫ﻣﺜﺎﻝ ‪ :‬ﻣﺸﺨﺼﺎﺕ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﺑﺎ ﻭﺿﻌﻴﺖ ﺑﻴﺶ ﺍﺯ ‪ ١٠‬ﺭﺍ ﺑﺪﻫﻴﺪ ‪.‬‬ ‫} ‪{t / t‬‬

‫ﺗﻤﺮﻳﻨﺎﺕ ﺍﻳﻦ ﻓﺼﻞ ‪:‬‬

‫‪t[ status ] > 10‬‬

‫^‬

‫‪S‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٥٩ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٦٠ /‬‬

‫ﻓﺼﻞ ﭘﻨﺠﻢ ‪:‬‬ ‫ﺁﺷﻨﺎﻳﻲ ﺑﺎ ﺯﺑﺎﻥ‬

‫‪SQL‬‬

‫‪ -١-٥‬ﻣﻘﺪﻣﻪ ‪:‬‬ ‫‪ SQL‬ﻳـﻚ ﺯﺑـﺎﻥ ﺍﺳﺘﺎﻧﺪﺍﺭﺩ ﺑﺮﺍﻱ ﻛﺎﺭ ﺭﻭﻱ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺭﺍﺑﻄﻪ ﺍﻱ ﺍﺳﺖ ﻭ ﻫﺮ ﻣﺤﺼﻮﻝ ﻧﺮﻡ ﺍﻓﺰﺍﺭﻱ ﻣﻮﺟﻮﺩ ﺩﺭ ﺑﺎﺯﺍﺭ ﺍﺯ‬ ‫ﺁﻥ ﭘﺸـﺘﻴﺒﺎﻧﻲ ﻣـﻲ ﻛـﻨﺪ ‪ SQL .‬ﺍﻭﻟـﻴﻦ ﺑـﺎﺭ ﺩﺭ ﺍﻭﺍﻳـﻞ ﺩﻫﻪ ‪ ١٩٦٠‬ﺩﺭ ﺑﺨﺶ ﺗﺤﻘﻴﻘﺎﺕ ‪ IBM‬ﻃﺮﺍﺣﻲ ﺷﺪ ﻭ ﺑﺮﺍﻱ ﺍﻭﻟﻴﻦ ﺑﺎﺭ ﺩﺭ‬ ‫ﻣﻘـﻴﺎﺱ ﺑـﺰﺭﮒ ﺭﻭﻱ ﻛﺎﻣﭙﻴﻮﺗـﺮﻫﺎﻱ ‪ IBM‬ﺑـﻪ ﻧـﺎﻡ ﺳﻴﺴﺘﻢ ‪ R‬ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ ﺷﺪ ﻭ ﺳﭙﺲ ﺑﺮ ﺭﻭﻱ ﺍﻧﻮﺍﻉ ﻣﺘﻌﺪﺩﻱ ﺍﺯ ﻣﺤﺼﻮﻻﺕ‬ ‫ﺗﺠﺎﺭﻱ ﺩﺭ ‪ IBM‬ﻭ ﻣﺤﺼﻮﻻﺕ ﺩﻳﮕﺮ ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ ﺷﺪ ‪ .‬ﺩﺭ ﺍﻳﻦ ﻓﺼﻞ ﺯﺑﺎﻥ ‪ SQL‬ﻣﻮﺭﺩ ﺑﺤﺚ ‪ SQL 92‬ﻳﺎ ‪ SQL 2‬ﺍﺳﺖ ﻛﻪ‬ ‫ﻧﺎﻡ ﺭﺳﻤﻲ ﺁﻥ )‪ International Standard Database Language SQL (1992‬ﻣﻲ ﺑﺎﺷﺪ ‪.‬‬ ‫‪ SQL‬ﺑﺠـﺎﻱ ﺩﻭ ﺍﺻـﻄﻼﺡ ﺭﺍﺑﻄـﻪ ﻭ ﻣﺘﻐﻴـﺮ ﺭﺍﺑﻄـﻪ ﺍﻱ ﺍﺯ ﺍﺻﻄﻼﺡ ﺟﺪﻭﻝ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﻛﻨﺪ ‪ S QL .‬ﺗﺎ ﺗﺒﺪﻳﻞ ﺷﺪﻥ ﺑﻪ ﻳﻚ‬ ‫ﺯﺑـﺎﻥ ﺭﺍﺑﻄـﻪ ﺍﻱ ﻛﺎﻣـﻞ ﻓﺎﺻﻠﻪ ﺯﻳﺎﺩﻱ ﺩﺍﺭﺩ ‪ .‬ﺑﺎ ﺍﻳﻦ ﻫﻤﻪ ‪ SQL‬ﺍﺳﺘﺎﻧﺪﺍﺭﺩ ﺍﺳﺖ ﻭ ﺗﻘﺮﻳﺒﺎ ﺗﻮﺳﻂ ﻫﺮ ﻣﺤﺼﻮﻝ ﻧﺮﻡ ﺍﻓﺰﺍﺭﻱ ﺑﺎﻧﻚ‬ ‫ﺍﻃﻼﻋﺎﺕ ﭘﺸﺘﻴﺒﺎﻧﻲ ﻣﻲ ﺷﻮﺩ ﻭ ﻫﺮ ﻓﺮﺩ ﺣﺮﻓﻪ ﺍﻱ ﻧﻴﺎﺯﻣﻨﺪ ﺁﻥ ﺍﺳﺖ ‪.‬‬ ‫‪ -٢-٥‬ﺍﺣﻜﺎﻡ ﺗﻌﺮﻳﻒ ﺩﺍﺩﻩ ﻫﺎ ) ‪ ( DDL‬ﺩﺭ ‪SQL‬‬

‫ﺍﻳﻦ ﺍﺣﻜﺎﻡ ﺷﺎﻣﻞ ﺗﻌﺮﻳﻒ ﺟﺪﺍﻭﻝ ‪ ،‬ﺷﺎﺧﺺ ‪ ،‬ﺣﺬﻑ ﺟﺪﺍﻭﻝ ‪ ،‬ﺷﺎﺧﺺ ﻭ ﺗﻐﻴﻴﺮﺍﺕ ﻣﻲ ﺑﺎﺷﺪ ‪.‬‬ ‫ﺍﻧﻮﺍﻉ ﺩﺍﻣﻨﻪ ﻫﺎ ﺩﺭ ‪ SQL‬ﺑﻪ ﺷﺮﺡ ﺯﻳﺮ ﺍﺳﺖ ‪:‬‬ ‫•‬

‫)‪ Char (n‬ﻳﻚ ﺭﺷﺘﻪ ﻛﺎﺭﺍﻛﺘﺮﻱ ﺑﺎ ﻃﻮﻝ ﺛﺎﺑﺖ ﻛﻪ ﺗﻮﺳﻂ ﻛﺎﺭﺑﺮ ‪ n‬ﻣﺸﺨﺺ ﻣﻲ ﺷﻮﺩ ‪.‬‬

‫•‬

‫)‪ Varchar (n‬ﺭﺷﺘﻪ ﻫﺎﻱ ﺑﺎ ﻃﻮﻝ ﻣﺘﻐﻴﺮ ﺣﺪﺍﻛﺜﺮ ﺑﻪ ﻃﻮﻝ ‪n‬‬

‫ﺩﺭ ‪ Oracle‬ﻧﻮﻉ ‪ Varchar2‬ﺑﺮﺍﻱ ﺭﺷﺘﻪ ﻫﺎﻱ ﺑﺎ ﻃﻮﻝ ﻣﺘﻐﻴﺮ ﻭ ﺣﺪﺍﻛﺜﺮ ‪٢٠٠٠‬ﻛﺎﺭﺍﺗﺮ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺍﺳﺖ‪.‬‬ ‫•‬

‫‪ Int‬ﺍﻋﺪﺍﺩ ﺻﺤﻴﺢ‬

‫•‬

‫‪ Small int‬ﺍﻋﺪﺍﺩ ﻛﻮﭼﻚ‬

‫•‬

‫)‪ Numeric (p,d‬ﺍﻋﺪﺍﺩ ﺍﻋﺸﺎﺭﻱ ‪ p‬ﺣﺪﺍﻛﺜﺮﺗﻌﺪﺍﺩ ﺭﻗﻤﻬﺎ ﻭ ‪d‬ﺗﻌﺪﺍﺩ ﺭﻗﻢ ﻫﺎﻱ ﺍﻋﺸﺎﺭﻱ ‪.‬‬

‫•‬ ‫•‬

‫‪Double , real‬‬ ‫)‪ Float(n‬ﺍﻋﺪﺍﺩ ﺍﻋﺸﺎﺭﻱ ﺑﺎ ﺩﻗﺖ ﺣﺪﺍﻗﻞ ‪ n‬ﺭﻗﻢ ‪.‬‬

‫•‬

‫‪ Not null‬ﻣﻲ ﺗﻮﺍﻧﺪ ﺩﺭ ﺍﻧﺘﻬﺎﻱ ﺗﻌﺮﻳﻒ ﻓﻴﻠﺪ ﺑﻪ ﻛﺎﺭ ﺭﻭﺩ ﺑﻄﻮﺭﻳﻜﻪ ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﻮﺭﺩ ﻧﻈﺮ ﻧﻤﻲ ﺗﻮﺍﻧﺪ ﻣﻘﺪﺍﺭ ‪null‬‬

‫ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ‪.‬‬ ‫•‬

‫‪ Date‬ﺗﺎﺭﻳﺦ ﺷﺎﻣﻞ ‪ ٤‬ﺭﻗﻢ ﺑﺮﺍﻱ ﺳﺎﻝ ‪ ،‬ﻣﺎﻩ ﻭ ﺭﻭﺯ ‪:‬‬

‫•‬

‫‪ Time‬ﺑﺮﺍﻱ ﻧﻤﺎﻳﺶ ﺳﺎﻋﺖ ‪.‬‬

‫‪ : 2001 – 7 – 27‬ﻣﺜﺎﻝ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٦١ /‬‬

‫‘ ‪‘09 : 00 : 30‬‬ ‫‘ ‪‘09 : 00 : 30 : 75‬‬

‫•‬

‫‪time‬‬ ‫‪time‬‬

‫‪ Timestamp‬ﺷﺎﻣﻞ ﺗﺎﺭﻳﺦ ﻭ ﺯﻣﺎﻥ‬

‫‪Timestamp :’ 2001 – 1 – 27 09 :‬‬ ‫’‪30: 27 . 75‬‬

‫•‬

‫‪ Interval‬ﺩﻭﺭﻩ ﻫﺎﻱ ﺯﻣﺎﻧﻲ‬ ‫‪‘1’ day‬‬

‫ﻣﺜﺎﻝ ‪:‬‬

‫‪interval‬‬

‫ﻣﻘﺎﺩﻳﺮ ‪ Interval‬ﻣﻲ ﺗﻮﺍﻧﻨﺪ ﺑﻪ ﻣﻘﺎﺩﻳﺮ ‪ date / time / timestamp‬ﺍﺿﺎﻓﻪ ﺷﻮﻧﺪ ‪.‬‬ ‫•‬

‫ﺍﻣﻜﺎﻥ ﺍﺳﺘﺨﺮﺍﺝ ﻓﻴﻠﺪ ﺍﺯ ﺩﺍﺩﻩ ﻫﺎﻱ ﺗﺎﺭﻳﺦ ﻭ ﺯﻣﺎﻥ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪.‬‬ ‫)‪extract (year from r . time 1‬‬

‫•‬

‫ﺍﻣﻜﺎﻥ ﺗﺒﺪﻳﻞ ﺭﺷﺘﻪ ﺑﻪ ﺗﺎﺭﻳﺦ ﻭ ﺯﻣﺎﻥ ﻧﻴﺰ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪.‬‬ ‫‪date‬‬

‫•‬

‫‪as‬‬

‫> ‪< string – valued expression‬‬

‫‪cast‬‬

‫ﺩﺭ ‪ SQL 92‬ﺍﻣﻜﺎﻥ ﺗﻌﺮﻳﻒ ﺩﺍﻣﻨﻪ ﻧﻴﺰ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ﻛﻪ ﺑﺮﺍﻱ ﺍﻳﻨﻜﺎﺭ ﺩﺳﺘﻮﺭ ﺯﻳﺮ ﺑﺎﻳﺴﺘﻲ ﻧﻮﺷﺘﻪ ﺷﻮﺩ ‪:‬‬ ‫] ‪[ not null‬‬

‫ﻧﻮﻉ‬

‫‪Create domain‬‬

‫ﻧﺎﻡ ﺟﺪﻳﺪ‬

‫)‪create domain Dollars numeric(12, 2‬‬

‫)‪create domain AccountType char(10‬‬ ‫‪constraint account-type-test‬‬ ‫))’‪check (value in (‘Checking’, ‘Saving‬‬ ‫‪ : ١– ٢-٥‬ﺩﺳﺘﻮﺭﺍﺕ ﺗﻌﺮﻳﻒ ﺟﺪﺍﻭﻝ‬ ‫)) ‪r ( A1 D1 , A2 D2 ,... An Dn ..., ( integrity – constraint k‬‬ ‫* ‪ r‬ﻧﺎﻡ ﺭﺍﺑﻄﻪ ﺍﺳﺖ ‪.‬‬

‫‪table‬‬

‫‪Create‬‬

‫* ﻫﺮ ‪ Ai‬ﻧﺎﻡ ﺻﻔﺖ ﺧﺎﺻﻪ ﺩﺭ ﺷﻤﺎﻱ ‪ r‬ﺍﺳﺖ ‪.‬‬ ‫* ‪ Di‬ﻧﻮﻉ ﺩﺍﺩﻩ ﺍﻱ ﺩﺭ ﺩﺍﻣﻨﻪ ﺻﻔﺖ ﺧﺎﺻﻪ ‪ Ai‬ﺍﺳﺖ ‪ .‬ﻣﺜﺎﻝ ‪:‬‬ ‫‪not null ,‬‬

‫)‪char (15‬‬ ‫‪char (30) ,‬‬ ‫) ‪integer‬‬

‫‪Create table branch‬‬ ‫‪( branch – name‬‬ ‫‪branch –city‬‬ ‫‪assest‬‬

‫ﻣﺤﺪﻭﺩﻳﺖ ﻫﺎﻱ ﺟﺎﻣﻌﻴﺖ ﺩﺭ ﺗﻌﺮﻳﻒ ﺟﺪﺍﻭﻝ ‪:‬‬ ‫‪not null‬‬ ‫) ‪Primary key ( A1 ,... An‬‬

‫ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺍﻧﺘﺨﺎﺏ ‪ not null‬ﺭﺍ ﺑﻄﻮﺭ ﺧﻮﺩﻛﺎﺭ ﺑﺮﺍﻱ ﻓﻴﻠﺪ ﺩﺭ ﻧﻈﺮ ﺧﻮﺍﻫﺪ ﮔﺮﻓﺖ ‪.‬‬ ‫•‬

‫) ‪ Check ( P‬ﻛﻪ ‪ P‬ﺷﺮﻁ ﺍﺳﺖ ﺑﺮﺍﻱ ﻛﻨﺘﺮﻝ ﻣﻘﺪﺍﺭ ﻓﻴﻠﺪﻫﺎ ‪.‬‬

‫•‬ ‫•‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٦٢ /‬‬

‫‪FOREGIN Key ( A1 ... ) References‬‬

‫•‬

‫ﻣﺜﺎﻝ‪:‬‬ ‫‪Create‬‬ ‫‪table‬‬ ‫‪branch‬‬ ‫‪(branch – neme‬‬ ‫‪char (15) ,‬‬ ‫‪Branch – city‬‬ ‫‪char (30) ,‬‬ ‫‪Assests‬‬ ‫‪Integer ,‬‬ ‫‪Primary key‬‬ ‫‪( branch – name ) ,‬‬ ‫)) ‪Check ( assests > = 0‬‬ ‫‪Create table‬‬ ‫‪S‬‬ ‫‪( SNO‬‬ ‫‪char (5) ,‬‬ ‫‪sname‬‬ ‫‪char (20) ,‬‬ ‫‪status‬‬ ‫‪Numeric (5) ,‬‬ ‫‪city‬‬ ‫‪char (15) ,‬‬ ‫; )) ‪Primary key ( SNO‬‬ ‫‪Create table‬‬ ‫‪P‬‬ ‫‪( PNO‬‬ ‫‪char (6) ,‬‬ ‫‪color‬‬ ‫‪char (20) ,‬‬ ‫‪weight‬‬ ‫‪Numeric (5,1) ,‬‬ ‫‪city‬‬ ‫‪char (15) ,‬‬ ‫‪Primary key‬‬ ‫‪( PNO )) ,‬‬ ‫‪Create table‬‬ ‫‪SP‬‬ ‫‪( SNO‬‬ ‫‪char (5) ,‬‬ ‫‪PNO‬‬ ‫‪char (6) ,‬‬ ‫‪Qty‬‬ ‫‪Numeric (9) ,‬‬ ‫‪Primary key ( SNO , PNO ) ,‬‬ ‫‪Foreign key ( PNO ) References‬‬ ‫‪P,‬‬ ‫‪Foreign key ( SNO ) References‬‬ ‫;‪S‬‬ ‫‪ : ٢ – ٢ – ٦‬ﺣﺬﻑ ﻭ ﺗﻐﻴﻴﺮ ﺟﺪﺍﻭﻝ ‪D rop and Alter tables‬‬

‫ﻋﺒﺎﺭﺕ ‪ Drop table‬ﺗﻤﺎﻡ ﺍﻃﻼﻋﺎﺕ ﻳﻚ ﺟﺪﻭﻝ ﻭ ﺧﻮﺩ ﺟﺪﻭﻝ ﺭﺍ ﺍﺯ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺣﺬﻑ ﻣﻲ ﻛﻨﺪ ﻭ ﻋﺒﺎﺭﺕ‬

‫‪a lter‬‬

‫‪ table‬ﺑﺮﺍﻱ ﺍﺿﺎﻓﻪ ﻛﺮﺩﻥ ﻭ ﻳﺎ ﺣﺬﻑ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺑﻪ ﺟﺪﻭﻝ ﻣﻮﺟﻮﺩ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ ‪ .‬ﺑﺎ ﺍﺿﺎﻓﻪ ﻛﺮﺩﻥ ﺻﻔﺖ ﺧﺎﺻﻪ ﺟﺪﻳﺪ‬ ‫ﺗﻤﺎﻣﻲ ﺗﺎﭘﻠﻬﺎﻱ ﺭﺍﺑﻄﻪ ﻣﻘﺪﺍﺭ ‪ null‬ﺭﺍ ﺑﺮﺍﻱ ﺁﻥ ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﻲ ﮔﻴﺮﻧﺪ ‪ .‬ﻓﺮﻡ ﻛﻠﻲ ﺩﺳﺘﻮﺭ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ ‪:‬‬ ‫‪alter table r add A D‬‬ ‫‪ A‬ﺍﺳﻢ ﺻﻔﺖ ﻓﺎﺻﻠﻪ ﺟﺪﻳﺪ ﻭ ‪ D‬ﺩﺍﻣﻨﻪ ﺁﻥ ﻣﻲ ﺑﺎﺷﺪ ‪.‬‬

‫‪ Alter table r drop A‬ﺻﻔﺖ ﺧﺎﺻﻪ ﺭﺍ ﺍﺯ ﺟﺪﻭﻝ ﺣﺬﻑ ﻣﻲ ﻛﻨﺪ ‪.‬‬ ‫•‬

‫ﺍﻳﻦ ﺩﺳﺘﻮﺭ ) ﺩﺭ ﻋﻤﻞ ﺣﺬﻑ ﺻﻔﺖ ﺧﺎﺻﻪ ( ﺗﻮﺳﻂ ﺑﻴﺸﺘﺮ ﺑﺎﻧﻜﻬﺎﻱ ﺍﻃﻼﻋﺎﺗﻲ ﭘﺸﺘﻴﺒﺎﻧﻲ ﻧﻤﻲ ﺷﻮﺩ ‪.‬‬

‫‪NewType‬‬

‫•‬

‫‪Modify A‬‬

‫‪r‬‬

‫‪Alter table‬‬

‫ﺍﻳﻦ ﺩﺳﺘﻮﺭ ﺑﺮﺍﻱ ﺗﻐﻴﻴﺮ ﻧﻮﻉ ﻳﻚ ﺻﻔﺖ ﺧﺎﺻﻪ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ‪.‬‬

‫‪ : ٣ – ٦‬ﺍﺣﻜﺎﻡ ﻛﺎﺭ ﺑﺎ ﺩﺍﺩﻩ ﻫﺎ ﺩﺭ ‪SQL‬‬

‫ﺩﺭ ‪ SQL‬ﭼﻬﺎﺭ ﺩﺳﺘﻮﺭ ﺍﺳﺎﺳﻲ ﺑﺮﺍﻱ ﻛﺎﺭ ﺑﺎ ﺩﺍﺩﻩ ﻫﺎ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪:‬‬ ‫•‬ ‫•‬

‫‪SELECT‬‬ ‫‪UPDATE‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬ ‫•‬

‫•‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٦٣ /‬‬

‫‪DELETE‬‬ ‫‪INSERT‬‬

‫‪ : ١ – ٣ – ٦‬ﺍﺣﻜﺎﻡ ﺑﺎﺯﻳﺎﺑﻲ ﺩﺍﺩﻩ ﻫﺎ‬ ‫ﺩﺭ ‪ SQL‬ﺗـﻨﻬﺎ ﻳـﻚ ﺣﻜـﻢ ﻭﺍﺣـﺪ ﺑﺮﺍﻱ ﺑﺎﺯﻳﺎﺑﻲ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ﻭ ﺁﻥ ﺩﺳﺘﻮﺭ ‪ SELECT‬ﺍﺳﺖ ‪ .‬ﺷﻜﻞ ﻛﻠﻲ ﺍﻳﻦ ﺩﺳﺘﻮﺭ ﺑﻪ ﻓﺮﻡ‬ ‫ﺯﻳﺮ ﻣﻲ ﺑﺎﺷﺪ ‪:‬‬ ‫‪A1 , A2 ,... An‬‬ ‫‪r1 , r2 ,...rm‬‬

‫]‪P‬‬ ‫] ‪columns‬‬ ‫]‪P‬‬ ‫‪BY‬‬ ‫‪A1 ... Ak‬‬

‫‪SELECT‬‬ ‫‪FROM‬‬ ‫‪[where‬‬ ‫‪[ Group by‬‬ ‫‪[ Having‬‬ ‫‪[ ORDER‬‬

‫‪ Ai‬ﻫﺎ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻭ ‪ Ri‬ﻫﺎ ﺭﺍﺑﻄﻪ ﻫﺎ ﻭ ‪ P‬ﺷﺮﻁ ﺍﺳﺖ ‪.‬‬ ‫ﺩﺭ ﺻﻮﺭﺕ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺳﻪ ﻗﺴﻤﺖ ﺍﻭﻝ ﭘﺮﺱ ﻭ ﺟﻮ ﻣﻌﺎﺩﻝ ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﺯﻳﺮ ﻣﻲ ﺑﺎﺷﺪ ‪:‬‬ ‫)‬

‫) ‪( r1 × r2 ,...rn‬‬

‫‪π A1 , A2 ,... An (σ P‬‬

‫ﻋـﺒﺎﺭﺕ ﺟﻠـﻮﻱ ﺩﺳـﺘﻮﺭ ‪ select‬ﻣﻌـﺎﺩﻝ ﻋﻤـﻞ ﭘـﺮﺗﻮ ﺩﺭ ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﺍﺳﺖ ﻭ ﻋﺒﺎﺭﺕ ﺟﻠﻮﻱ ‪ where‬ﻣﻌﺎﺩﻝ ﻫﻤﺎﻥ ﺗﺤﺪﻳﺪ ﻳﺎ‬ ‫ﮔﺰﻳﻨﺶ ﺍﺳﺖ ‪ .‬ﺑﺮﺧﻲ ﻧﻜﺎﺕ ﻣﻬﻢ ﺍﻳﻦ ﺩﺳﺘﻮﺭ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ ‪:‬‬ ‫•‬

‫ﻋﺒﺎﺭﺕ ) * ( ﺩﺭ ﺟﻠﻮﻱ ‪ select‬ﻣﻌﺎﺩﻝ ﺗﻤﺎﻡ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺭﺍﺑﻄﻪ ﺍﺳﺖ ‪.‬‬

‫•‬

‫ﺩﺭ ‪ SQL‬ﻣﻤﻜـﻦ ﺍﺳـﺖ ﻧﺘـﻴﺠﻪ ﭘـﺮﺱ ﻭ ﺟﻮ ﺣﺎﻭﻱ ﺩﺍﺩﻩ ﻫﺎﻱ ﺗﻜﺮﺍﺭﻱ ﺑﺎﺷﺪ ﻟﺬﺍ ﺑﺮﺍﻱ ﺣﺬﻑ ﻣﻘﺎﺩﻳﺮ ﺗﻜﺮﺍﺭﻱ ﻛﻠﻤﻪ‬ ‫‪ distinct‬ﺭﺍ ﺑﺎﻳﺴﺘﻲ ﺑﻌﺪ ﺍﺯ ‪ select‬ﺑﻜﺎﺭ ﺑﺮﺩ ‪.‬‬ ‫‪A1 ,...‬‬

‫‪distinct‬‬ ‫‪ri‬‬

‫•‬

‫ﺩﺭ ﺻﻮﺭﺕ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﻛﻠﻤﻪ ‪ all‬ﺑﻌﺪ ﺍﺯ ‪ select‬ﺣﺬﻑ ﻣﻘﺎﺩﻳﺮ ﺗﻜﺮﺍﺭﻱ ﺍﻧﺠﺎﻡ ﻧﺨﻮﺍﻫﺪ ﮔﺮﻓﺖ ‪.‬‬

‫•‬

‫ﺩﺭ ﺟﻠﻮﻱ ‪ select‬ﻣﻲ ﺗﻮﺍﻥ ﺍﺯ ﻋﺒﺎﺭﺍﺕ ﺭﻳﺎﺿﻲ ﺷﺎﻣﻞ ﻋﻤﻠﮕﺮﻫﺎﻱ ‪ +‬ﻭ – ﻭ * ﻭ ‪ /‬ﻧﻴﺰ ﺍﺳﺘﻔﺎﺩﻩ ﻛﺮﺩ ‪.‬‬

‫•‬

‫‪S# , P# , Qty * 5‬‬ ‫‪from SP‬‬ ‫ﺩﺭ ﺟﻠﻮﻱ ﻋﺒﺎﺭﺕ ‪ where‬ﺷﺮﻁ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ ﻛﻪ ﻣﻲ ﺗﻮﺍﻧﺪ ﺑﺎ ‪ or ، and‬ﻭ ‪ not‬ﻧﻴﺰ ﺗﺮﻛﻴﺐ ﺷﻮﺩ ‪.‬‬

‫•‬

‫ﺩﺭ ﺷﺮﻁ ﺟﻠﻮﻱ ‪ where‬ﺍﺯ ﻋﺒﺎﺭﺕ ‪ between‬ﻧﻴﺰ ﻣﻲ ﺗﻮﺍﻥ ﺍﺳﺘﻔﺎﺩﻩ ﻛﺮﺩ ‪.‬‬ ‫‪5‬‬

‫‪and‬‬

‫‪2‬‬

‫‪between‬‬

‫‪SP‬‬ ‫‪Qty‬‬

‫‪From‬‬ ‫‪Where‬‬

‫*‬

‫‪Select‬‬ ‫‪From‬‬

‫‪Select‬‬

‫‪Select‬‬

‫•‬

‫ﺍﮔﺮ ﭼﻨﺪ ﺟﺪﻭﻝ ﺟﻠﻮﻱ ﻋﺒﺎﺭﺕ ‪ f rom‬ﺁﻭﺭﺩﻩ ﺷﻮﺩ ﺑﻪ ﻣﻨﺰﻟﻪ ﺣﺎﺻﻠﻀﺮﺏ ﺩﻛﺎﺭﺗﻲ ﺭﺍﺑﻄﻪ ﻫﺎﺳﺖ ‪.‬‬

‫•‬

‫ﺩﺭ ‪ SQL‬ﺍﻣﻜـﺎﻥ ﺩﻭﺑـﺎﺭﻩ ﻧﺎﻣـﻴﺪﻥ ﺭﺍﺑﻄﻪ ﻭ ﻳﺎ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﻋﺒﺎﺭﺕ ‪ as‬ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪ .‬ﻗﺎﻟﺐ ﻛﻠﻲ ﺩﺳﺘﻮﺭ‬ ‫ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ ‪:‬‬

‫•‬

‫‪as‬‬ ‫‪new name‬‬ ‫‪new name‬‬ ‫ﻣﺘﻐﻴﺮﻫﺎﻱ ﺗﺎﭘﻠﻲ ﺩﺭ ﻋﺒﺎﺭﺕ ﺑﻌﺪ ﺍﺯ ‪ From‬ﺍﺯ ﻃﺮﻳﻖ ﻛﻠﻤﻪ ‪ as‬ﺗﻌﺮﻳﻒ ﻣﻲ ﺷﻮﻧﺪ ‪.‬‬

‫‪Oldname‬‬ ‫‪ Oldname‬ﻭ ﻳﺎ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٦٤ /‬‬ ‫*‬

‫‪Tsp‬‬

‫•‬

‫‪as‬‬

‫‪SP‬‬

‫‪as‬‬ ‫‪TS‬‬ ‫‪,‬‬ ‫‪TS.S# = Tsp.S#‬‬

‫‪Select‬‬

‫‪From‬‬ ‫‪S‬‬ ‫‪Where‬‬

‫ﻋـﺒﺎﺭﺕ ‪ ORDER BY‬ﺑـﻪ ﻣﻌﻨـﻲ ﺁﻥ ﺍﺳـﺖ ﻛﻪ ﻛﺎﺭﺑﺮ ﻣﻲ ﺧﻮﺍﻫﺪ ﺟﻮﺍﺏ ﺭﺍ ﺑﻄﻮﺭ ﻣﻨﻈﻢ ﺭﻭﻱ ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﻮﺭﺩ‬ ‫ﻧﻈﺮﺵ ﺑﺒﻴﻨﺪ ‪ .‬ﺩﺭ ﺻﻮﺭﺗﻲ ﻛﻪ ﺩﺭ ﺍﻧﺘﻬﺎ ﻋﺒﺎﺭﺕ ‪ d esc‬ﺑﻴﺎﻳﺪ ﺗﺮﺗﻴﺐ ﻧﺰﻭﻟﻲ ﻭ ﺍﮔﺮ ‪ asc‬ﺑﻴﺎﻳﺪ ﺗﺮﺗﻴﺐ ﺻﻌﻮﺩﻱ ﺍﺳﺖ ‪.‬‬ ‫‪desc‬‬

‫ﻣﺜﺎﻝ ‪:‬‬ ‫•‬

‫‪by‬‬

‫‪S#‬‬

‫‪order‬‬

‫ﺩﺭ ﺻـﻮﺭﺕ ﺍﺳـﺘﻔﺎﺩﻩ ﺍﺯ ﭼﻨﺪ ﺟﺪﻭﻝ ﺩﺭ ﺟﻠﻮﻱ ﻋﺒﺎﺭﺕ ‪ from‬ﻭ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺷﺮﻁ ﺧﺎﺹ ﻣﻲ ﺗﻮﺍﻥ ﻋﻤﻞ ﭘﻴﻮﻧﺪ ﺭﺍ ﻧﻴﺰ‬ ‫ﺍﻧﺠﺎﻡ ﺩﺍﺩ ‪.‬‬

‫ﻣﺜﺎﻝ ‪ :‬ﻣﺸﺨﺼﺎﺕ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﻭ ﻗﻄﻌﺎﺕ ﺩﺭ ﻳﻚ ﺷﻬﺮ ﺭﺍ ﺑﺪﻫﻴﺪ ‪.‬‬ ‫‪S,P‬‬

‫‪from‬‬

‫* ‪Select S . * , P .‬‬ ‫‪S . city = P . city‬‬

‫•‬

‫ﻣﻲ ﺗﻮﺍﻥ ﻋﻤﻞ ﭘﻴﻮﻧﺪ ﺭﺍ ﺑﺎ ﺷﺮﻃﻬﺎﻱ ﺍﺿﺎﻓﻲ ﻧﻴﺰ ﺍﻧﺠﺎﻡ ﺩﺍﺩ ‪.‬‬ ‫‪S . Status > 10‬‬

‫•‬

‫‪Where‬‬

‫‪Select S . * , P . * from S , P‬‬ ‫‪Where S . city = P . city‬‬ ‫‪AND‬‬

‫ﻧﻜﺘﻪ ‪ :‬ﻣﻲ ﺗﻮﺍﻥ ﻳﻚ ﺟﺪﻭﻝ ﺭﺍ ﺑﺎ ﺧﻮﺩﺵ ﻧﻴﺰ ﺗﺮﻛﻴﺐ ) ﭘﻴﻮﻧﺪ ( ﻛﺮﺩ ‪.‬‬

‫ﻣﺜﺎﻝ ‪ :‬ﺷﻤﺎﺭﻩ ﺟﻔﺖ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﺳﺎﻛﻦ ﻳﻚ ﺷﻬﺮ ﺭﺍ ﺑﺪﻫﻴﺪ ‪.‬‬ ‫‪Select First . S # , Second . S #‬‬ ‫‪First , S‬‬ ‫‪Second‬‬ ‫‪First . city = Second . city‬‬ ‫‪AND First . S # < Second . S #‬‬

‫•‬

‫‪S‬‬

‫‪From‬‬ ‫‪Where‬‬

‫ﺩﺭ ﺯﺑـﺎﻥ ‪ SQL‬ﺍﻣﻜـﺎﻥ ﻣﻘﺎﻳﺴـﻪ ﺭﺷـﺘﻪ ﻫـﺎ ﻭ ﺗﻄﺎﺑـﻖ ﺁﻧﻬﺎ ﻧﻴﺰ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪ .‬ﺍﻳﻦ ﺍﻣﻜﺎﻥ ﺗﻮﺳﻂ ﺩﻭ ﻋﻤﻠﮕﺮ ‪ %‬ﻭ – ﻣﻴﺴﺮ‬ ‫ﺍﺳـﺖ‪ :‬ﻋﻼﻣـﺖ ﺩﺭﺻﺪ ‪ %‬ﺑﺮﺍﻱ ﺗﻄﺎﺑﻖ ﻫﺮ ﺯﻳﺮ ﺭﺷﺘﻪ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ ﻭ ﻋﻼﻣﺖ ‪ u nderline‬ـ ﺑﺮﺍﻱ ﺗﻄﺎﺑﻖ ﻳﻚ ﻛﺎﺭﺍﻛﺘﺮ‬ ‫ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ ‪.‬‬

‫… ‪Select P# ,‬‬ ‫‪From P‬‬ ‫‪Where Pname like‬‬

‫“‪” w %‬‬

‫‪ w %‬ﻳﻌﻨﻲ ﺁﻧﻬﺎﻳﻲ ﻛﻪ ﺑﺎ ‪ w‬ﺁﻏﺎﺯ ﺷﺪﻩ ﺍﻧﺪ ‪ .‬ﻭ ” ‪ “% W‬ﻳﻌﻨﻲ ﺁﻧﻬﺎﻳﻲ ﻛﻪ ﺑﻪ ‪ w‬ﺧﺘﻢ ﺷﺪﻩ ﺍﻧﺪ ‪.‬‬ ‫‪S‬‬ ‫‘‪‘% C ---‬‬

‫‪like‬‬

‫‪city‬‬

‫*‬ ‫‪From‬‬

‫‪Select‬‬

‫‪Where‬‬

‫ﺷﻬﺮ ﺣﺪﺍﻗﻞ ﭼﻬﺎﺭ ﺣﺮﻑ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ﻭ ﭼﻬﺎﺭﻣﻴﻦ ﺣﺮﻑ ﺍﺯ ﺁﺧﺮ ﺑﺎ ‪ C‬ﺁﻏﺎﺯﺷﻮﺩ ‪.‬‬ ‫’_ _‪SELECT SNAME FROM S WHERE SNAME LIKE ‘C‬‬

‫ ﺍﺳﺎﻣﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻧﻲ ﻛﻪ ﺩﻗﻴﻘﺎ ﺳﻪ ﺣﺮﻑ ﺩﺍﺷﺘﻪ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ‪.‬‬‫ﺩﺭ ﺻﻮﺭﺗﻲ ﻛﻪ ﻋﺪﻡ ﺗﻄﺎﺑﻖ ﺑﺨﻮﺍﻫﺪ ﭼﻚ ﺷﻮﺩ ﻣﻲ ﺗﻮﺍﻥ ﺑﻪ ﺟﺎﻱ ‪ L I K E‬ﺍﺯ ‪ NOT LIKE‬ﺍﺳﺘﻔﺎﺩﻩ ﻧﻤﻮﺩ ‪.‬‬ ‫•‬

‫ﺍﻟﺤﺎﻕ ﺭﺷﺘﻪ ﻫﺎ ﺩﺭ ‪ SQL‬ﺗﻮﺳﻂ ﻋﻤﻠﮕﺮ || ﺍﻧﺠﺎﻡ ﻣﻲ ﮔﻴﺮﺩ ‪.‬‬

٦٥ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

‫ ﺑــﺮﺍﻱ ﺍﺟـﺘﻤﺎﻉ ﻭ ﻋــﺒﺎﺭﺕ‬UNION ‫ ﻋـﺒﺎﺭﺕ‬. ‫ ﻭﺟـﻮﺩ ﺩﺍﺭﻧــﺪ‬SQL ‫ﻋﻤﻠـﻴﺎﺕ ﺍﺟـﺘﻤﺎﻉ ﻭ ﺍﺷــﺘﺮﺍﻙ ﻭ ﻧﻘـﻴﺾ ﻧﻴــﺰ ﺩﺭ‬



.‫ ﺑﺮﺍﻱ ﻋﻤﻠﮕﺮ ﻣﻨﻬﺎ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﻧﺪ‬EXCEPT ‫ ﺑﺮﺍﻱ ﺍﺷﺘﺮﺍﻙ ﻭ ﻋﺒﺎﺭﺕ‬INTERSECT ‫ ﺁﻧﻬﺎ ﺭﺍ ﺗﻬﻴﻪ ﻛﺮﺩﻩ‬S2 ‫ ﭘﻮﻧﺪ ﺑﺎﺷﺪ ﻭ ﻳﺎ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ‬١٦ ‫ ﺷـﻤﺎﺭﻩ ﻗﻄﻌﺎﺗـﻲ ﺭﺍ ﻣﺸـﺨﺺ ﻛﻨـﻴﺪ ﻛﻪ ﻳﺎ ﻭﺯﻥ ﺁﻧﻬﺎ ﺑﻴﺶ ﺍﺯ‬: ‫ﻣـﺜﺎﻝ‬ . ‫ﺑﺎﺷﺪ‬ SELECT P.P# FROM P WHERE WEIGHT > 16.0 UNION SELECT SP.P# FROM SP WHERE SP.S# = ‘S2’ ‫ ﺍﻣﺎ‬. ‫ ﺣﺬﻑ ﻣﻲ ﺷﻮﻧﺪ‬EXCEPT ‫ ﻭ ﻳﺎ‬INTERSECT ، U NION ‫ﺳﻄﺮﻫﺎﻱ ﺗﻜﺮﺍﺭﻱ ﺍﺿﺎﻓﻲ ﻫﻤﻴﺸﻪ ﺍﺯ ﻧﺘﻴﺠﻪ ﻳﻚ‬

. ‫ ﻓﺮﺍﻫﻢ ﺷﺪﻩ ﻛﻪ ﺩﺭ ﺁﻥ ﺳﻄﺮﻫﺎﻱ ﺗﻜﺮﺍﺭﻱ ﺑﺎﻗﻲ ﻣﻲ ﻣﺎﻧﻨﺪ‬EXCEPT ALL ، UNION ALL ‫ ﻧﺴﺨﻪ ﻫﺎﻱ‬SQL ‫ﺩﺭ‬ : ‫ﻣﺜﺎﻝ ﻫﺎﻱ ﺍﺿﺎﻓﻲ‬ : ‫ﺷﻤﺎﻱ ﺑﻪ ﻛﺎﺭ ﺭﻓﺘﻪ ﺩﺭ ﺍﻳﻦ ﻣﺜﺎﻝ‬

Find the names of all branches in the loan relations, and remove duplicates select distinct branch-name from loan To find all loan number for loans made at the Perryridge branch with loan amounts greater than $1200. select loan-number from loan where branch-name = ‘Perryridge’ and amount > 1200 Find the name, loan number and loan amount of all customers having a loan at the Perryridge branch.

٦٦ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

select customer-name, borrower.loan-number, amount from borrower, loan where borrower.loan-number = loan.loan-number and branch-name = ‘Perryridge’ Find the name, loan number and loan amount of all customers; rename the column name loan-number as loan-id. select customer-name, borrower.loan-number as loan-id, amount from borrower, loan where borrower.loan-number = loan.loan-number Find the customer names and their loan numbers for all customers having a loan at some branch. select customer-name, T.loan-number, S.amount from borrower as T, loan as S where T.loan-number = S.loan-number Find the names of all branches that have greater assets than some branch located in Brooklyn. select distinct T.branch-name from branch as T, branch as S where T.assets > S.assets and S.branch-city = ‘Brooklyn’ Find the names of all customers whose street includes the substring “Main”. select customer-name from customer where customer-street like ‘%Main%’ Match the name “Main%” like ‘Main\%’ escape ‘\’ List in alphabetic order the names of all customers having a loan in Perryridge branch select distinct customer-name from borrower, loan where borrower loan-number = loan.loan-number and branch-name = ‘Perryridge’ order by customer-name Find all customers who have a loan, an account, or both: (select customer-name from depositor) union (select customer-name from borrower) Find all customers who have both a loan and an account. (select customer-name from depositor) intersect (select customer-name from borrower) Find all customers who have an account but no loan. (select customer-name from depositor) except (select customer-name from borrower)

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٦٧ /‬‬

‫•‬

‫ﺗﻮﺍﺑﻊ ﺟﻤﻌﻲ ‪SQL‬‬

‫•‬

‫ﺩﺭ ﺯﺑـﺎﻥ ‪ SQL‬ﺗﻮﺍﺑـﻊ ﺟﻤﻌﻲ ﻧﻴﺰ ﻭﺟﻮﺩ ﺩﺍﺭﻧﺪ ‪ .‬ﺍﻳﻦ ﺗﻮﺍﺑﻊ ﺭﻭﻱ ﻟﻴﺴﺘﻲ ﺍﺯ ﻣﻘﺎﺩﻳﺮ ﻳﻚ ﺳﺘﻮﻥ ﻳﺎ ﺭﺍﺑﻄﻪ ﻋﻤﻞ ﻛﺮﺩﻩ ﻭ‬ ‫ﻳﻚ ﻣﻘﺪﺍﺭ ﺭﺍ ﺑﺮﻣﻲ ﮔﺮﺩﺍﻧﻨﺪ ‪ .‬ﺗﻮﺍﺑﻊ ﺟﻤﻌﻲ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ ‪:‬‬

‫‪-‬‬

‫‪ A VG‬ﺑﺮﺍﻱ ﻣﺤﺎﺳﺒﻪ ﻣﻴﺎﻧﮕﻴﻦ‬

‫‪-‬‬

‫‪ M AX , MIN‬ﻣﻴﻨﻴﻤﻢ ‪ ،‬ﻣﺎﻛﺰﻳﻤﻢ‬

‫‪-‬‬

‫‪ S UM‬ﻣﺠﻤﻮﻉ ﻣﻘﺎﺩﻳﺮ‬

‫‪-‬‬

‫‪C OUNT‬‬

‫ﺗﻌﺪﺍﺩ ﻣﻘﺎﺩﻳﺮ‬

‫ﻣﺜﺎﻝ ‪:‬‬ ‫)‪max( status‬‬ ‫‪from S‬‬

‫ﺗﻌﺪﺍﺩ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﺭﺍ ﻣﻲ ﺩﻫﺪ‬

‫‪select‬‬

‫)*(‪SELECT COUNT‬‬

‫‪.‬‬

‫‪FROM S‬‬ ‫) ‪COUNT ( DISTINCT P#‬‬ ‫‪FROM SP‬‬

‫‪SELECT‬‬

‫ﻋﺒﺎﺭﺕ ‪ group by‬ﺩﺭ ﺩﺳﺘﻮﺭ ﺑﺎﻋﺚ ﻣﻲ ﺷﻮﺩ ﺭﺍﺑﻄﻪ ﺩﺍﺩﻩ ﺷﺪﻩ ﺑﻌﺪ ﺍﺯ ﺟﻤﻠﻪ ‪ from‬ﺭﺍ ﺑﺮﺣﺴﺐ ﻣﻘﺎﺩﻳﺮ ﺳﺘﻮﻥ ﺩﺍﺩﻩ ﺷﺪﻩ‬ ‫ﮔﺮﻭﻩ ﺑﻨﺪﻱ ﻛﺮﺩﻩ ﻭ ﺁﻧﮕﺎﻩ ﺣﻜﻢ ‪ SELECT‬ﺩﺭ ﺍﻳﻦ ﺟﺪﻭﻝ ﺑﺎﺯﺁﺭﺍﻳﻲ ﺷﺪﻩ ﺍﺟﺮﺍ ﻣﻲ ﺷﻮﺩ ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ : Q1 :‬ﺷﻤﺎﺭﻩ ﻗﻄﻌﺎﺕ ﻭ ﻛﻞ ﺗﻌﺪﺍﺩ ﺗﻬﻴﻪ ﺷﺪﻩ ﺍﺯ ﻫﺮ ﻗﻄﻌﻪ ﺭﺍ ﺑﺪﻫﻴﺪ ‪.‬‬ ‫)‪SELECT P# ، SUM(QTY‬‬ ‫; ‪BY P#‬‬

‫)‪Sum(QTY‬‬

‫‪P#‬‬

‫‪300‬‬

‫‪P1‬‬

‫‪350‬‬

‫‪P2‬‬

‫‪FORM SP‬‬ ‫‪GROUP‬‬

‫‪Qty‬‬

‫‪S# P#‬‬

‫‪103‬‬ ‫‪80‬‬ ‫‪120‬‬ ‫‪200‬‬ ‫‪150‬‬

‫‪P1‬‬ ‫‪P1‬‬ ‫‪P1‬‬ ‫‪P2‬‬ ‫‪P2‬‬ ‫‪P3‬‬

‫‪S1‬‬ ‫‪S2‬‬ ‫‪S3‬‬ ‫‪S1‬‬ ‫‪S2‬‬ ‫‪S1‬‬

٦٨ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

‫ ﻇﺎﻫﺮ ﺷﺪﻩ ﺑﺎﺷﻨﺪ ﺩﺭ ﻏﻴﺮ‬Group by ‫ ﺧﺎﺭﺝ ﺍﺯ ﺗﻮﺍﺑﻊ ﺟﻤﻌﻲ ﺑﺎﻳﺴﺘﻲ ﺩﺭ ﻟﻴﺴﺖ ﮔﺮﻭﻩ‬select‫ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺩﺭ ﺩﺳﺘﻮﺭ‬: ‫ﻧﻜـﺘﻪ‬ . ‫ﺍﻳﻦ ﺻﻮﺭﺕ ﺧﻄﺎ ﺭﺥ ﻣﻲ ﺩﻫﺪ‬ . ‫ ﺷﻤﺎﺭﻩ ﻗﻄﻌﺎﺗﻲ ﺭﺍ ﺑﺪﻫﻴﺪ ﻛﻪ ﺗﻮﺳﻂ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ﺗﻬﻴﻪ ﻣﻲ ﺷﻮﺩ‬: ‫ﻣﺜﺎﻝ‬ Select



P# From sp Group by p# Having count(*) >1

‫ ﺩﺭ ﺳﻄﺮ‬Where‫ ﻣﻲ ﺁﻳﺪ ﻭ ﻧﻘﺶ ﺁﻥ ﺩﺭ ﮔﺮﻭﻩ ﻫﻤﺎﻧﻨﺪ ﻧﻘﺶ‬Group by ‫ ﻣﻌـﻨﺎﻱ ﻣﺴـﺘﻘﻞ ﻧﺪﺍﺭﺩ ﻭ ﻫﻤﻴﺸﻪ ﺑﺎ‬Having : ‫ﻧﻜـﺘﻪ‬ . ‫ﻣﻲ ﺑﺎﺷﺪ‬ Find the average account balance at the Perryridge branch. select avg (balance) from account where branch-name = ‘Perryridge’ Find the number of tuples in the customer relation. select count (*) from customer Find the number of depositors in the bank. select count (distinct customer-name) from depositor Find the number of depositors for each branch. select branch-name, count (distinct customer-name) from depositor, account where depositor.account-number = account.account-number group by branch-name Find the names of all branches where the average account balance is more than $1,200. select branch-name, avg (balance) from account group by branch-name having avg (balance) > 1200

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫•‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٦٩ /‬‬

‫‪ SQL‬ﺩﺭ ﺑـﺮﺧﻮﺭﺩ ﺑـﺎ ﻣﻘـﺪﺍﺭ‪ NULL‬ﺑـﻪ ﻋـﻨﻮﺍﻥ ﻳـﻚ ﻋﻤﻠـﻮﻧﺪ ﺩﺭ ﻋﻤـﻞ ﻣﻘﺎﻳﺴـﻪ ﻧﻤﻲ ﺗﻮﺍﻧﺪ ﺗﺼﻤﻴﻤﻲ ﺑﮕﻴﺮﺩ ‪.‬ﻳﻌﻨﻲ‬ ‫ﺳـﻄﺮﻫﺎﻱ ﺩﺍﺭﺍﻱ ‪ NULL‬ﺩﺭ ﺳﺘﻮﻥ ﻣﻮﺭﺩ ﻧﻈﺮ ﺭﺍ ﺩﺭ ﻛﺎﺭ ﺩﺧﺎﻟﺖ ﻧﻤﻲ ﺩﻫﺪ ‪ .‬ﺍﻣﺎ ﺍﮔﺮ ﺍﺯ ﻋﺒﺎﺭﺕ‪ IS NULL‬ﺍﺳﺘﻔﺎﺩﻩ ﺷﻮﺩ‬ ‫ﺁﻧﮕﺎﻩ ﺳﻴﺴﺘﻢ ﺑﺎ ﻣﻘﺪﺍﺭ ‪ NULL‬ﺑﺮﺧﻮﺭﺩ ﻣﻲ ﻛﻨﺪ ‪.‬‬ ‫) ‪is NULL‬‬

‫‪sp‬‬ ‫‪(status > 15) OR (status‬‬

‫•‬

‫ﻧﺘﻴﺠﻪ ﻫﺮ ﻋﻤﻞ ﺭﻳﺎﺿﻲ ﺭﻭﻱ‬

‫•‬

‫ﺗﻤﺎﻡ ﺗﻮﺍﺑﻊ ﺟﻤﻌﻲ ﺑﺠﺰ)*(‪ Count‬ﺗﺎﭘﻠﻬﺎﻱ ﺑﺎ ﻣﻘﺎﺩﻳﺮ‪NULL‬‬

‫‪ NULL‬ﻧﻴﺰ ‪NULL‬‬

‫‪S#‬‬ ‫‪From‬‬ ‫‪Where‬‬

‫‪Select‬‬

‫ﺍﺳﺖ ‪.‬‬ ‫‪NULL‬‬

‫‪5 + NULL‬‬

‫ﺩﺭ ﺁﻥ ﺻﻔﺖ ﺧﺎﺻﻪ ﺭﺍ ﻧﺎﺩﻳﺪﻩ ﻣﻲ ﮔﻴﺮﻧﺪ ‪.‬‬

‫‪E.g. Find all loan number which appear in the loan relation with null values‬‬ ‫‪for amount.‬‬ ‫‪select loan-number‬‬ ‫‪from loan‬‬ ‫‪where amount is null‬‬ ‫•‬

‫ﺩﺭ ﺑﺮﺧﻲ ﻧﺴﺨﻪ ﻫﺎﻱ ‪ ، SQL‬ﺗﻮﺍﺑﻊ ﺩﻳﮕﺮﻱ ﻧﻴﺰ ﻭﺟﻮﺩ ﺩﺍﺭﻧﺪﻛﻪ ﺍﺯ ﺟﻤﻠﻪ ﻣﻲ ﺗﻮﺍﻥ ﺗﻮﺍﺑﻊ ﺯﻳﺮ ﺭﺍ ﻧﺎﻡ ﺑﺮﺩ ‪:‬‬

‫‪SYSDATE‬‬ ‫‪, NEXT-DAY , LN, EXP, TAN ,TANH, SIN , SINH, COS,‬‬ ‫‪COSH,CEIL,FLOOR,STTDEV,VARIANCE,POWER,MOD,SIGN,CHR,CONCAT,UPPER‬‬ ‫‪,LOWER,LPAD,RPAD,LTRIM,RTRIM,REPLACE,TRANSLATE,‬‬ ‫‪lENGTH,TO_CHAR,USER,TO_NUMBER‬‬

‫•‬

‫ﭘﺮﺱ ﻭﺟﻮﻫﺎﻱ ﻓﺮﻋﻲ‬ ‫ﭘـﺮﺱ ﻭ ﺟـﻮﻫﺎﻱ ﻓﺮﻋـﻲ ﻳﻜـﻲ ﺍﺯ ﺗﻮﺍﻧﺎﻳـﻴﻬﺎﻱ ﻣﻬﻢ ﺩﺭ‪ SQL‬ﻣﻲ ﺑﺎﺷﺪ ‪ .‬ﻳﻚ ﭘﺮﺱ ﻭ ﺟﻮﻱ ﻓﺮﻋﻲ ﻳﻚ ﻋﺒﺎﺭﺕ ﭘﺮﺱ ﻭ‬ ‫ﺟﻮﻱ ‪ Select –from-where‬ﺍﺳﺖ ﻛﻪ ﺩﺭ ﺩﺍﺧﻞ ﻳﻚ ﭘﺮﺱ ﻭ ﺟﻮ ﺑﻜﺎﺭ ﺑﺮﺩﻩ ﻣﻲ ﺷﻮﺩ ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺍﺳﺎﻣﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﻗﻄﻌﻪ ‪ P 2‬ﺭﺍ ﺑﺪﻫﻴﺪ ‪.‬‬ ‫ﻳﻚ ﺭﺍﻩ ﺑﺮﺍﻱ ﻓﺮﻣﻮﻟﻪ ﻛﺮﺩﻥ ﺍﻳﻦ ﭘﺮﺱ ﻭ ﺟﻮ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﻣﻜﺎﻧﻴﺴﻢ ﭘﻴﻮﻧﺪ ﺍﺳﺖ ‪:‬‬ ‫‪Select Sname‬‬ ‫‪From S,Sp‬‬ ‫‪Where‬‬ ‫‪S.S# = SP.S#‬‬ ‫’‪AND SP.P# = ‘P2‬‬

‫ﺭﺍﻩ ﺩﻳﮕﺮ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﭘﺮﺱ ﻭ ﺟﻮﻱ ﻓﺮﻋﻲ ﺍﺳﺖ ‪:‬‬ ‫‪Select Sname‬‬ ‫‪From S‬‬ ‫‪Where S# IN (Select S#‬‬ ‫‪From‬‬ ‫‪SP‬‬ ‫)’‪Where P# = ‘P2‬‬ ‫‪Sub Query‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫•‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٧٠ /‬‬

‫ﺳﻴﺴﺘﻢ ﺍﺑﺘﺪﺍ ﭘﺮﺱ ﻭ ﺟﻮﻱ ﻓﺮﻋﻲ ﺭﺍ ﺍﺟﺮﺍ ﻣﻲ ﻛﻨﺪ ﻛﻪ ﺣﺎﺻﻞ ﻳﻚ ﻣﺠﻤﻮﻋﻪ ﺍﺯ‪ S #‬ﻫﺎﺳﺖ ‪.‬‬

‫ﻣﺜﺎﻝ ‪ :‬ﺍﺳﺎﻣﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻧﻲ ﺭﺍ ﺑﺪﻫﻴﺪ ﻛﻪ ﺍﻗﻼ ﻳﻚ ﻗﻄﻌﻪ ﺁﺑﻲ ﺭﻧﮓ ﺗﻬﻴﻪ ﻣﻲ ﻛﻨﻨﺪ ‪.‬‬ ‫ﺩﺭ ﺍﻳﻦ ﭘﺮﺱ ﻭ ﺟﻮ ﺳﻪ ﺟﺪﻭﻝ ‪SP ، P، S‬ﺩﺧﺎﻟﺖ ﺩﺍﺭﻧﺪ ‪:‬‬

‫‪P‬‬ ‫)‘ ﺁﺑﻲ‘ = ‪Where Color‬‬

‫•‬

‫‪SP‬‬ ‫‪IN (Select P#‬‬ ‫‪From‬‬

‫‪Select Sname‬‬ ‫‪From S‬‬ ‫‪Where S# IN (Select S# from‬‬ ‫‪Where P#‬‬

‫ﺍﮔﺮ ﻧﺘﻴﺠﻪ ﭘﺮﺱ ﻭ ﺟﻮﻱ ﻓﺮﻋﻲ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﻣﻘﺪﺍﺭ ﺑﺎﺷﺪ ﺍﺯ ﻋﺒﺎﺭﺕ ‪ I N‬ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﺩ ﻭ ﺍﮔﺮ ﻗﻄﻌﺎ ﺗﻚ‬ ‫ﻣﻘﺪﺍﺭﻱ ﺑﺎﺷﺪ ﻣﻲ ﺗﻮﺍﻥ ﺍﺯ ﻋﻤﻠﮕﺮﺩ = ﺍﺳﺘﻔﺎﺩﻩ ﻧﻤﻮﺩ ‪.‬‬

‫ﻣﺜﺎﻝ ‪ :‬ﺷﻤﺎﺭﻩ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﻫﻢ ﺷﻬﺮ ﺑﺎ ‪ S1‬ﺭﺍ ﺑﺪﻫﻴﺪ ‪.‬‬ ‫‪Select‬‬ ‫‪S#‬‬ ‫‪From‬‬ ‫‪S‬‬ ‫‪Where city = ( Select city‬‬ ‫‪from S‬‬ ‫‪Where‬‬ ‫)’‪S# = ‘S1‬‬

‫ﺟﻮﺍﺏ ﭘﺮﺱ ﻭ ﺟﻮﻱ ﻓﺮﻋﻲ ﺑﺎﻻ ﻳﻚ ﻣﻘﺪﺍﺭ ﺍﺳﺖ ‪.‬‬ ‫•‬

‫ﻣﻲ ﺗﻮﺍﻥ ﺩﺭ ﭘﺮﺱ ﻭ ﺟﻮﻫﺎﻱ ﻓﺮﻋﻲ ﺍﺯ ﺗﺎﺑﻊ ﺟﻤﻌﻲ ﻧﻴﺰ ﺍﺳﺘﻔﺎﺩﻩ ﻛﺮﺩ ‪.‬‬

‫ﻣﺜﺎﻝ ‪ :‬ﺷﻤﺎﺭﻩ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻧﻲ ﺭﺍ ﺑﺪﻫﻴﺪ ﻛﻪ ﻣﻘﺪﺍﺭ ﻭﺿﻌﻴﺖ ﺁﻧﻬﺎ ﺍﺯ ﻣﺎﻛﺰﻳﻤﻢ ﻣﻘﺪﺍﺭ ﻭﺿﻌﻴﺖ ﻣﻮﺟﻮﺩ ﺩﺭ ‪ S‬ﻛﻤﺘﺮ ﺑﺎﺷﺪ‬ ‫‪SELECT S#‬‬ ‫‪FROM‬‬ ‫‪S‬‬ ‫‪WHERE STATUS < ( SELECT‬‬ ‫)‪MAX (STATUS‬‬ ‫‪FROM‬‬ ‫;) ‪S‬‬

‫•‬

‫ﺩﺭ ‪ SQL‬ﻣﻲ ﺗﻮﺍﻥ ﺍﺯ ﺳﻮﺭ ﻭﺟﻮﺩﻱ ﻧﻴﺰ ﺍﺳﺘﻔﺎﺩﻩ ﻛﺮﺩ ‪.‬‬

‫ﻣﺜﺎﻝ ‪ :‬ﺍﺳﺎﻣﻲ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﻗﻄﻌﻪ ‪P 2‬ﺭﺍ ﺑﺪﻫﻴﺪ ‪.‬‬

‫•‬

‫‪SELECT SNAME‬‬ ‫‪FROM‬‬ ‫‪S‬‬ ‫‪WHERE EXISTS ( SELECT * FROM SP‬‬ ‫)’‪WHERE SP.S# = S.S# AND SP.P#=’P 2‬‬ ‫ﻋﺒﺎﺭﺕ ‪ EXISTS‬ﺩﺭ ‪ SQL‬ﺩﺍﺭﺍﻱ ﺍﺭﺯﺵ ﺩﺭﺳﺖ ﺍﺳﺖ ﺍﮔﺮ ﻭﻓﻘﻂ ﺍﮔﺮ ﻧﺘﻴﺠﻪ ﺍﺭﺯﻳﺎﺑﻲ ) … ‪ (Select‬ﺗﻬﻲ ﻧﺒﺎﺷﺪ‪.‬‬

‫•‬

‫ﻧﻜﺎﺕ ﻣﻬﻢ ﺩﺭ ﻣﻮﺭﺩ ﻣﺜﺎﻝ ﻣﻄﺮﺡ ﺷﺪﻩ ‪:‬‬

‫‪ .١‬ﻭﺟﻮﺩ ‪ S‬ﺩﺭ ‪ S.S#‬ﺿﺮﻭﺭﻱ ﻭﻟﻲ ‪ SP‬ﺩﺭ ‪ SP.S#‬ﺑﺮﺍﻱ ﻭﺿﻮﺡ ﺑﻴﺸﺘﺮ ﺍﺳﺖ ‪ .‬ﻭﻗﺘﻲ ﻛﻪ ﺩﺭ ﻳﻚ ﭘﺮﺱ ﻭ ﺟﻮﻱ ﺩﺭﻭﻧﻲ‬ ‫ﺍﺯ ﺟﺪﻭﻟﻲ ﺍﺯ ﭘﺮﺱ ﻭ ﺟﻮﻱ ﺑﻴﺮﻭﻧﻲ ﺍﺭﺟﺎﻉ ﻣﻲ ﺩﻫﻴﻢ ‪ .‬ﻗﻴﺪ ﻛﺮﺩﻥ ﺷﻨﺎﺳﻪ ﺁﻥ ﺳﺘﻮﻥ ﺍﻟﺰﺍﻣﻲ ﺍﺳﺖ ‪.‬‬ ‫‪ .٢‬ﻭﺟـﻮﺩ ﺷﺮﻁ ‪ SP.S# = S.S#‬ﺑﻪ ﺍﻳﻦ ﻣﻌﻨﺎ ﺍﺳﺖ ﻛﻪ ﺳﻴﺴﺘﻢ ﻋﻤﻞ ﭘﻴﻮﻧﺪ ﺭﺍ ﺍﻧﺠﺎﻡ ﺩﻫﺪ ‪ .‬ﻫﺮ ﭼﻨﺪ ﻇﺎﻫﺮﺵ ﻫﻤﺎﻥ ﺍﺳﺖ‬ ‫ﻭ ﺍﺯ ﺍﻳﻦ ﺩﻳﺪﮔﺎﻩ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ‪ exists‬ﻫﻤﻴﺸﻪ ﻛﺎﺭﺍﺗﺮ ﺍﺯ ﺷﺒﻴﻪ ﺳﺎﺯﻱ ﻋﻤﻞ ﭘﻴﻮﻧﺪ ﺍﺳﺖ ‪.‬‬

٧١ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

Find all customers who have both an account and a loan at the bank. select distinct customer-name from borrower where customer-name in (select customer-name from depositor) Find all customers who have a loan at the bank but do not have an account at the bank select distinct customer-name from borrower where customer-name not in (select customer-name from depositor) Find all customers who have both an account and a loan at the Perryridge branchselect distinct customer-name from borrower, loan where borrower.loan-number = loan.loan-number and branch-name = “Perryridge” and (branch-name, customer-name) in (select branch-name, customer-name from depositor, account where depositor.account-number = account.account-number) Find all branches that have greater assets than some branch located in Brooklyn. select distinct T.branch-name from branch as T, branch as S where T.assets > S.assets and S.branch-city = ‘Brooklyn’ Same query using > some clause select branch-name from branch where assets > some (select assets from branch where branch-city = ‘Brooklyn’) (= some) =in However, (<> some) = not in (<> all)= not in However, (= all) = in

٧٢ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

Find the names of all branches that have greater assets than all branches located in Brooklyn. select branch-name from branch where assets > all (select assets from branch where branch-city = ‘Brooklyn’) The unique construct tests whether a subquery has any duplicate tuples in its result. Find all customers who have at most one account at the Perryridge branch. select T.customer-name from depositor as T where unique ( select R.customer-name from account, depositor as R where T.customer-name = R.customer-name and R.account-number = account.account-number and account.branch-name = ‘Perryridge’) Find all customers who have at least two accounts at the Perryridge branch. select distinct T.customer-name from depositor T where not unique ( select R.customer-name from account, depositor as R where T.customer-name = R.customer-name and R.account-number = account.account-number and account.branch-name = ‘Perryridge’)

:‫ ﺍﺣﻜﺎﻡ ﺗﻐﻴﻴﺮ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ‬: ٢ – ٣ – ٦ ‫ ﺍﺣﻜﺎﻡ ﺣﺬﻑ ﺩﺍﺩﻩ ﻫﺎ‬: ١ – ٢ – ٣ – ٦ : ‫ ﺍﺳﺘﻔﺎﺩﻩ ﻛﺮﺩ‬D elete ‫ﺑﺮﺍﻱ ﺣﺬﻑ ﻳﻚ ﻳﺎ ﭼﻨﺪ ﺗﺎﭘﻞ ﺍﺯ ﺟﺪﻭﻝ ﻣﻲ ﺗﻮﺍﻥ ﺍﺯ ﺩﺳﺘﻮﺭ‬ DELETE FROM R WHERE P

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٧٣ /‬‬

‫ﻣﺜﺎﻝ ‪ :‬ﺣﺬﻑ ﻛﻨﻴﺪ ﺍﻃﻼﻉ>‪ < S3,P4,….‬ﺭﺍ ‪.‬‬ ‫’‪AND P# = ‘P4‬‬

‫‪DELETE FROM SP‬‬ ‫’‪WHERE S# = ‘S3‬‬

‫ﺩﺭ ﺩﺳﺘﻮﺭﺯﻳﺮ ﺑﺨﺎﻃﺮ ﻗﺎﻋﺪﻩ ﺟﺎﻣﻌﻴﺖ ﺑﺎﻳﺴﺘﻲ ﺩﺳﺘﻮﺭ ﺯﻳﺮ ﻧﻴﺰ ﺍﺟﺮﺍ ﺷﻮﺩ ‪.‬‬ ‫‪DELETE FROM P‬‬ ‫’‪WHERE P# = ‘P5‬‬ ‫‪DELETE FROM SP‬‬ ‫’‪WHERE P# = ‘P5‬‬

‫ﺩﺳﺘﻮﺭ ﺯﻳﺮ ﺑﺮﺍﻱ ﺣﺬﻑ ﺗﻤﺎﻡ ﺳﻄﺮﻫﺎﻱ ‪ Sp‬ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ‪:‬‬ ‫‪DELETE FROM SP‬‬

‫‪ : ٢ – ٢ – ٣ – ٦‬ﺍﺿﺎﻓﻪ ﻛﺮﺩﻥ ﺗﺎﭘﻞ ﻭ ﻳﺎ ﺗﺎﭘﻠﻬﺎﻱ ﺟﺪﻳﺪ ﻳﻚ ﺭﺍﺑﻄﻪ ) ﺟﺪﻭﻝ (‬ ‫ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺩﺳﺘﻮﺭ‪ INSERT‬ﻣﻲ ﺗﻮﺍﻥ ﺗﺎﭘﻠﻬﺎﻳﻲ ﺭﺍ ﺑﻪ ﺟﺪﻭﻝ ﺍﺿﺎﻓﻪ ﻧﻤﻮﺩ ‪ .‬ﻓﺮﻣﺖ ﻛﻠﻲ ﺩﺳﺘﻮﺭ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ ‪:‬‬ ‫)‪INSERT INTO R (A1,A2,….‬‬ ‫)‪VALUES ( V1,V2,…..‬‬

‫ﻣﺜﺎﻝ ‪:‬‬ ‫‪INSERT INTO P‬‬ ‫‪VALUES‬‬ ‫‪( ‘P8’,’PN8’,’BLUE’,’10’,’C3’),‬‬

‫ﻣﺜﺎﻟﻲ ﺍﺯ ﺩﺭﺝ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺩﺍﺩﻩ ﻫﺎﻱ ﺟﺪﻭﻝ ﺩﻳﮕﺮ ‪:‬‬ ‫( ‪INSERT INTO ACCOUNT‬‬ ‫‪SELECT LOAN-NUMBER, BRANCH-NAME,200‬‬ ‫‪FROM LOAN‬‬ ‫; ‘ ﻧﺎﺩﺭﻱ‘ = ‪WHERE BRANCH-NAME‬‬ ‫ﺩﺭ ﺟﻤﻠـﻪ ‪ INSERT‬ﺩﺳﺘﻮﺭ ‪FROM …..‬‬

‫‪ SELECT‬ﺍﺑﺘﺪﺍ ﻗﺒﻞ ﺍﺯ ﻫﺮ ﺩﺭﺟﻲ ﺍﺭﺯﻳﺎﺑﻲ ﺷﺪﻩ ﻭ ﺳﭙﺲ ﻧﺘﻴﺠﻪ ﺑﻪ ﺭﺍﺑﻄﻪ‬

‫ﻣﻮﺭﺩ ﻧﻈﺮ ﺩﺭﺝ ﻣﻲ ﺷﻮﺩ ‪.‬‬ ‫ﺩﺭ ﻏﻴـﺮ ﺍﻳـﻦ ﺻـﻮﺭﺕ ﺩﺳـﺘﻮﺭ ‪ I NSERT INTO TABLE1 SELECT * FROM TABLE1‬ﺩﭼﺎﺭ ﻣﺸﻜﻞ‬ ‫ﻣﻲ ﺷﻮﺩ ‪.‬‬ ‫‪ : ٣ – ٢ – ٣ -٥‬ﺣﻜﻢ ﺗﻐﻴﻴﺮ ﺭﻛﻮﺭﺩ‬ ‫ﺷـﻜﻞ ﻛﻠـﻲ ﺍﻳـﻦ ﺣﻜﻢ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ ‪ .‬ﺩﺭ ﺍﻳﻦ ﺻﻮﺭﺕ ﺗﻤﺎﻡ ﺭﻛﻮﺭﺩﻫﺎﻱ ﺟﺪﻭﻝ ﻛﻪ ﺣﺎﺋﺰ ﺷﺮﻁ ﺩﺍﺩﻩ ﺷﺪﻩ ﺑﺎﺷﻨﺪ ﺑﺎ‬ ‫ﺗﻮﺟﻪ ﺑﻪ ﻣﻘﺪﺍﺭ ﺩﺍﺩﻩ ﺷﺪﻩ ﺩﺭ ‪ S et‬ﺗﻐﻴﻴﺮ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﻧﺪ ‪.‬‬ ‫‪UPDATE TABLE‬‬ ‫‪SET‬‬ ‫ﻋﺒﺎﺭﺕ = ‪FIELD‬‬ ‫] ‪[ WHERE PERDICATE‬‬

‫ﻣﺜﺎﻝ ‪:‬‬ ‫‪ .١‬ﺭﻧﮓ ﻗﻄﻌﻪ ‪ P2‬ﺭﺍ ﺑﻪ ﺯﺭﺩ ﺗﻐﻴﻴﺮ ﺩﺍﺩﻩ ﻭ ﺑﻪ ﻭﺯﻥ ﺁﻥ ‪ ٥‬ﻭﺍﺣﺪ ﺑﻴﻔﺰﺍﺋﻴﺪ ‪.‬‬ ‫‪UPDATE P‬‬

٧٤ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬ SET

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

COLOR = ‘‫’ﺯﺭﺩ‬,

WEIGHT = WEIGHT + 5 WHERE P# = ‘P2’

‫ ﮔﺮﻡ ﺭﺍ‬١٠ ‫ ﻭﺍﺣﺪ ﺍﺿﺎﻓﻪ ﻛﻨﻴﺪ ﻭ ﻗﻄﻌﺎﺕ ﻛﻤﺘﺮ ﺍﺯ‬٥ ‫ ﮔﺮﻡ ﻳﺎ ﺑﻴﺸﺘﺮ ﺭﺍ‬١٠ ‫ﻭﺯﻥ ﻗﻄﻌﺎﺕ ﺩﺍﺭﺍﻱ ﻭﺯﻧﻲ ﺑﺎ ﻣﻘﺪﺍﺭ‬



. ‫ ﻭﺍﺣﺪ ﺍﺿﺎﻓﻪ ﻛﻨﻴﺪ‬٣ UPDATE P SET WHERE UPDATE P SET WHERE

UPDATE P SET

WEIGHT = WEIGHT + 5 WEIGHT =10 WEIGHT = WEIGHT + 3 WEIGHT < 10

. ‫ﺗﺮﺗﻴﺐ ﺟﻤﻼﺕ ﺑﺎﻻ ﻣﻬﻢ ﺍﺳﺖ‬



: ‫ ﺑﻄﻮﺭ ﺳﺎﺩﻩ ﺗﺮ ﭘﺮﺱ ﻭ ﺟﻮ ﺭﺍ ﻧﻮﺷﺖ‬CASE‫ﻣﻲ ﺗﻮﺍﻥ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺟﻤﻠﻪ‬



WEIGHT = CASE WHEN ELSE

WEIGHT >= 10 WEIGHT + 5 WEIGHT + 3

THEN

END

Provide as a gift for all loan customers of the Perryridge branch, a $200 savings account. Let the loan number serve as the account number for the new savings account insert into account select loan-number, branch-name, 200 from loan where branch-name = ‘Perryridge’ insert into depositor select customer-name, loan-number from loan, borrower where branch-name = ‘Perryridge’ and loan.account-number = borrower.account-number Increase all accounts with balances over $10,000 by 6%, all other accounts receive 5%.

٧٥ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

Write two update statements: update account set balance = balance * 1.06 where balance > 10000 update account set balance = balance * 1.05 where balance £ 10000 The order is important Can be done better using the case statement (next slide) Same query as before: Increase all accounts with balances over $10,000 by 6%, all other accounts receive 5%. update account set balance = case when balance <= 10000 then balance *1.05 else balance * 1.06 end

‫ ﻭ ﺳﻄﺢ ﺧﺎﺭﺟﻲ‬SQL: ٤ – ٦ . ‫ ﺑﺮﺍﻱ ﺗﻌﺮﻳﻒ ﺩﻳﺪ ﺍﺯ ﺩﺳﺘﻮﺭ ﺯﻳﺮ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﺩ‬S QL‫ ﺩﺭ‬. ‫ﻋﺒﺎﺭﺗﻲ ﻧﺎﻣﺪﺍﺭ ﺍﺯ ﺟﺒﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ﺍﺳﺖ‬، ‫ﻣﻲ ﺩﺍﻧﻴﻢ ﺩﻳﺪ‬ CREATE

VIEW

VIEW_NAME [ ( COLUMN[,COLUMN, ….]….).] AS SUB QUERY ‫ ﻳﻚ ﭘﺮﺱ ﻭ ﺟﻮ ﺍﺳﺖ ﻛﻪ ﺍﺯ ﻃﺮﻳﻖ‬view ‫ ﺍﺳﺖ ﻭ ﺩﺭ ﻭﺍﻗﻊ ﻣﻜﺎﻧﻴﺰﻡ ﺍﺷﺘﻘﺎﻕ‬view ‫ ﺩﺭ ﺧﺪﻣﺖ‬Select ‫ﺗﻤـﺎﻡ ﻗـﺪﺭﺕ ﺩﺳـﺘﻮﺭ‬

‫ ﺍﺟﺮﺍ ﻧﻤﻲ ﺷﻮﺩ ﺑﻠﻜﻪ ﻓﻘﻂ ﺑﻪ ﻋﻨﻮﺍﻥ ﺗﻌﺮﻳﻒ ﺑﺎ ﺷﻤﺎﻱ‬view ‫ ﭘﺮﺱ ﻭ ﺟﻮﻱ ﻣﺮﺑﻮﻃﻪ ﺩﺭ ﺯﻣﺎﻥ ﺗﻌﺮﻳﻒ‬. ‫ ﺩﺍﺩﻩ ﻣـﻲ ﺷـﻮﺩ‬Select . ‫ﺧﺎﺭﺟﻲ ﺩﺭ ﻛﺎﺗﺎﻟﻮﮒ ﻧﮕﻬﺪﺍﺭﻱ ﻣﻲ ﺷﻮﺩ ﺗﺎ ﻫﺮﮔﺎﻩ ﻻﺯﻡ ﺑﺎﺷﺪ ﺳﻴﺴﺘﻢ ﺑﻪ ﺁﻥ ﻣﺮﺍﺟﻌﻪ ﻛﻨﺪ‬ : ‫ﻣﺜﺎﻝ‬ CREATE AS

VIEW PARTS (P#,PNAME,WT,CITY) SELECT P#,PNAME, WEIGHT,CITY FROM P WHERE COLOR = ‘RED’

. ‫ ﺗﻌﺮﻳﻒ ﻣﻲ ﺷﻮﺩ‬Parts ‫ﺑﺎ ﺣﻜﻢ ﺑﺎﻻ ﻳﻚ ﺩﻳﺪ ﺑﻨﺎﻡ‬ A view consisting of branches and their customers create view all-customer as (select branch-name, customer-name from depositor, account where depositor.account-number = account.account-number)

union

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٧٦ /‬‬

‫‪(select branch-name, customer-name‬‬ ‫‪from borrower, loan‬‬ ‫)‪where borrower.loan-number = loan.loan-number‬‬

‫‪ : ١ – ٤ – ٦‬ﻋﻤﻠﻴﺎﺕ ﺩﺭ ﺩﻳﺪ‬ ‫ﺍﻟﻒ( ﺑﺎﺯﻳﺎﺑﻲ ‪:‬‬ ‫ﻋﻤـﻞ ﺑﺎﺯﻳﺎﺑـﻲ ﺍﺯ ﻧﻈـﺮ ﺗـﺌﻮﺭﻱ ﻣﺸﻜﻠﻲ ﻧﺪﺍﺭﺩ ﻫﺮ ﭼﻨﺪ ﺩﺭ ﺑﻌﻀﻲ ﺳﻴﺴﺘﻢ ﻫﺎ ﻣﺤﺪﻭﺩﻳﺖ ﻫﺎﻳﻲ ﺩﺭ ﺍﻳﻦ ﺯﻣﻴﻨﻪ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ﭼﻮﻥ‬ ‫‪ view‬ﻣﺎﻫﻴﺘﺎ ﺟﺪﻭﻝ ﺍﺳﺖ ‪ .‬ﻟﺬﺍ ﻫﻤﺎﻥ ﺣﻜﻢ ‪ Select‬ﻧﻴﺰ ﺑﺮﺍﻱ ﺁﻥ ﻋﻤﻞ ﻣﻲ ﻛﻨﺪ ‪.‬‬ ‫ﻣﺜﺎﻝ ‪:‬‬ ‫‪PARTS‬‬

‫‪SELECT‬‬ ‫*‬ ‫‪FROM‬‬ ‫’‪WHERE P# = ‘P2‬‬

‫ﺑـﺮﺍﻱ ﺍﺟـﺮﺍﻱ ﺣﻜـﻢ ﺑـﺎﻻ ﺑﺎﻳﺴـﺘﻲ ﺳﻴﺴﺘﻢ ﺁﻥ ﺭﺍ ﺑﻪ ﺣﻜﻤﻲ ﺩﺭ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﺗﺒﺪﻳﻞ ﻛﻨﺪ ﻭ ﺑﺮﺍﻱ ﺍﻳﻦ ﻣﻨﻈﻮﺭ ﺷﺮﻁ ﻳﺎ ﺷﺮﺍﻳﻂ‬ ‫ﺩﺍﺩﻩ ﺷﺪﻩ ﺩﺭ ﺗﻌﺮﻳﻒ ﺩﻳﺪ ﺭﺍ ﺑﺎ ﺷﺮﻁ ﺩﺭ ﺣﻜﻢ ﺑﺎﺯﻳﺎﺑﻲ ﺗﺮﻛﻴﺐ ﻣﻲ ﻛﻨﺪ ‪.‬‬ ‫ﻣﺜﺎﻝ ‪:‬‬ ‫*‬ ‫‪PARTS‬‬

‫‪SELECT‬‬ ‫‪FROM‬‬

‫ﺩﻳﺪ ﻛﺎﺭﺑﺮ ﺭﺍ ﺑﻪ ﻋﻴﻨﻴﺖ ﺩﺭﻣﻲ ﺁﻭﺭﺩ ‪.‬‬ ‫ﭼـﻮﻥ ‪ VIEW‬ﺧـﻮﺩ ﻳـﻚ ﺟـﺪﻭﻝ ﺍﺳـﺖ ﻭ ﻟـﺬﺍ ﻣـﻲ ﺗﻮﺍﻥ ﺭﻭﻱ ﺁﻥ ‪ VIEW‬ﺗﻌﺮﻳﻒ ﻛﺮﺩ ﻭ ﺑﺪﻳﻦ ﺗﺮﺗﻴﺐ ﺳﻄﻮﺡ ﺩﻳﮕﺮﻱ ﺍﺯ‬ ‫ﺍﻧﺘﺰﺍﻉ ﺭﺍ ﺍﻳﺠﺎﺩ ﻛﺮﺩ ‪.‬‬ ‫‪Find all customers of the Perryridge branch‬‬ ‫‪select customer-name‬‬ ‫‪from all-customer‬‬ ‫’‪where branch-name = ‘Perryridge‬‬ ‫‪Find the average account balance of those branches where the average‬‬ ‫‪account balance is greater than $1200.‬‬ ‫‪select branch-name, avg-balance‬‬ ‫)‪from (select branch-name, avg (balance‬‬ ‫‪from account‬‬ ‫)‪group by branch-name‬‬ ‫)‪as result (branch-name, avg-balance‬‬ ‫‪where avg-balance > 1200‬‬

‫ﺩﺭ ﺑﺮﺧـﻲ ﺳﻴﺴـﺘﻢ ﻫـﺎ ﺩﺭ ﻋﻤﻞ ﺑﺎﺯﻳﺎﺑﻲ ﺍﺯ ‪ VIEW‬ﻣﺤﺪﻭﺩﻳﺖ ﻫﺎﻳﻲ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ﻛﻪ ﺍﺯ ﺟﻤﻠﻪ ﻣﻲ ﺗﻮﺍﻥ ﻣﺸﻜﻞ ﺗﺎﺑﻊ‬ ‫ﺟﻤﻌﻲ ﺭﺍ ﻣﻄﺮﺡ ﻛﺮﺩ ‪.‬‬ ‫‪PQ‬‬

‫‪VIEW‬‬

‫‪CREATE‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٧٧ /‬‬

‫‪AS SELECT SP.P#, SUM(SP.QTY) AS TOTALQTY‬‬ ‫‪FROM‬‬ ‫‪SP‬‬ ‫‪GROUP BY SP.P#‬‬

‫ﺩﺳﺘﻮﺭ ﺯﻳﺮ ﻏﻴﺮﻣﺠﺎﺯ ﺍﺳﺖ ‪.‬‬ ‫‪AS PT‬‬

‫)‪AVG(PQ. TOTALQTY‬‬ ‫‪PQ‬‬

‫‪SELECT‬‬ ‫‪FROM‬‬

‫ﺏ( ﻋﻤﻠﻴﺎﺕ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﺩﺭ ‪ ) : VIEW‬ﺑﺮﻭﺯ ﺩﺭﺁﻭﺭﻱ ﺩﻳﺪﻫﺎ (‬ ‫ﺗﻤـﺎﻡ ﺩﻳـﺪﻫﺎﻱ ﻗﺎﺑـﻞ ﺗﻌـﺮﻳﻒ ﺩﺭ ‪ SQL‬ﻗﺎﺑـﻞ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﻧﻴﺴﺘﻨﺪ ‪ .‬ﺑﻪ ﺑﻴﺎﻥ ﺩﻳﮕﺮ ﺩﻳﺪﻫﺎﻳﻲ ﻭﺟﻮﺩ ﺩﺍﺭﻧﺪ ﻛﻪ ﻧﻤﻲ ﺗﻮﺍﻥ ﺍﺯ‬ ‫ﻃﺮﻳﻖ ﺁﻧﻬﺎ ﻋﻤﻞ ﺩﺭﺝ ‪ ،‬ﺗﻐﻴﻴﺮ ﻭ ﺣﺬﻑ ﺭﺍ ﺍﻧﺠﺎﻡ ﺩﺍﺩ ‪ .‬ﺩﻳﺪﻫﺎ ﺭﺍ ﻣﻌﻤﻮﻻ ﺑﻪ ﺩﻭ ﺩﺳﺘﻪ ﺗﻘﺴﻴﻢ ﻣﻲ ﻛﻨﻨﺪ ‪.‬‬ ‫‪.١‬‬

‫ﺩﻳﺪﻫﺎﻱ ﻓﺎﻗﺪ ﻣﺸﻜﻞ ﺩﺭ ﻋﻤﻠﻴﺎﺕ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ )ﭘﺬﻳﺮﺍ(‬

‫‪.٢‬‬

‫ﺩﻳﺪﻫﺎﻱ ﺩﺍﺭﺍﻱ ﻣﺸﻜﻞ )ﻧﺎﭘﺬﻳﺮﺍ(‬

‫ﺁﻧﭽـﻪ ﻛﻪ ﺩﺭ ﺳﻴﺴﺘﻢ ﻫﺎﻱ ﻣﻮﺟﻮﺩ ﺑﻪ ﻋﻨﻮﺍﻥ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﺩﻳﺪﻫﺎ ﺍﻧﺠﺎﻡ ﻣﻲ ﺷﻮﺩ ﺩﺭ ﺑﻌﻀﻲ ﻣﻮﺍﺭﺩ ﺍﺯ ﻧﻈﺮ ﻣﻨﻄﻘﻲ ﻗﺎﺑﻞ ﺩﻓﺎﻉ‬ ‫ﻧﻴﺴـﺖ ﻭ ﻳﺎ ﺑﺮﻋﻜﺲ ﺍﺯ ﻧﻈﺮ ﻣﻨﻄﻘﻲ ﺷﺪﻧﻲ ﺍﺳﺖ ﻭﻟﻲ ﺳﻴﺴﺘﻢ ﻫﺎﻱ ﻣﻮﺟﻮﺩ ﺍﻧﺠﺎﻡ ﻧﻤﻲ ﺩﻫﻨﺪ ‪ .‬ﻳﻜﻲ ﺍﺯ ﺍﻳﺮﺍﺩﻫﺎﻳﻲ ﻛﻪ ﺑﻪ ﺳﻴﺴﺘﻢ‬ ‫ﻫﺎﻱ ﺭﺍﺑﻄﻪ ﺍﻱ ﻣﻲ ﮔﻴﺮﻧﺪ ﻧﻴﺰ ﺑﺤﺚ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﺩﻳﺪ ﺍﺳﺖ ‪.‬‬ ‫•‬

‫ﻧﻈﺮ ﭼﻤﺒﺮﻟﻦ ﺩﺭ ﺳﻴﺴﺘﻢ‪: R‬‬

‫ﺩﻳـﺪﻱ ﻗﺎﺑـﻞ ﺑـﻪ ﻫـﻨﮕﺎﻡ ﺳﺎﺯﻱ ﺍﺳﺖ ﺍﮔﺮ ﺭﻭﻱ ﻳﻚ ﺟﺪﻭﻝ ﻣﺒﻨﺎ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺑﺎﺷﺪ ﻭ ﻫﺮ ﺳﻄﺮ ﺩﻳﺪ ﻣﺘﻨﺎﻇﺮ ﺑﺎ ﺳﻄﺮ ﺷﺨﺼﻲ ﺍﺯ‬ ‫ﺟﺪﻭﻝ ﻣﺒﻨﺎ ﺑﺎﺷﺪ ﻭ ﻫﺮ ﺳﺘﻮﻥ ﺩﻳﺪ ﻧﻴﺰ ﻣﺘﻨﺎﻇﺮ ﺑﺎ ﺳﺘﻮﻥ ﻣﺸﺨﺺ ﻭ ﻧﺎﻣﺪﺍﺭﻱ ﺍﺯ ﺟﺪﻭﻝ ﻣﺒﻨﺎ ﺑﺎﺷﺪ ‪.‬‬ ‫ﻣﺜﺎﻝ )‪: (١‬‬ ‫‪CREATE‬‬ ‫‪VIEW‬‬ ‫‪SUPC2‬‬ ‫‪AS SELECT S#,SNAME‬‬ ‫‪FROM‬‬ ‫‪S‬‬ ‫‪WHERE‬‬ ‫’‪CITY = ‘C2‬‬

‫ﻓﺮﺽ ﻛﻨﻴﻢ ﺩﺳﺘﻮﺭ ﺭﺍ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ ‪:‬‬ ‫‪UPDATE‬‬ ‫‪SUPC2‬‬ ‫’****‘ = ‪Set Sname‬‬ ‫‪Where‬‬ ‫’‪S# = ‘S2‬‬

‫ﺍﻳﻦ ﺩﺳﺘﻮﺭ ﺑﺎﻳﺴﺘﻲ ﺑﻪ ﺩﺳﺘﻮﺭﻱ ﺩﺭ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﻧﮕﺎﺷﺘﻪ ﺷﻮﺩ ‪.‬‬ ‫‪UPDATE‬‬ ‫‪S‬‬ ‫’****‘ = ‪SET SNAME‬‬ ‫‪WHERE‬‬ ‫’‪S# = ‘S2‬‬ ‫‪AND‬‬ ‫’‪CITY = ‘C2‬‬

‫ﺩﺭ ﺻﻮﺭﺗﻲ ﻛﻪ ﺑﺨﻮﺍﻫﻴﻢ ﺳﻄﺮﻱ ﺑﻪ ﺩﻳﺪ ﺩﺭﺝ ﻛﻨﻴﻢ ‪:‬‬ ‫‪INSERT‬‬ ‫‪INTO‬‬ ‫‪SUPC2‬‬ ‫)‪VALUES(S12,SN12‬‬

‫ﻛﻤﺘـﺮﻳﻦ ﻣﺸـﻜﻞ ﺁﻥ ﺍﺳـﺖ ﻛـﻪ ﺩﺭ ﺩﻭ ﺳـﺘﻮﻥ ‪ status، city‬ﭘﺪﻳـﺪﻩ ﻫـﻴﭽﻤﻘﺪﺍﺭ ﺑﺮﻭﺯ ﻣﻲ ﻛﻨﺪ ‪ .‬ﺻﺮﻓﻨﻈﺮ ﺍﺯ ﺍﻳﻨﻜﻪ ﻭﺟﻮﺩ ﺍﻳﻦ‬ ‫ﭘﺪﻳﺪﻩ ﻣﻄﻠﻮﺏ ﻧﻴﺴﺖ ‪ ،‬ﺑﺮﻭﺯ ﺁﻥ ﻣﻲ ﺗﻮﺍﻧﺪ ﻳﻜﻲ ﺍﺯ ﻗﻮﺍﻋﺪ ﺟﺎﻣﻌﻴﺖ ﭘﺎﻳﮕﺎﻩ ﺭﺍ ﺧﺪﺷﻪ ﺩﺍﺭ ﻛﻨﺪ ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٧٨ /‬‬

‫‪INSERT‬‬ ‫‪INTO‬‬ ‫‪S‬‬ ‫‪VALUES‬‬ ‫>‪<S12,SN12,….,…..‬‬

‫ﺩﺭ ﺧﺼﻮﺹ ﺩﻳﺪﻫﺎﻱ ﺗﻚ ﺟﺪﻭﻟﻲ ﭼﻤﺒﺮﻟﻴﻨﻲ ﻣﻲ ﺗﻮﺍﻥ ﮔﻔﺖ ﻛﻪ ﻏﻴﺮ ﺍﺯ ﭘﺪﻳﺪﻩ ﻫﻴﭽﻤﻘﺪﺍﺭ ﻣﺸﻜﻠﻲ ﻧﺪﺍﺭﺩ ‪.‬‬ ‫ﻣﺜﺎﻝ )‪: (٢‬‬ ‫‪CREATE‬‬ ‫‪VIEW‬‬ ‫‪V1‬‬ ‫)‪AS SELECT ( S#,STATUS‬‬ ‫‪FROM‬‬ ‫;‪S‬‬ ‫‪CREATE‬‬ ‫‪VIEW‬‬ ‫‪V2‬‬ ‫‪AS SELECT STATUS,CITY‬‬ ‫‪FROM‬‬ ‫;‪S‬‬ ‫ﻣﻲ‬ ‫ﻫـﺮﺩﻭ ﺩﻳـﺪ ﺑـﺎﻻ ﺭﻭﻱ ﻳﻚ ﺟﺪﻭﻝ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺍﻧﺪ ﻭ ﻫﺮ ﺩﻭ ﺩﻳﺪ ﻣﺎﻫﻴﺘﺎ ﺣﺎﺻﻞ ﻋﻤﻞ ﭘﺮﺗﻮ ﺭﻭﻱ ﺟﺪﻭﻝ ‪S‬‬

‫ﺑﺎﺷـﻨﺪ ‪ .‬ﺩﻳـﺪ ‪ V1‬ﻗﺎﺑـﻞ ﺑـﻪ ﻫـﻨﮕﺎﻡ ﺳـﺎﺯﻱ ﺍﺳـﺖ ) ﻏﻴﺮ ﺍﺯ ﻣﺴﺄﻟﻪ ‪ NULL VALUE‬ﺩﺭ ﻋﻤﻞ ﺩﺭﺝ ( ﻭ ﺩﻳﺪ ‪ V2‬ﻗﺎﺑﻞ ﺑﻪ‬ ‫ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﻧﻴﺴﺖ‬ ‫ﺩﻳـﺪ ‪ V1‬ﻣﻮﺳﻮﻡ ﺑﻪ ﺩﻳﺪ ﺣﺎﻓﻆ ﻛﻠﻴﺪ ﺍﺳﺖ ﺩﺭ ﺣﺎﻟﻴﻜﻪ ﺩﻳﺪ ‪ V2‬ﺣﺎﻓﻆ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻧﻴﺴﺖ ‪ .‬ﺩﻳﺪ ﭼﻤﺒﺮﻟﻴﻨﻲ ﻫﻤﺎﻥ ﺩﻳﺪ‬ ‫ﺣﺎﻓﻆ ﻛﻠﻴﺪ ﺍﺳﺖ ﻭ ﭼﻮﻥ ﺩﺭ ﺳﺎﻟﻬﺎﻱ ‪ 78-79‬ﻣﻔﻬﻮﻡ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﺗﻌﺮﻳﻒ ﻧﺸﺪﻩ ﺑﻮﺩ ﻟﺬﺍ ﻭﻱ ﺁﻥ ﺭﺍ ﻣﻄﺮﺡ ﻧﻜﺮﺩ ‪.‬‬ ‫ﻣﺜﺎﻝ )‪ : (٣‬ﺩﻳﺪ ﺁﻣﺎﺭﻱ ‪:‬‬ ‫‪Create‬‬

‫‪view‬‬ ‫)‪V3(Pnum,SumQ‬‬ ‫)‪Select P#,sum(QTY‬‬ ‫‪From‬‬ ‫‪SP‬‬ ‫‪Group‬‬ ‫;‪by P#‬‬ ‫ﺍﻳـﻦ ﺩﻳـﺪ ﺣـﺎﻭﻱ ﻳﻚ ﻓﻴﻠﺪ ﻣﺠﺎﺯﻱ ﺍﺳﺖ ) ﺑﻪ ﻋﻴﻨﻴﺖ ﺩﺭﺁﻭﺭﺩﻥ ﻏﻴﺮ ﻣﺴﺘﻘﻴﻢ ( ‪ S umQ :‬ﻳﻚ ﻓﻴﻠﺪ ﻣﺠﺎﺯﻱ ﺍﺳﺖ ﻭ ﺑﻪ ﻋﻴﻨﻪ‬ ‫‪AS‬‬

‫ﺭﻭﻱ ﺟﺪﻭﻝ ﻓﻴﻠﺪ ﻣﺘﻨﺎﻇﺮ ﻧﺪﺍﺭﺩ ﻭ ﻟﺬﺍ ﻫﻴﭻ ﮔﻮﻧﻪ ﻋﻤﻠﻲ ﺭﻭﻱ ﺍﻳﻦ ﺳﺘﻮﻥ ﻧﻤﻲ ﺗﻮﺍﻥ ﺍﻧﺠﺎﻡ ﺩﺍﺩ ‪.‬‬ ‫)‪INTO V3 (Pnum,SumQ‬‬ ‫>‪Values < P11 , 111‬‬

‫‪INSERT‬‬

‫ﻣﻘﺪﺍﺭﻱ ﺍﺳﺖ ﺑﺮﺍﻱ )‪ sum(Qty‬ﻭ ﻧﻪ ﺑﺮﺍﻱ ‪ . Qty‬ﻟﺬﺍ ﻋﻤﻞ ﺩﺭﺝ ﺍﻣﻜﺎﻥ ﭘﺬﻳﺮ ﻧﻴﺴﺖ ‪.‬‬ ‫•‬

‫ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﺩﻳﺪﻫﺎﻱ ﺣﺎﺻﻞ ﻋﻤﻞ ﭘﻴﻮﻧﺪ)ﺗﺮﻛﻴﺐ( ‪:‬‬

‫ﻃـﺒﻖ ﻧﻈـﺮ ﭼﻤﺒـﺮﻟﻴﻦ ﺍﻳـﻦ ﺩﻳـﺪﻫﺎ ﻗﺎﺑﻞ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﻧﻴﺴﺘﻨﺪ ﺍﻣﺎ ﺍﻳﻦ ﻧﻈﺮ ﺭﺩ ﺷﺪﻩ ﺍﺳﺖ ‪ .‬ﻓﺮﺽ ﻣﻲ ﻛﻨﻴﻢ ﺑﺠﺎﻱ ﺭﺍﺑﻄﻪ ‪S‬‬

‫ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ ‪:‬‬ ‫)‪SX(S#,Sname,city‬‬ ‫)‪SY(S#,Status‬‬

‫ﻭ ‪ S#‬ﺩﺭ ﻫﺮ ﺩﻭ ﺭﺍﺑﻄﻪ‪ SY,SX‬ﻛﻠﻴﺪ ﺍﺳﺖ ‪.‬‬ ‫‪SX ∞ SY = S‬‬

‫ﺍﮔﺮ ﺩﻳﺪﻱ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ ﺑﻔﺮﻡ ﻣﻘﺎﺑﻞ ‪:‬‬ ‫‪CREATE‬‬ ‫‪VIEW‬‬ ‫‪S‬‬ ‫‪AS SELECT SX.S#,SNAME,STATUS,CITY‬‬ ‫‪FROM‬‬ ‫‪SX,SY‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٧٩ /‬‬

‫‪WHERE SX.S# = SY.S#‬‬

‫ﺩﺭ ﺩﻳـﺪ ﺑـﺎﻻ ﻳـﻚ ﭘـﻴﻮﻧﺪ ﺩﺍﺭﻳـﻢ ﻭ ﭘـﻴﻮﻧﺪ ﺍﺯ ﻧـﻮﻉ ‪ PK -PK‬ﺍﺳﺖ ‪ ) .‬ﺻﻔﺖ ﺧﺎﺻﻪ ﺩﺧﻴﻞ ﺩﺭ ﭘﻴﻮﻧﺪ ﺩﺭ ﻫﺮ ﺩﻭ ﺭﺍﺑﻄﻪ ﻛﻠﻴﺪ‬ ‫ﺍﺻﻠﻲ ﺍﺳﺖ ( ﺩﻳﺪﻫﺎﻱ ﺣﺎﺻﻞ ﭼﻨﻴﻦ ﭘﻴﻮﻧﺪﻫﺎﻳﻲ ﻣﺸﻜﻠﻲ ﺩﺭ ﻋﻤﻠﻴﺎﺕ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﻧﺪﺍﺭﻧﺪ ‪ .‬ﻭﺟﻮﺩ ﭘﻴﻮﻧﺪﻫﺎﻱ‬

‫‪-P k‬‬

‫‪ Pk‬ﺳﺒﺐ ﺷﺪﻩ ﺍﺳﺖ ﻛﻪ ﺗﻨﺎﻇﺮ ﻳﻚ ﺑﻴﻚ ﺑﻴﻦ ﺳﻄﺮﻫﺎﻭ ﺳﺘﻮﻧﻬﺎﻱ ﺟﺪﺍﻭﻝ ﻣﺒﻨﺎﻱ ﺯﻳﺮﻳﻦ ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ‪.‬‬ ‫‪Insert‬‬ ‫‪Into‬‬ ‫)‪S (S#,Sname,Status,city‬‬ ‫‪Values‬‬ ‫)‪(S9,Sn9,20,C9‬‬

‫‪Insert‬‬ ‫‪Into‬‬ ‫)‪SX (S#,Sname,city‬‬ ‫‪Values‬‬ ‫)‪(S9,Sn9,C9‬‬ ‫‪Insert‬‬ ‫‪Into‬‬ ‫)‪SY (S#, Status‬‬ ‫‪Values‬‬ ‫)‪(S9,20‬‬

‫•‬

‫ﺩﻳﺪﻫﺎﻱ ﻧﺎﭘﺬﻳﺮﺍ ‪:‬‬ ‫ﺍﮔـﺮ ﺍﻳـﻦ ﺍﺻـﻞ ﭘﺬﻳـﺮﻓﺘﻪ ﺷﻮﺩ ﻛﻪ ﻋﻤﻠﻴﺎﺕ ﺗﺎﭘﻠﻲ ﺩﺭ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺭﺍﺑﻄﻪ ﺍﻱ ﺍﺯ ﻃﺮﻳﻖ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻭ ﻳﺎ ﻳﻜﻲ ﺍﺯ‬

‫ﻛﻠﻴﺪ‬

‫ﻫـﺎﻱ ﻛﺎﻧﺪﻳـﺪ ﺍﻧﺠـﺎﻡ ﮔﺮﺩﺩ ‪ ،‬ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﺩﻳﺪ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺭﻭﻱ ﻳﻚ ﺭﺍﺑﻄﻪ ﻛﻪ ﻓﺎﻗﺪ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ) ﺍﺻﻠﻲ ( ﺭﺍﺑﻄﻪ ﻣﺒﻨﺎ‬ ‫ﺑﺎﺷﺪ ‪ ،‬ﻋﻤﻠﻴﺎﺕ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﺭﺍ ﻧﻤﻲ ﭘﺬﻳﺮﺩ ﻟﺬﺍ ﺩﻭ ﺣﺎﻟﺖ ﺯﻳﺮ ﺭﺍ ﻏﻴﺮ ﭘﺬﻳﺮﺍ ﺩﺭ ﻧﻈﺮ ﻣﻴﮕﻴﺮﻳﻢ ‪:‬‬ ‫ﺍﻟﻒ ( ﺩﻳﺪ ﭘﺮﺗﻮﻱ ﻓﺎﻗﺪ ﻛﻠﻴﺪ ‪:‬‬ ‫ﺏ ( ﺣﺎﺻﻞ ﻋﻤﻞ ﭘﻴﻮﻧﺪ)ﺗﺮﻛﻴﺐ( ‪:FK-FK‬‬ ‫ﺍﻳـﻦ ﻧـﻮﻉ ﺩﻳﺪ ‪ ،‬ﺍﮔﺮ ﻋﻮﺍﺭﺽ ﺟﺎﻧﺒﻲ ﻋﻤﻠﻴﺎﺕ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﺯﺍ ﺑﭙﺬﻳﺮﻳﻢ ‪،‬ﭘﺬﻳﺮﺍﻱ ﻋﻤﻠﻴﺎﺕ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﺍﺳﺖ ﻭﻟﻲ ﭼﻮﻥ‬ ‫ﺍﻳﻦ ﻋﻮﺍﺭﺽ ﻗﺎﺑﻞ ﺗﻮﺟﻪ ﻫﺴﺘﻨﺪ ‪،‬ﻟﺬﺍ ﺁﻧﺮﺍ ﺟﺰﺀ ﺩﻳﺪﻫﺎﻱ ﻏﻴﺮ ﭘﺬﻳﺮﺍ ﻣﻨﻈﻮﺭ ﻣﻴﻜﻨﻨﺪ‪.‬‬ ‫•‬

‫ﺩﺭ ‪ SQL/92‬ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﺩﻳﺪﻫﺎ ﺍﺯ ﻗﻮﺍﻧﻴﻦ ﺯﻳﺮ ﭘﻴﺮﻭﻱ ﻣﻲ ﻛﻨﻨﺪ ‪:‬‬

‫‪.١‬‬

‫ﻋﺒﺎﺭﺕ ﺟﺪﻭﻟﻲ ﻛﻪ ﺣﻮﺯﻩ ﺩﻳﺪ ﺭﺍ ﺗﻌﻴﻴﻦ ﻣﻲ ﻛﻨﺪ ﻧﺒﺎﻳﺪ ﺷﺎﻣﻞ ﻛﻠﻤﺎﺕ ‪ U NION‬ﻭ ‪ JOIN‬ﺑﺎﺷﺪ ‪.‬‬

‫‪.٢‬‬

‫ﻗﺴﻤﺖ ‪ SELECT‬ﻋﺒﺎﺭﺕ ﺍﻧﺘﺨﺎﺏ ﻣﺴﺘﻘﻴﻤﺎ ﺷﺎﻣﻞ ‪ DISTINCT‬ﻧﺒﺎﺷﺪ ‪.‬‬

‫‪.٣‬‬

‫ﻗﺴﻤﺖ ‪ FROM‬ﺩﻗﻴﻘﺎ ﺷﺎﻣﻞ ﻳﻚ ﺟﺪﻭﻝ ﺍﺭﺟﺎﻉ ﺑﺎﺷﺪ ‪.‬‬

‫‪.٤‬‬

‫ﻋﺒﺎﺭﺕ ‪ SELECT‬ﻧﺒﺎﻳﺪ ﺣﺎﻭﻱ ‪ GROUP‬ﻭ ‪ HAVING‬ﺑﺎﺷﺪ ‪.‬‬

‫ﻧﻜﺎﺕ ﻣﻬﻢ ‪:‬‬ ‫‪.١‬‬

‫ﻗﺎﺑﻠﻴﺖ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﺩﺭ‪ view‬ﺑﻪ ﮔﻮﻧﻪ ﺍﻱ ﺍﺳﺖ ﻛﻪ ﻳﺎ ﻫﺮ ﺳﻪ ﻋﻤﻞ ‪ INSERT‬ﻭ ‪ UPDATE‬ﻭ ‪ DELETE‬ﻣﻲ‬

‫ﺗﻮﺍﻧﻨﺪ ﺑﺮ ﺭﻭﻱ ﻳﻚ ﺩﻳﺪ ﺍﻋﻤﺎﻝ ﺷﻮﻧﺪ ﻭ ﻳﺎ ﻫﻴﭻ ﻛﺪﺍﻡ ﺭﺍ ﻧﻤﻲ ﺗﻮﺍﻥ ﺍﻋﻤﺎﻝ ﻛﺮﺩ ‪.‬‬ ‫‪.٢‬‬

‫ﺩﺭ‪ view‬ﺍﻳﻦ ﺍﻣﻜﺎﻥ ﻭﺟﻮﺩ ﻧﺪﺍﺭﺩ ﻛﻪ ﺑﻌﻀﻲ ﺳﺘﻮﻧﻬﺎ ﺭﺍ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﻛﺮﺩ ﻭ ﺑﺮﺧﻲ ﺳﺘﻮﻧﻬﺎ ﺭﺍ ﺩﺭ ﺩﺍﺧﻞ ﻫﻤﺎﻥ ﺩﻳﺪ‬

‫ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﻧﻜﺮﺩ ‪.‬‬ ‫ﻣﺜﺎﻝ )‪ : (٣‬ﻓﺮﺽ ﻛﻨﻴﺪ ﺩﻳﺪ ‪V5‬ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺑﺎﺷﺪ ‪:‬‬ ‫‪VIEW‬‬ ‫‪V5‬‬ ‫‪Select S#,Status,city‬‬ ‫‪From‬‬ ‫‪S‬‬

‫‪CREATE‬‬ ‫‪AS‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٨٠ /‬‬

‫‪Where Status > 15‬‬ ‫‪With‬‬ ‫;‪check option‬‬ ‫‪V5‬‬ ‫‪S#…….Status‬‬ ‫‪S1……16‬‬ ‫‪S3……17‬‬

‫‪S‬‬ ‫‪S#……Status‬‬ ‫‪S1……16‬‬ ‫‪S2……10‬‬ ‫‪S3……17‬‬ ‫‪S4…….15‬‬

‫ﺗﻬﻴﻪ ﻛﻨﻨﺪ ‪ S2‬ﻳﺎ ‪ S4‬ﺩﺭ ﺍﻳﻦ ﺩﻳﺪ ﻭﺟﻮﺩ ﻧﺪﺍﺭﺩ ‪ .‬ﺁﻳﺎ ﻛﺎﺭﺑﺮ ﺣﻖ ﺩﺍﺭﺩ ﻋﻤﻞ ﺯﻳﺮ ﺭﺍ ﺍﻧﺠﺎﻡ ﺩﻫﺪ ؟‬ ‫‪Insert‬‬ ‫‪Into‬‬ ‫‪V5‬‬ ‫‪Values‬‬ ‫)‪(S2,18‬‬

‫ﺩﺭ ﺍﻳـﻦ ﺻـﻮﺭﺕ ﺑﺎﻳﺴـﺘﻲ ﺟﻠﻮﻱ ﻋﻤﻞ ﺩﺭﺝ ﺭﺍ ﺑﮕﻴﺮﺩ ﺯﻳﺮﺍ ﺑﺎﻋﺚ ﺗﻜﺮﺍﺭ ﺩﺭ ﻛﻠﻴﺪ ﻣﻲ ﺷﻮﺩ ‪ .‬ﻭ ﻧﻴﺰ ﺁﻳﺎ ﻛﺎﺭﺑﺮ ﺣﻖ ﺩﺍﺭﺩ ﺩﺳﺘﻮﺭ‬ ‫ﻣﻘﺎﺑﻞ ﺭﺍ ﻭﺍﺭﺩ ﻛﻨﺪ ؟‬ ‫‪V5‬‬ ‫‪Status = 10‬‬ ‫‪Where‬‬ ‫’‪S# = ‘S3‬‬ ‫ﺩﺭ ﭼﻨـﻴﻦ ﻣـﻮﺍﺭﺩﻱ ﺩﺭ ﺑﻌﻀـﻲ ﺳﻴﺴـﺘﻢ ﻫـﺎ ﮔـﺰﻳﻨﻪ‪check option‬‬

‫‪update‬‬ ‫‪Set‬‬

‫‪ With‬ﺭﺍ ﻗـﺮﺍﺭ ﻣـﻲ ﺩﻫـﻨﺪ ‪ .‬ﺑﻪ ﺍﻳﻦ ﻣﻌﻨﻲ ﻛﻪ ﺍﮔﺮ‬

‫ﻋﻤﻠـﻴﺎﺕ ﺩﺭﺝ ﻭ ﺑـﻪ ﻫـﻨﮕﺎﻡ ﺳﺎﺯﻱ ﺟﺎﻣﻌﻴﺖ ﺍﻋﻤﺎﻝ ﺷﺪﻩ ﺗﻮﺳﻂ ﻋﺒﺎﺭﺕ ﺗﻌﺮﻳﻒ ﻛﻨﻨﺪﻩ ﺩﻳﺪ ﺭﺍ ﻧﻘﺾ ﻛﻨﻨﺪ ﺁﻧﮕﺎﻩ ﺍﻳﻦ ﻋﻤﻠﻴﺎﺕ‬ ‫ﺭﻭﻱ ﺩﻳﺪ ﺭﺩ ﻣﻲ ﺷﻮﻧﺪ ‪.‬‬

‫‪ -٥-٥‬ﺍﻣﻜﺎﻧﺎﺕ ﺍﻣﻨﻴﺘﻲ ‪:SQL‬‬ ‫ﻣـﻲ ﺩﺍﻧﻴﻢ ﺍﻣﻨﻴﺖ ﺑﻪ ﻣﻌﻨﻲ ﺣﻔﺎﻇﺖ ﺩﺍﺩﻩ ﻫﺎ ﺩﺭ ﻗﺒﺎﻝ ﻛﺎﺭﺑﺮﺍﻥ ﻏﻴﺮ ﻣﺠﺎﺯ ﻣﻴﺒﺎﺷﺪ‪ .‬ﺟﻨﺒﻪ ﻫﺎﻱ ﻣﺨﺘﻠﻔﻲ ﺩﺭﺑﺎﺭﻩ ﺍﻣﻨﻴﺖ ﻣﻄﺮﺡ ﺍﺳﺖ‬ ‫ﻛﻪ ﺍﺯ ﺟﻤﻠﻪ ﻣﻲ ﺗﻮﺍﻥ ﻣﻮﺍﺭﺩ ﺯﻳﺮ ﺭﺍ ﻧﺎﻡ ﺑﺮﺩ ‪:‬‬ ‫ﺟﻨﺒﻪ ﻫﺎﻱ ﻗﺎﻧﻮﻧﻲ ﻭ ﺍﺟﺘﻤﺎﻋﻲ‬ ‫ﻛﻨﺘﺮﻝ ﻫﺎﻱ ﻓﻴﺰﻳﻜﻲ‬ ‫ﻣﺴﺎﺋﻞ ﻋﻤﻠﻴﺎﺗﻲ‬ ‫ﻛﻨﺘﺮﻝ ﻫﺎﻱ ﺳﺨﺖ ﺍﻓﺰﺍﻱ‬ ‫ﭘﺸﺘﻴﺒﺎﻧﻲ ﺳﻴﺴﺘﻢ ﻋﺎﻣﻞ‬ ‫ﺁﻧﭽـﻪ ﺩﺭ ﺍﻳـﻦ ﺑﺤﺚ ﺣﺎﺋﺰ ﺍﻫﻤﻴﺖ ﺍﺳﺖ ﺍﻣﻜﺎﻧﺎﺕ ﺍﻣﻨﻴﺘﻲ ﻛﻨﺘﺮﻝ ﺩﺍﺩﻩ ﻫﺎ ﺩﺭﻭﻥ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺍﺳﺖ ﻛﻪ ﺑﺮﺧﻲ ﺍﺯ ﺁﻧﻬﺎ ﺑﺎ‬ ‫ﺩﺳﺘﻮﺭﺍﺕ ‪ SQL‬ﺗﻌﺮﻳﻒ ﻣﻲ ﺷﻮﻧﺪ‪ .‬ﺍﺯ ﺟﻤﻠﻪ ﺍﻳﻦ ﺍﻣﻜﺎﻧﺎﺕ ﻣﻲ ﺗﻮﺍﻥ ﺗﻌﺮﻳﻒ ﻛﺎﺭﺑﺮﺍﻥ ‪ ،‬ﻗﻮﺍﻧﻴﻦ ﻭ ﺍﻣﺘﻴﺎﺯﺍﺕ ﺭﺍ ﻧﺎﻡ ﺑﺮﺩ ‪.‬‬ ‫ﻛﺎﺭﺑﺮ ‪:‬‬ ‫ﻛﺎﺭﺑﺮ ﻧﺎﻣﻲ ﺍﺳﺖ ﻛﻪ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺁﻥ ﻣﻴﺘﻮﺍﻥ ﻭﺍﺭﺩ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺷﺪ‪ .‬ﺑﺮﺍﻱ ﺗﻌﺮﻳﻒ ﻛﺎﺭﺑﺮ ﺩﺳﺘﻮﺭﺍﺕ ﺯﻳﺮ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﻧﺪ‪:‬‬ ‫‪CREATE USER user‬‬ ‫}‪IDENTIFIED {BY password | EXTERNALLY‬‬ ‫]‪[DEFAULT TABLESPACE tablespace‬‬ ‫]‪[TEMPORARY TABLESPACE tablespace‬‬

٨١ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

[QUOTA {integer [K|M] | UNLIMITED} ON tablespace] [PROFILE profile] ALTER USER user [IDENTIFIED {BY password | EXTERNALLY}] [DEFAULT TABLESPACE tablespace] [TEMPORARY TABLESPACE tablespace] [QUOTA {integer [K|M] | UNLIMITED} ON tablespace] [PROFILE profile] [DEFAULT ROLE { role [, role] ... | ALL [EXCEPT role [, role] ...] | NONE}]

‫ﺍﻣﺘﻴﺎﺯ ﻫﺎ‬ ‫ ﻭ ﺑﺮﺍﻱ ﻟﻐﻮ ﺁﻥ ﺍﺯ ﺩﺳﺘﻮﺭ‬GRANT ‫ ﺑﺮﺍﻱ ﺍﻋﻄﺎﺀ ﺍﻣﺘﻴﺎﺯ ﺍﺯ ﺩﺳﺘﻮﺭ‬. ‫ﺍﺟﺎﺯﻩ ﺍﻧﺠﺎﻡ ﻳﻚ ﻋﻤﻞ ﺭﻭﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎﺳﺖ‬، ‫ﺍﻣﺘﻴﺎﺯ‬ .‫ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﺩ‬REVOKE The grant statement is used to confer authorization grant <privilege list> on to <user list> <user list> is: a user-id public, which allows all valid users the privilege granted A role (more on this later) Granting a privilege on a view does not imply granting any privileges on the underlying relations. The grantor of the privilege must already hold the privilege on the specified item (or be the database administrator). select: allows read access to relation,or the ability to query using the view Example: grant users U1, U2, and U3 select authorization on the branch relation: grant select on branch to U1, U2, U3 insert: the ability to insert tuples update: the ability to update using the SQL update statement delete: the ability to delete tuples. references: ability to declare foreign keys when creating relations. usage: In SQL-92; authorizes a user to use a specified domain

٨٢ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

all privileges: used as a short form for all the allowable privileges

Roles permit common privileges for a class of users can be specified just once by creating a corresponding “role” Privileges can be granted to or revoked from roles, just like user Roles can be assigned to users, and even to other roles

SQL:1999 supports roles create role teller create role manager grant select on branch to teller grant update (balance) on account to teller grant all privileges on account to manager grant teller to manager grant teller to alice, bob grant manager to avi : ‫ﺩﺳﺘﻮﺭ ﻟﻐﻮ ﻣﺠﻮﺯ‬ The revoke statement is used to revoke authorization. revoke<privilege list> on from <user list> [restrict|cascade] Example: revoke select on branch from U1, U2, U3 cascade Revocation of a privilege from a user may cause other users also to lose that privilege; referred to as cascading of the revoke. We can prevent cascading by specifying restrict: revoke select on branch from U1, U2, U3 restrict With restrict, the revoke command fails if cascading revokes are required. .‫ ﻣﺮﺍﺟﻌﻪ ﻧﻤﻮﺩ‬http://members.tripod.com/er4ebus/sql/ch12.htm ‫ﺑﺮﺍﻱ ﻣﻄﺎﻟﻌﻪ ﺑﻴﺸﺘﺮ ﻣﻲ ﺗﻮﺍﻥ ﺑﻪ ﺁﺩﺭﺱ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٨٣ /‬‬

‫‪-٦-٥‬ﺗﻌﺮﻳﻒ ﺗﺮﺍﻛﻨﺶ‬ ‫ﺗـﺮﺍﻛﻨﺶ ﻭﺍﺣـﺪ ﺑـﺮﻧﺎﻣﻪ ﻧﻮﻳﺴـﻲ ﺍﺳـﺖ ﻛـﻪ ﺷـﺎﻣﻞ ﻳﻜﺴـﺮﻱ ﻋﻤﻠـﻴﺎﺕ ﻣﺮﺗﺒﻂ ﺑﺮﺍﻱ ﺩﺳﺘﺮﺳﻲ ﻭ ﺗﻐﻴﻴﺮ ﺍﻃﻼﻋﺎﺕ ﻳﻚ ﺑﺎﻧﻚ‬ ‫ﺍﻃﻼﻋﺎﺗـﻲ ﻛـﻪ ﺩﺭ ﺟﻬـﺎﻥ ﻭﺍﻗﻌـﻲ ﺩﺭ ﺣﻜـﻢ ﻳـﻚ ﻋﻤـﻞ ﻭﺍﺣﺪ ﺗﻠﻘﻲ ﻣﻲ ﺷﻮﻧﺪ‪ .‬ﻣﻌﻤﻮﻻ” ﺩﺳﺘﻮﺭﺍﺕ ﺗﺮﺍﻛﻨﺶ ﺑﺎ ﺩﺳﺘﻮﺭﺷﺮﻭﻉ‬ ‫ﺗـﺮﺍﻛﻨﺶ )‪ ( begin transaction‬ﺁﻏﺎﺯ ﻭ ﺑﺎ ﻳﻚ ﻋﻤﻞ ‪ commit‬ﻭﻳﺎ ‪ undo‬ﭘﺎﻳﺎﻥ ﻣﻲ ﭘﺬﻳﺮﺩ‪ .‬ﺩﺭ ﺧﺼﻮﺹ ﺗﺮﺍﻛﻨﺶ ﭼﻨﺪ‬ ‫ﻧﻜﺘﻪ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪:‬‬ ‫•‬

‫ﻃﺮﺍﺣﻲ ﺻﺤﻴﺢ ‪correctness‬‬

‫ﺑــﺮﻧﺎﻣﻪ ﻧــﻮﻳﺲ ﺑﺎﻳــﺪ ﻋﻤﻠــﻴﺎﺕ ﺍﺟﺮﺍﻳــﻲ ﻳــﻚ ﺗــﺮﺍﻛﻨﺶ ﺭﺍ ﺑﺼــﻮﺭﺕ ﻭﺍﺣــﺪ ﻳﻜــﭙﺎﺭﭼﻪ ﻃﺮﺍﺣــﻲ ﻛــﻨﺪ ﻭ ﺍﻳــﻦ ﺑــﻪ ﺧــﻮﺩ‬ ‫‪dbms‬ﺭﺑﻄﻲ ﻧﺪﺍﺭﺩ‪.‬‬ ‫•‬

‫ﺧﻮﺍﻧﺪﻥ ﺍﻃﻼﻋﺎﺕ‬

‫ﻫﺮ ﻣﻮﺭﺩ ﺍﻃﻼﻋﺎﺗﻲ ﻣﻮﺭﺩ ﻧﻴﺎﺯ ﺗﺮﺍﻛﻨﺶ ﺑﺎﻳﺪ ﻓﻘﻂ ﻳﻜﺒﺎﺭ ﺧﻮﺍﻧﺪﻩ ﺷﻮﺩ ‪ .‬ﺑﻌﺒﺎﺭﺕ ﺩﻳﮕﺮ ﺩﺭ ﺩﺍﺧﻞ ﻳﻚ ﺗﺮﺍﻛﻨﺶ ﻳﻚ ﺭﻛﻮﺭﺩ‬ ‫ﺩﻭﺑﺎﺭ ﺧﻮﺍﻧﺪﻩ ﻧﺸﻮﺩ‪.‬‬ ‫•‬

‫ﻧﻮﺷﺘﻦ ﺍﻃﻼﻋﺎﺕ‪:‬‬

‫ﻫﺮ ﻣﻮﺭﺩ ﺍﻃﻼﻋﺎﺗﻲ ﻣﻮﺭﺩ ﻋﻤﻞ ﺩﺭ ﺗﺮﺍﻛﻨﺶ ﺩﺭ ﺻﻮﺭﺕ ﺗﻐﻴﻴﺮ ﻓﻘﻂ ﻳﻜﺒﺎﺭ ﻧﻮﺷﺘﻪ ﺷﻮﺩ‪.‬‬ ‫‪ -١-٦-٥‬ﻭﻳﮋﮔﻴﻬﺎﻱ ﺗﺮﺍﻛﻨﺶ‬ ‫ﺑﺮﺍﻱ ﺗﺮﺍﻛﻨﺶ ﻫﺎ ﭼﻬﺎﺭ ﻭﻳﮋﮔﻲ ﻧﻴﺰ ﺫﻛﺮ ﻛﺮﺩﻩ ﺍﻧﺪ ﻛﻪ ﻣﻲ ﺗﻮﺍﻥ ﺁﻧﻬﺎ ﺭﺍ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﻧﺎﻡ ﺑﺮﺩ‪:‬‬ ‫ﺍﻟﻒ ‪ :‬ﻭﻳﮋﮔﻲ ﺍﺗﻤﻲ ﺑﻮﺩﻥ ‪Atomicity‬‬

‫ﺗﺮﺍﻛﻨﺶ ﻫﺎ ‪،‬ﺳﺎﺩﻩ ﻭ ﻏﻴﺮ ﻗﺎﺑﻞ ﺗﺠﺰﻳﻪ ﻫﺴﺘﻨﺪ ﺑﻌﺒﺎﺭﺗﻲ ﻛﻠﻴﻪ ﻋﻤﻠﻴﺎﺕ ﻫﺮ ﺗﺮﺍﻛﻨﺶ ﻳﺎ ﺗﻤﺎﻣﺎ“ ﺍﺟﺮﺍ ﻣﻲ ﺷﻮﻧﺪ ﻭ ﻳﺎ ﻫﻴﭽﻜﺪﺍﻡ‬ ‫ﺍﺟﺮﺍ ﻧﻤﻲ ﮔﺮﺩﻧﺪ‪.‬‬ ‫ﺏ‪ :‬ﻭﻳﮋﮔﻲ ﺳﺎﺯﮔﺎﺭﻱ ‪consistency‬‬

‫ﺗﺮﺍﻛﻨﺶ ﻫﺎ ﺳﺎﺯﮔﺎﺭﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺭﺍ ﺣﻔﻆ ﻣﻲ ﻛﻨﻨﺪ‪ .‬ﺑﻌﺒﺎﺭﺕ ﺩﻳﮕﺮ ﺗﺮﺍﻛﻨﺶ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺭﺍ ﺍﺯ ﻳﻚ ﺣﺎﻟﺖ ﺳﺎﺯﮔﺎﺭ ﺑﻪ ﺣﺎﻟﺖ‬ ‫ﺳﺎﺯﮔﺎﺭ ﺩﻳﮕﺮﻱ ﺗﺒﺪﻳﻞ ﻣﻲ ﻛﻨﺪ‪.‬‬ ‫ﺝ ‪:‬ﻭﻳﮋﮔﻲ ﺟﺪﺍﺳﺎﺯﻱ ‪Isolation‬‬

‫ﺗﺮﺍﻛﻨﺶ ﻫﺎ ﺍﺯ ﻳﻜﺪﻳﮕﺮ ﻣﺠﺰﺍ ﻫﺴﺘﻨﺪ ﻳﻌﻨﻲ ﺍﺛﺮ ﻣﺨﺮﺏ ﺭﻭﻱ ﻳﻜﺪﻳﮕﺮ ﻧﺪﺍﺭﻧﺪ‪.‬‬ ‫ﺩ‪ :‬ﻭﻳﮋﮔﻲ ﻫﺎﻱ ﭘﺎﻳﺪﺍﺭﻱ‪Durability‬‬

‫ﭘﺲ ﺍﺯ ﺁﻧﻜﻪ ﺗﺮﺍﻛﻨﺶ ﭘﺬﻳﺮﻓﺘﻪ ﺷﺪ ﺍﺛﺮ ﺁﻥ ﺭﺍ ﺩﺭ ﺑﺎﻧﻚ ﺑﺎﻗﻲ ﻣﻲ ﻣﺎﻧﺪ ﺣﺘﻲ ﺍﮔﺮ ﺳﻴﺴﺘﻢ ﺍﻧﺪﻛﻲ ﺑﻌﺪ ﺍﺯ ﻛﺎﺭ ﺑﻴﻔﺘﺪ‪.‬‬

‫‪ -٢-٦-٥‬ﻣﺜﺎﻝ ﺍﺯ ﺗﺮﺍﻛﻨﺶ‬ ‫ﻓﺮﺽ ﻛﻨﻴﻢ ﻣﻲ ﺧﻮﺍﻫﻴﻢ ﻣﺒﻠﻎ ‪ ٥٠٠٠٠‬ﺭﻳﺎﻝ ﺍﺯ ﺣﺴﺎﺏ ‪ A‬ﺑﻪ ﺣﺴﺎﺏ ‪ B‬ﻣﻨﺘﻘﻞ ﻛﻨﻴﻢ ﺩﺍﺭﻳﻢ ‪:‬‬ ‫)‪1.read (A‬‬ ‫‪2.A:=A-50000‬‬ ‫)‪3.write(A‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٨٤ /‬‬ ‫)‪4.read(B‬‬ ‫‪5.B:=B+50000‬‬ ‫)‪6.write(B‬‬

‫ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺧﻮﺍﺹ ﺗﺮﺍﻛﻨﺶ ﻫﺎ ﺩﺍﺭﻳﻢ ‪:‬‬ ‫ﺍﻟﻒ( ﺧﺎﺻﻴﺖ ﺳﺎﺯﮔﺎﺭﻱ‬ ‫ﻣﺠﻤﻮﻉ ﻣﻘﺎﺩﻳﺮ ‪ A‬ﻭ ‪ B‬ﭘﺲ ﺍﺯ ﺍﺟﺮﺍﻱ ﺗﺮﺍﻛﻨﺶ ﺗﻐﻴﻴﺮ ﻧﻤﻲ ﻛﻨﺪ‪.‬‬ ‫ﺏ(ﺧﺎﺻﻴﺖ ﺍﺗﻤﻲ ﺑﻮﺩﻥ‪:‬‬ ‫ﺍﮔـﺮ ﺗﺮﺍﻛﻨﺶ ﭘﺲ ﺍﺯ ﻣﺮﺣﻠﻪ ‪ ٣‬ﻭ ﻗﺒﻞ ﺍﺯ ﻣﺮﺣﻠﻪ ‪ ٦‬ﻣﺘﻮﻗﻒ ﮔﺮﺩﺩ ‪ ،‬ﺳﻴﺴﺘﻢ ﺗﻀﻤﻴﻦ ﻣﻲ ﻛﻨﺪ ﻛﻪ ﺗﻐﻴﻴﺮﺍﺕ ﺩﺭ ﺑﺎﻧﻚ ﺛﺒﺖ‬ ‫ﻧﮕﺮﺩﻧﺪ‪.‬‬ ‫ﺝ(ﭘﺎﻳﺪﺍﺭﻱ‪:‬‬ ‫ﭘﺲ ﺍﺯ ﺁﻧﻜﻪ ﺍﺟﺮﺍﻱ ﺗﺮﺍﻛﻨﺶ ﻣﻮﺭﺩ ﺗﺎﻳﻴﺪ ﻗﺮﺍﺭ ﮔﺮﻓﺖ ﻭ ﺗﺮﺍﻛﻨﺶ ﻛﺎﻣﻞ ﮔﺮﺩﻳﺪ ‪ ،‬ﺍﻳﻦ ﺗﻐﻴﻴﺮﺍﺕ ﺩﺭ ﺑﺎﻧﻚ ﭘﺎﻳﺪﺍﺭ ﺧﻮﺍﻫﺪ ﺑﻮﺩ‪.‬‬ ‫ﺩ(ﺟﺪﺍﺳﺎﺯﻱ‪:‬‬ ‫ﺍﮔـﺮ ﺑـﻴﻦ ﻣـﺮﺍﺣﻞ ‪٣‬ﻭ‪ ٦‬ﻳـﻚ ﺗﺮﺍﻛﻨﺶ ﺩﻳﮕﺮ ﺍﺟﺎﺯﻩ ﺩﺳﺘﻴﺎﺑﻲ ﺑﻪ ﺗﻐﻴﻴﺮﺍﺕ ﺩﺭ ﺑﺎﻧﻚ ﺭﺍ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ﺑﺎﻋﺚ ﻧﺎﺳﺎﺯﮔﺎﺭﻱ ﺩﺭ‬ ‫ﺑﺎﻧﻚ ﺧﻮﺍﻫﺪ ﮔﺮﺩﻳﺪ)ﻣﺠﻤﻮﻉ ‪A+B‬ﻛﻤﺘﺮ ﺍﺯ ﻣﻘﺪﺍﺭ ﺍﺻﻠﻲ ﺧﻮﺍﻫﺪ ﺷﺪ( ﻟﺬﺍ ﻧﺒﺎﻳﺴﺘﻲ ﺍﻣﻜﺎﻥ ﺍﺟﺎﺯﻩ ﺗﺮﺍﻛﻨﺶ ﻫﺎﻱ ﺩﻳﮕﺮ ﺑﺮﺍﻱ‬ ‫ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﭘﺎﻳﮕﺎﻩ ﺭﺍ ﺑﻮﺟﻮﺩ ﺁﻭﺭﺩ‪.‬‬

‫‪-٣-٦-٥‬ﺣﺎﻟﺘﻬﺎﻱ ﺍﺟﺮﺍﻱ ﺗﺮﺍﻛﻨﺶ‬ ‫ﺍﻟﻒ‪ :‬ﻧﺎﻗﺺ ‪Aborted‬‬

‫ﺩﺭ ﺍﻳﻦ ﺣﺎﻟﺖ ﺩﺭ ﺣﻴﻦ ﺍﺟﺮﺍﻱ ﺗﺮﺍﻛﻨﺶ ﺍﺷﻜﺎﻟﻲ ﭘﻴﺶ ﺁﻣﺪﻩ ﺍﺳﺖ ﻛﻪ ﻣﻨﺠﺮ ﺑﻪ ﺗﻮﻗﻒ ﺍﺟﺮﺍﻱ ﺁﻥ ﺷﺪﻩ ﺍﺳﺖ ﻭ ﻟﺬﺍ ﺗﺮﺍﻛﻨﺶ‬ ‫ﻧﻴﻤﻪ ﺗﻤﺎﻡ ﺭﻫﺎ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺏ‪ :‬ﺑﺮﮔﺸﺖ ‪Rolled back‬‬

‫ﺩﺭ ﺻـﻮﺭﺕ ﺑـﺮﻭﺯ ﺍﺷﻜﺎﻝ ﺩﺭ ﺍﺟﺮﺍﻱ ﻳﻚ ﺗﺮﺍﻛﻨﺶ ‪ ،‬ﺑﺮﺍﻱ ﺣﻔﻆ ﻳﻜﭙﺎﺭﭼﮕﻲ ﺍﻃﻼﻋﺎﺕ ‪ ،‬ﺍﺛﺮﺍﺕ ﺍﺣﺘﻤﺎﻟﻲ ﺑﺨﺸﻲ ﺍﺯ ﺗﺮﺍﻛﻨﺶ‬ ‫ﻛﻪ ﺍﺟﺮﺍ ﺷﺪﻩ ﺭﻭﻱ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺑﺎﻳﺪ ﺧﻨﺜﻲ ﺷﻮﺩ‪ .‬ﺑﻪ ﺍﻳﻦ ﺣﺎﻟﺖ ﺑﺮﮔﺸﺖ ﮔﻔﺘﻪ ﻣﻲ ﺷﻮﺩ ‪.‬ﻣﺴﺌﻮﻟﻴﺖ ﺍﻳﻦ ﺍﻣﺮ ﺑﻌﻬﺪﻩ ‪dbms‬‬

‫ﺍﺳﺖ‪.‬‬ ‫ﺝ‪ :‬ﭘﺬﻳﺮﺵ ﺷﺪﻩ ‪Commited‬‬

‫ﺣﺎﻟﺘﻲ ﺍﺳﺖ ﻛﻪ ﻋﻤﻠﻴﺎﺕ ﺗﺮﺍﻛﻨﺶ ﺑﻄﻮﺭﻛﺎﻣﻞ ﻣﻮﻓﻘﻴﺖ ﺁﻣﻴﺰ ﺍﻧﺠﺎﻡ ﺷﺪﻩ ﻭ ﺍﺛﺮ ﺁﻥ ﻧﻴﺰ ﺛﺒﺖ ﺷﺪﻩ ﺍﺳﺖ ﭘﺲ ﺍﺯ ﺍﺟﺮﺍﻱ ﺗﺮﺍﻛﻨﺶ‬ ‫ﺧﻨﺜﻲ ﻛﺮﺩﻥ ﺗﻐﻴﻴﺮﺍﺕ ﺍﺣﺘﻤﺎﻟﻲ ﺗﺮﺍﻛﻨﺶ ﺭﻭﻱ ﺑﺎﻧﻚ ﻏﻴﺮ ﻣﻤﻜﻦ ﺍﺳﺖ‪.‬‬ ‫ﺩﺭ ﺑﻴﺸﺘﺮ ﺳﻴﺴﺘﻤﻬﺎ ﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ‪ ،‬ﻫﺮ ﺩﺳﺘﻮﺭ ‪ SQL‬ﻛﻪ ﺍﺟﺮﺍﻱ ﻣﻮﻓﻘﻲ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ‪ ،‬ﺑﻄﻮﺭ ﺧﻮﺩﻛﺎﺭ ﭘﺬﻳﺮﻓﺘﻪ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺩﺭ ‪ SQL:1999‬ﺑﺮﺍﻱ ﻧﻮﺷﺘﻦ ﺑﻪ ﻓﺮﻡ ﺗﺮﺍﻛﻨﺶ ﺍﺯ ﺩﺳﺘﻮﺭ ﺯﻳﺮ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻴﺸﻮﺩ‪.‬‬ ‫‪begin atomic‬‬ ‫…‬ ‫‪end‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٨٥ /‬‬

‫ﻓﺼﻞ ﺷﺸﻢ‪:‬‬ ‫ﻧﺮﻣﺎﻟﺘﺮ ﺳﺎﺯﻱ ﺭﺍﺑﻄﻪ ﻫﺎ‬ ‫‪ ١-٦‬ﻣﻘﺪﻣﻪ ‪:‬‬ ‫ﺍﻳـﺪﻩ ﺍﺻـﻠﻲ ﻧﺮﻣﺎﻟﺘـﺮ ﺳﺎﺯﻱ ﺭﺍﺑﻄﻪ ﻫﺎ ﺑﺮ ﻣﺒﻨﺎﻱ ﺭﻓﻊ ﺁﻧﻮﻣﺎﻟﻲ ﻫﺎﻱ ﺭﺍﺑﻄﻪ ﻫﺎ ﺳﺖ‪ .‬ﻣﻲ ﺩﺍﻧﻴﻢ ﺍﺻﻄﻼﺡ ﺁﻧﻮﻣﺎﻟﻲ ﻳﻌﻨﻲ ﺑﺮﻭﺯ‬ ‫ﻭﺿـﻌﻴﺖ ﻧﺎﻣﻄﻠـﻮﺏ ﺩﺭ ﺍﻧﺠـﺎﻡ ﻋﻤـﻞ ﻛـﻪ ﻣﻲ ﺗﻮﺍﻧﺪ ﻧﺎﻣﻤﻜﻦ ﺑﻮﺩﻥ ﺍﻧﺠﺎﻡ ﻳﻚ ﻋﻤﻞ ﻭ ﻳﺎ ﺑﺮﻭﺯ ﺗﺒﻌﺎﺕ ﻧﺎﻣﻄﻠﻮﺏ ﺩﺭ ﺍﻧﺠﺎﻡ ﻳﻚ‬ ‫ﻋﻤـﻞ ﻭ ﻳـﺎ ﺑـﺮﻭﺯ ﺩﺷـﻮﺍﺭﻱ ) ﻓـﺰﻭﻧﻜﺎﺭﻱ( ﺩﺭ ﻋﻤﻠـﻴﺎﺕ ﺑﺎﺷـﺪ‪ .‬ﺑﺮﺍﻱ ﺭﻓﻊ ﺁﻧﻮﻣﺎﻟﻲ ﻫﺎ ﺑﺎﻳﺪ ﺭﺍﺑﻄﻪ ﻫﺎ ﻧﺮﻣﺎﻟﺘﺮ ﺷﻮﻧﺪ‪ .‬ﺑﻌﻨﻮﺍﻥ ﻣﺜﺎﻝ‬ ‫ﺭﺍﺑﻄﻪ ﻱ ﻣﺎﻧﻨﺪ ‪ SPC‬ﺭﺍ ﺯﻳﺮ ﺩﺭ ﻧﻈﺮ ﻣﻲ ﮔﻴﺮﻳﻢ‪:‬‬ ‫ﺍﻫﺪﺍﻑ ﻧﺮﻣﺎﻝ ﺳﺎﺯﻱ ‪:‬‬ ‫‪P#‬‬

‫‪S#‬‬

‫‪ -٣‬ﺗﺎﻣﻴﻦ ﻃﺮﺡ ﺑﻬﺘﺮ ﺑﺮﺍﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻗﺎﺑﻞ‬

‫‪s1‬‬ ‫‪s1‬‬ ‫‪s1‬‬

‫‪p1‬‬ ‫‪p2‬‬ ‫‪p3‬‬

‫‪100‬‬ ‫‪200‬‬ ‫‪150‬‬

‫‪c2‬‬ ‫‪c2‬‬ ‫‪c2‬‬

‫ﺩﺭﻙ ﺗﺮ‬

‫‪s2‬‬

‫‪p1‬‬

‫‪100‬‬

‫‪s2‬‬

‫‪p2‬‬

‫‪c3‬‬ ‫‪c3‬‬ ‫‪c3‬‬

‫‪-١‬ﻛﺎﻫﺶ ﺑﺮﺧﻲ ﺍﺯ ﺁﻧﻮﻣﺎﻟﻲ ﻫﺎ‬ ‫‪ -٢‬ﻛﺎﻫﺶ ﺍﻓﺰﻭﻧﮕﻲ‬

‫‪ -٤‬ﺍﻋﻤﺎﻝ ﺑﺮﺧﻲ ﻗﻮﺍﻋﺪ ﺟﺎﻣﻌﻴﺘﻲ ﻧﺎﺷﻲ ﺍﺯ‬ ‫ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ‬

‫‪QTY CITY‬‬

‫‪s3‬‬

‫‪p1‬‬

‫‪80‬‬ ‫‪90‬‬

‫ﺍﻳـﻦ ﺭﺍﺑﻄـﻪ ﻋﻨﺎﺻـﺮﺵ ﺍﺗﻤـﻴﻚ ) ﺳـﺎﺩﻩ ( ﻣـﻲ ﺑﺎﺷـﻨﺪ ﻛـﻪ ﺑـﻪ ﺁﻥ ﺭﺍﺑﻄﻪ ﻧﺮﻣﺎﻝ ‪ INF‬ﻧﻴﺰ ﻣﻲ ﮔﻮﻳﻨﺪ‪ .‬ﺍﻣﺎ ﺍﻳﻦ ﺭﺍﺑﻄﻪ ﺩﺭ ﻋﻤﻠﻴﺎﺕ‬ ‫ﺁﻧﻮﻣﺎﻟﻲ ﺩﺍﺭﺩ‪:‬‬ ‫‪ -١‬ﺩﺭ ﻋﻤﻞ ﺩﺭﺝ‪ :‬ﺩﺭﺝ ﻛﻦ ﺍﻃﻼﻉ 〉‪〈 sv, cv‬‬

‫‪ sv‬ﺳﺎﻛﻦ ‪ cv‬ﺍﺳﺖ ‪.‬‬

‫ﺍﻳﻦ ﺩﺭﺝ ﻧﺎﻣﻤﻜﻦ ﺍﺳﺖ ﺗﺎ ﻭﻗﺘﻴﻜﻪ ﻧﺪﺍﻧﻴﻢ ﭼﻪ ﻗﻄﻌﻪ ﺍﻱ ﺭﺍ ﺗﻬﻴﻪ ﻛﺮﺩﻩ ﺍﺳﺖ‪.‬‬ ‫‪ -٢‬ﺩﺭ ﻋﻤﻞ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ‪:‬‬ ‫ﺷـﻬﺮ ‪ s1‬ﺭﺍ ﻋﻮﺽ ﻛﻨﻴﺪ‪ .‬ﻋﻤﻞ ﻣﻨﻄﻘﹰﺎ ﺗﺎﭘﻠﻲ ﺑﻪ ﻋﻤﻠﻲ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺗﺒﺪﻳﻞ ﻣﻲ ﺷﻮﻧﺪ‪ .‬ﻭ ﺑﻪ ﻧﻮﻋﻲ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ ﻣﻨﺘﺸﺮ ﺷﻮﻧﺪﻩ‬ ‫ﺩﺍﺭﻳﻢ‪.‬‬ ‫‪ -٣‬ﺩﺭ ﻋﻤﻞ ﺣﺬﻑ ‪:‬‬ ‫ﺑﺎ ﺣﺬﻑ ﺍﻃﻼﻉ‬

‫〉‪ 〈 s3 , p1 ,90‬ﺍﻃﻼﻉ ﻧﺎﺧﻮﺍﺳﺘﻪ ﺍﺯ ﺑﻴﻦ ﻣﻲ ﺭﻭﺩ ) ‪ s3‬ﺳﺎﻛﻦ ﺷﻬﺮ ‪ c3‬ﺍﺳﺖ(‪.‬‬

‫ﺭﺍﺑﻄـﻪ ‪ spc‬ﺧـﻮﺵ ﺳـﺎﺧﺘﺎﺭ ﻧﻴﺴـﺖ ﺭﻭﺵ ﻫـﺎﻱ ﻧﺮﻣﺎﻟﺘﺮ ﺳﺎﺯﻱ ﺑﻌﻨﻮﺍﻥ ﻳﻚ ﺍﺑﺰﺍﺭ ﻃﺮﺍﺣﻲ ﺑﻪ ﻃﺮﺍﺡ ﻣﻲ ﮔﻮﻳﺪ ﺩﺭ ﻳﻚ‬ ‫ﻣﺤـﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﻣﺸﺨﺺ ﭼﻪ ﺭﺍﺑﻄﻪ ﻫﺎﻳﻲ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪ ،‬ﺩﺭ ﻫﺮ ﺭﺍﺑﻄﻪ ﭼﻪ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺍﻱ ﺗﺎ ﺭﻓﺘﺎﺭ ‪ DBMS‬ﺩﺭ ﻋﻤﻠﻴﺎﺕ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٨٦ /‬‬

‫ﺭﻭﻱ ﭘﺎﻳﮕـﺎﻩ ﺑـﺎ ﻛﻤﺘـﺮﻳﻦ ﺁﻧﻮﻣﺎﻟـﻲ ﻫﻤـﺮﺍﻩ ﺑﺎﺷـﺪ ‪ .‬ﺩﺭ ﻣﺜﺎﻝ ﻓﻮﻕ ﺩﻟﻴﻞ ﺑﺮﻭﺯ ﺁﻧﻮﻣﺎﻟﻴﻬﺎﻱ ﺭﺍﺑﻄﻪ ‪ SPC‬ﭘﺪﻳﺪﻩ ﺍﻱ ﺍﺳﺖ ﺑﻨﺎﻡ‬ ‫ﺍﺧـﺘﻼﻁ ﺍﻃﻼﻋﺎﺗـﻲ ﻳﻌﻨـﻲ ﺍﻃﻼﻋـﺎﺕ ﺩﺭ ﻣـﻮﺭﺩ ﺩﻭ ﭘﺪﻳـﺪﻩ ) ﻣﻮﺟـﻮﺩﻳﺖ ( ﺑﻄﻮﺭ ﻏﻴﺮ ﻻﺯﻡ ﺩﺭ ﻳﻜﺪﻳﮕﺮ ﻣﺨﻠﻮﻁ ﺷﺪﻩ ﺍﻧﺪ‬ ‫ﺑﻌﺒﺎﺭﺗﻲ ﺍﻃﻼﻉ ﺩﺭ ﻣﻮﺭﺩ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ﻭ ﺷﻬﺮﺵ ﺑﺎ ﺍﻃﻼﻉ ﻗﻄﻌﻪ ﻣﺨﻠﻮﻁ ﺷﺪﻩ ﺍﺳﺖ‪.‬‬ ‫‪ -٢-٦‬ﺷﻜﻞ ﻫﺎﻱ ﻧﺮﻣﺎﻝ ) ﺳﻄﻮﺡ ﻣﺨﺘﻠﻒ ﻧﺮﻣﺎﻝ(‬ ‫ﺳﻄﻮﺡ ﻣﺨﺘﻠﻒ ﻧﺮﻣﺎﻝ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺑﻴﺎﻥ ﻧﻤﻮﺩ‪:‬‬ ‫‪INF‬‬

‫‪INF -‬‬

‫‪2NF‬‬

‫‪2NF-‬‬

‫‪3NF‬‬

‫‪3NF-‬‬

‫‪BCNF‬‬

‫‪BCNF-‬‬

‫‪4NF‬‬

‫‪4NF-‬‬

‫‪5NF‬‬

‫‪5NP‬‬‫‪DK/NF-‬‬

‫ﺷﻜﻞ ﻣﻘﺎﺑﻞ ﺳﻄﻮﺡ ﻣﺨﺘﻠﻒ ﻧﺮﻣﺎﻝ ﺭﺍ ﻧﺸﺎﻥ ﻣﻲ ﺩﻫﺪ‪.‬‬ ‫ﻗﺒﻞ ﺍﺯ ﺑﺮﺭﺳﻲ ﺳﻄﻮﺡ ﻧﺮﻣﺎﻝ ﺑﺮﺧﻲ ﻣﻔﺎﻫﻴﻢ ﻣﻮﺭﺩ ﻧﻴﺎﺯ ﺭﺍ ﺗﻮﺿﻴﺢ ﻣﻲ ﺩﻫﻴﻢ‪:‬‬ ‫‪ -٣-٦‬ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ )‪dependency‬‬

‫‪(functional‬‬

‫ﮔﻮﺋـﻴﻢ ﺻـﻔﺖ ﺧﺎﺻـﻪ ‪ R.Y‬ﺑﺎ ‪ R . X‬ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﺩﺍﺭﺩ ﺍﮔﺮ ﺑﺎﺯﺍﻱ ﻫﺮ ﻣﻘﺪﺍﺭ ﻣﺘﻤﺎﻳﺰ ‪ X‬ﻓﻘﻂ ﻳﻚ ﻣﻘﺪﺍﺭ ‪ Y‬ﻣﺘﻨﺎﻇﺮ ﺑﺎﺷﺪ‬ ‫ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﻣﻲ ﮔﻮﺋﻴﻢ ‪ Y‬ﺑﺎ ‪ X‬ﻭﺍﺑﺴﺘﮕﻲ ﺩﺍﺭﺩ ﻭ ﺑﻪ ‪ X‬ﺩﺗﺮﻣﻴﻨﺎﻥ ﻭ ﺑﻪ ‪ Y‬ﻭﺍﺑﺴﺘﻪ ﻧﻴﺰ ﮔﻮﻳﻨﺪ‪ .‬ﻭ ﺑﺼﻮﺭﺕ‬ ‫‪ x → y‬ﻧﺸﺎﻥ ﻣﻲ ﺩﻫﻴﻢ‬ ‫ﻣﺜﺎﻝ ﻣﻘﺪﻣﺎﺗﻲ ‪ :‬ﻓﺮﺽ ﻛﻨﻴﺪ ﺭﺍﺑﻄﻪ ﻣﻘﺎﺑﻞ ﺭﺍ ﺩﺍﺭﻳﻢ‬ ‫ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﺩﺍﺭﻳﻢ‪:‬‬ ‫‪X → Z‬‬ ‫‪Z→ X‬‬ ‫‪X →Y‬‬

‫ﺩ ﺭ ﺗﻌﺮﻳﻒ ﻭﺍﺑﺴﺘﮕﻲ ﺑﺎﻳﺴﺘﻲ ﺑﻪ ﺩﻭ ﻧﻜﺘﻪ ﺗﻮﺟﻪ ﺩﺍﺷﺖ‪:‬‬

‫‪Z‬‬

‫‪Y‬‬

‫‪X‬‬

‫‪Z1‬‬ ‫‪Z1‬‬ ‫‪Z1‬‬ ‫‪Z2‬‬ ‫‪Z2‬‬

‫‪Y1‬‬ ‫‪Y2‬‬ ‫‪Y3‬‬ ‫‪Y1‬‬ ‫‪Y2‬‬

‫‪X1‬‬ ‫‪X1‬‬ ‫‪X1‬‬ ‫‪X2‬‬ ‫‪X2‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٨٧ /‬‬

‫‪ -١‬ﻭﺍﺑﺴـﺘﮕﻲ ﺗﺎﺑﻌـﻲ ﺑﺎﻳـﺪ ﺑﺮﺍﻱ ﺗﻤﺎﻡ ﺭﺍﺑﻄﻪ ﻫﺎ ﺩﺭﺳﺖ ﺑﺎﺷﺪ ﻳﻌﻨﻲ ﺍﺯ ﻣﻔﻬﻮﻡ ﻭ ﻣﻌﻨﻲ ﺁﻥ ﺻﻔﺎﺕ ﺳﺮﭼﺸﻤﻪ ﺑﮕﻴﺮﺩ ﻧﻪ ﺍﺯ ﻣﻮﺍﺭﺩ‬ ‫ﺧـﺎﺹ ﺩﺭ ﻳـﻚ ﻳـﺎ ﭼـﻨﺪ ﺭﺍﺑﻄـﻪ ‪ .‬ﺑﻌـﻨﻮﺍﻥ ﻣﺜﺎﻝ ﺩﺭ ﺟﺪﻭﻝ ﺯﻳﺮ ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ ﺯﻳﺎﺩﻱ ﺩﻳﺪﻩ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﺩﺭ ﻭﺍﻗﻊ ﺻﺤﻴﺢ‬ ‫ﻧﻴﺴﺖ‪.‬‬ ‫ﻛﻼﺱ‬

‫ﺗﺮﻡ‬

‫ﺩﺭﺱ‬

‫‪١٠٦‬‬

‫‪٧٩١‬‬

‫ﺍﺳﻤﺒﻠﻲ‬

‫ﻛﻼﺱ → ﺩﺭﺱ‬

‫‪١٠٥‬‬

‫‪٧٩٢‬‬

‫ﻣﺒﺎﻧﻲ ﻛﺎﻣﭙﻴﻮﺗﺮ‬

‫ﺍﺳﺘﺎﺩ → ﺩﺭﺱ‬

‫‪١٠٤‬‬

‫‪٧٩٣‬‬

‫ﻣﺪﺍﺭ ﺍﻟﻜﺘﺮﻳﻜﻲ ﺭﺣﻴﻤﻲ‬

‫ﺩﺭﺱ → ﺍﺳﺘﺎﺩ‬

‫‪٣٠١‬‬

‫‪٨٠١‬‬

‫ﺯﻳﻨﺎﻟﻲ‬

‫ﺍﺳﺘﺎﺩ → ﻛﻼﺱ‬

‫ﻣﺪﺍﺭ ﻣﻨﻄﻘﻲ‬

‫ﺍﺳﺘﺎﺩ‬ ‫ﺣﻤﻴﺪﻱ‬ ‫ﺷﺮﻳﻔﻲ‬

‫‪ -٢‬ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﺑﺮﺍﻱ ﺗﻌﺮﻳﻒ ﻣﺤﺪﻭﻳﺘﻬﺎﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻧﻴﺰ ﺑﻜﺎﺭ ﻣﻲ ﺭﻭﺩ‪ .‬ﻳﻚ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﻣﻤﻜﻦ ﺍﺳﺖ ﺑﺮﺍﻱ ﻳﻚ‬ ‫ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺩﺭﺳﺖ ﻭ ﺩﺭ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺩﻳﮕﺮ ﻏﻠﻂ ﺑﺎﺷﺪ ﻟﺬﺍ ﻃﺮﺍﺡ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻣﻲ ﺗﻮﺍﻧﺪ ﻗﻮﺍﻋﺪ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺕ ﺧﻮﺩ ﺭﺍ‬ ‫ﺑﺎ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﻧﻴﺰ ﺑﻴﺎﻥ ﻧﻤﺎﻳﺪ‪.‬‬ ‫ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ ﺗﺎﺑﻌﻲ ﺯﻳﺮ ﺭﺍ ﻣﻲ ﺗﻮﺍﻥ ﺑﺮﺍﻱ ﺭﺍﺑﻄﻪ ‪ SPC‬ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺖ‪.‬‬ ‫‪Qty‬‬ ‫→‬ ‫‪city‬‬ ‫→‬ ‫‪→ city‬‬ ‫‪s#‬‬ ‫→‬ ‫)‪( city ,Qty‬‬ ‫→‬

‫)‪(s# ,p#‬‬ ‫)‪(s# ,p#‬‬ ‫) ‪(s#‬‬ ‫)‪(s# ,p#‬‬ ‫)‪(s# ,p#‬‬

‫‪-١-٣-٦‬ﻣﻔﻬﻮﻡ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﻛﺎﻣﻞ )‪(FFD‬‬ ‫ﺻـﻔﺖ ﺧﺎﺻـﻪ ‪ y‬ﺍﺯ ﺭﺍﺑﻄـﻪ ‪ R‬ﺑـﺎ ﺻـﻔﺖ ﺧﺎﺻﻪ ‪ x‬ﺍﺯ ﺁﻥ ‪ FD‬ﻛﺎﻣﻞ ﺩﺍﺭﺩ ﻫﺮ ﮔﺎﻩ ‪ y‬ﺑﺎ ‪ FD ، x‬ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ﺍﻣﺎ ﺑﺎ ﻫﻴﭽﻜﺪﺍﻡ ﺍﺯ‬ ‫ﺍﺟـﺰﺍ ﺗﺸـﻜﻴﻞ ﺩﻫﻨﺪﻩ ﺁﻥ ‪ FD‬ﻧﺪﺍﺷﺘﻪ ﺑﺎﺷﺪ ﻭ ﺁﻥ ﺭﺍ ﺑﺼﻮﺭﺕ ‪⇒ R.Y‬‬

‫ﺩﺍﺭﻳﻢ ‪:‬‬

‫‪( S ≠, P ≠ ) → Qty‬‬

‫‪ R.X‬ﻧﺸﺎﻥ ﻣﻲ ﺩﻫﻴﻢ ﺑﻌﻨﻮﺍﻥ ﻣﺜﺎﻝ ﺩﺭ ﺭﺍﺑﻄﻪ ‪SPC‬‬

‫ﻭ ﭘﺲ ‪( s ≠, p ≠) ⇒ Qty‬‬

‫‪s ≠→ Qty‬‬ ‫‪p ≠→ Qty‬‬

‫•‬

‫ﺍﮔﺮ ﺑﺮﺍﻱ ﺗﻤﺎﻡ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ‪ y‬ﺩﺭ ‪ R‬ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ ‪ x → y‬ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ‪ x‬ﺭﺍ ﺍﺑﺮ ﻛﻠﻴﺪ ‪ R‬ﻣﻲ ﻧﺎﻣﻨﺪ ﻭ ﺑﺼﻮﺭﺕ‬ ‫‪ x → R‬ﻧﻤﺎﻳﺶ ﻣﻲ ﺩﻫﻨﺪ ‪ .‬ﺍﮔﺮ ﺍﻳﻦ ﻭﺍﺑﺴﺘﮕﻲ ﺍﺯ ﻧﻮﻉ ‪ FFD‬ﺑﺎﺷﺪ ﺁﻧﮕﺎﻩ ‪ X‬ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ‪ R‬ﺍﺳﺖ ‪.‬‬

‫‪-٢-٣-٦‬ﺗﻌﺮﻳﻒ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﺑﺪﻳﻬﻲ‪:‬‬ ‫ﺍﮔـﺮ ‪ Y‬ﺯﻳﺮ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ‪ X‬ﺑﺎﺷﺪ ﺁﻧﮕﺎﻩ ‪ x → y‬ﺍﻳﻦ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﺭﺍ ﺑﺪﻳﻬﻲ ) ‪ (trival‬ﻣﻲ ﻧﺎﻣﻴﻢ ‪ .‬ﺑﻌﺒﺎﺭﺕ ﺩﻳﮕﺮ‬ ‫ﻳﻚ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﺭﺍ ﺑﺪﻳﻬﻲ ﮔﻮﻳﻨﺪ ﺍﮔﺮ ﻭ ﻓﻘﻂ ﺍﮔﺮ ﺳﻤﺖ ﺭﺍﺳﺖ ﺁﻥ ﺯﻳﺮ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﺳﻤﺖ ﭼﭗ ﺑﺎﺷﺪ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٨٨ /‬‬

‫ﻣﻤﻜـﻦ ﺍﺳﺖ ﺑﻌﻀﻲ ﺍﺯ ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ ﺗﺎﺑﻌﻲ ﺭﺍ ﺍﺯ ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ ﺗﺎﺑﻌﻲ ﺩﻳﮕﺮ ﻧﺘﻴﺠﻪ ﮔﺮﻓﺖ ﺑﻌﻨﻮﺍﻥ ﻣﺜﺎﻝ ﺍﺯ ﻭﺍﺑﺴﺘﮕﻲ‬ ‫ﺗﺎﺑﻌــﻲ ) ‪ ( s ≠, p ≠) → (city, Qty‬ﻣــﻲ ﺗــﻮﺍﻥ ﺩﻭ ﻭﺍﺑﺴــﺘﮕﻲ ‪ ( s ≠, p ≠) → Qty, ( s ≠, p ≠) → city‬ﺭﺍ ﻧﺘــﻴﺠﻪ‬ ‫ﮔﺮﻓﺖ‪.‬‬ ‫ﻣﺠﻤـﻮﻋﻪ ﺗﻤـﺎﻡ ﻭﺍﺑﺴـﺘﮕﻲ ﻫﺎﻱ ﺗﺎﺑﻌﻲ ﻛﻪ ﺗﻮﺳﻂ ﻣﺠﻤﻮﻋﻪ ﻣﻌﻴﻨﻲ ﺍﺯ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﺑﺪﺳﺖ ﻣﻲ ﺁﻳﻨﺪ ﺭﺍ ﺑﺴﺘﺎﺭ ﺭﺍﺑﻄﻪ‬ ‫ﮔﻮﻳـﻨﺪ‪ .‬ﺑﻌﺒﺎﺭﺕ ﺩﻳﮕﺮ ﺍﮔﺮ ‪ F‬ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ‪ FD‬ﻫﺎﻱ ﺭﺍﺑﻄﻪ ‪ F‬ﺑﺎﺷﺪ‪ ،‬ﻣﺠﻤﻮﻋﻪ ﺗﻤﺎﻡ ‪ FD‬ﻫﺎﻳﻲ ﻛﻪ ‪ F‬ﻗﺎﺑﻞ ﺍﺳﺘﻨﺘﺎﺝ‬ ‫ﻫﺴـﺘﻨﺪ ﺭﺍ ﺑﺴـﺘﺎﺭ ) ﭘﻮﺷﺸـﻲ( ) ‪ (CLOSURE‬ﻣﺠﻤﻮﻋﻪ ‪ F‬ﮔﻮﻳﻨﺪ ﻭ ﺑﺎ ‪ F+‬ﻧﻤﺎﻳﺶ ﻣﻲ ﺩﻫﻨﺪ‪ ،‬ﺍﻭﻟﻴﻦ ﺗﻼﺵ ﺩﺭ ﺟﻬﺖ‬ ‫ﺣـﻞ ﺍﻳـﻦ ﻣﺴﺄﻟﻪ ﺩﺭ ﻣﻘﺎﻟﻪ ﺍﻱ ﻛﻪ ﺗﻮﺳﻂ ﺁﺭﻣﺴﺘﺮﺍﻧﮓ ﻣﻨﺘﺸﺮ ﺷﺪ‪ ،‬ﺻﻮﺭﺕ ﮔﺮﻓﺖ ﻛﻪ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﻗﻮﺍﻧﻴﻦ ﺍﺳﺘﻨﺘﺎﺝ‬ ‫ﻛـﻪ ﺑﻌـﻨﻮﺍﻥ ﺍﺻـﻮﻝ ﺁﺭﻣﺴـﺘﺮﺍﻧﮓ ﻧﺎﻣـﻴﺪﻩ ﻣـﻲ ﺷـﺪﻧﺪ ﺭﺍ ﺍﺭﺍﺋـﻪ ﺩﺍﺩ ﻛﻪ ﺑﻪ ﻛﻤﻚ ﺁﻥ ﻣﻲ ﺗﻮﺍﻥ ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ ﺗﺎﺑﻌﻲ‬ ‫ﺟﺪﻳﺪﻱ ﺭﺍ ﺍﺯ ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ ﺗﺎﺑﻌﻲ ﻣﻮﺟﻮﺩ ﺍﺳﺘﻨﺘﺎﺝ ﻛﺮﺩ‪.‬‬ ‫‪ -٣-٣-٦‬ﺍﺻﻮﻝ ﺁﺭﻣﺴﺘﺮﺍﻧﮓ‬ ‫‪ -١‬ﻗﺎﻋﺪﻩ ﺍﻧﻌﻜﺎﺳﻲ ) ‪: (Reflexivity‬‬ ‫ﺍﮔﺮ ‪ B‬ﺯﻳﺮ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ‪ A‬ﺑﺎﺷﺪ ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ‬

‫‪A → B‬‬

‫‪ -٢‬ﻗﺎﻋﺪﻩ ﺍﻓﺰﺍﻳﺶ ) ‪ (augmentation‬ﺍﮔﺮ ‪ A → B‬ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ )‪(A,C) → (B,C‬‬ ‫‪ -٣‬ﻗﺎﻋﺪﻩ ﺗﻌﺪﻱ )‪ : (transitivity‬ﺍﮔﺮ ‪ A → B‬ﻭ ‪ B → C‬ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ‪A →C‬‬ ‫‪ -٤‬ﻗﺎﻋﺪﻩ ﺗﺠﺰﻳﻪ ﭘﺬﻳﺮﻱ )‪ : (decomposition‬ﺍﮔﺮ )‪ A → (B,C‬ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ‪A → C,A → B‬‬ ‫‪ -٥‬ﻗﺎﻋﺪﻩ ﺍﺟﺘﻤﺎﻉ )‪ : (union‬ﺍﮔﺮ ‪ A → B‬ﻭ ‪ A →C‬ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ )‪A → (B,C‬‬ ‫‪ -٦‬ﻗﺎﻋﺪﻩ ﺷﺒﻪ ﺗﻌﺪﻱ )‪ : (psoudo transitivity‬ﺍﮔﺮ ‪ A → B‬ﻭ‪ (C,B) → D‬ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ‪(A,C) → D‬‬ ‫‪ -٦‬ﻗﺎﻋﺪﻩ ﺗﺮﻛﻴﺐ‪ :‬ﺍﮔﺮ ‪ A→B‬ﻭ ‪ C→D‬ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ )‪(A,C) → (B,D‬‬

‫‪-٤-٣-٦‬ﺑﺴﺘﺎﺭ ﻳﻚ ﻣﺠﻤﻮﻋﻪ ﺍﺯ ﺻﻔﺎﺕ ﺧﺎﺻﻪ‬ ‫ﺍﮔـﺮ ‪ F‬ﻣﺠﻤـﻮﻋﻪ ﺍﻱ ﺍﺯ ‪ FD‬ﺑﺎﺷـﺪ‪ ،‬ﮔـﺎﻩ ﻻﺯﻡ ﻣـﻲ ﺁﻳـﺪ ﻛـﻪ ﻣﺠﻤـﻮﻋﻪ ﺗﻤﺎﻡ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺭﺍﺑﻄﻪ ‪ R‬ﺭﺍ ﻛﻪ ﺑﺎ ﻳﻚ ﺻﻔﺖ‬ ‫ﺧﺎﺻـﻪ ﻳـﺎ ﻣﺠﻤـﻮﻋﻪ ﺍﻱ ﺍﺯ ﺻـﻔﺎﺕ ﺧﺎﺻـﻪ ﻣـﺜ ﹰ‬ ‫ﻼ ‪ A‬ﺍﺯ ﺭﺍﺑﻄـﻪ ‪ R‬ﻭﺍﺑﺴـﺘﮕﻲ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ‪ ،‬ﻣﺸﺨﺺ ﻧﻤﺎﺋﻴﻢ ﺍﻳﻦ ﻣﺠﻤﻮﻋﻪ ﺍﺯ‬ ‫ﺻـﻔﺎﺕ ﺧﺎﺻـﻪ ﺭﺍ ﺑﺴﺘﺎﺭ ‪ A‬ﻧﺎﻣﻴﺪﻩ ﻭ ﺁﻥ ﺭﺍ ﺑﺎ ‪ A +‬ﻧﻤﺎﻳﺶ ﻣﻲ ﺩﻫﻴﻢ‪ .‬ﻣﻲ ﺗﻮﺍﻥ ‪ A +‬ﺭﺍ ﺑﺎ ﻣﺤﺎﺳﺒﻪ ‪ F +‬ﻭ ﺍﻧﺘﺨﺎﺏ ﺁﻥ ‪FD‬‬

‫ﻫﺎﻳﻲ ﻛﻪ ﺩﺭ ﺁﻥ ‪ A‬ﺩﺗﺮﻣﻴﻨﺎﻥ ﺍﺳﺖ ﺑﺪﺳﺖ ﺁﻭﺭﺩ‪.‬‬ ‫ﺗﻤﺮﻳﻦ ‪ :‬ﻓﺮﺽ ﻛﻨﻴﺪ ‪ A D CD B ,ad C‬ﻧﺎﻥ ﺩﻫﻴﺪ ‪ AD‬ﺍﺑﺮ ﻛﻠﻴﺪ ﺍﺳﺖ ﻭﻟﻲ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﻧﻴﺴﺖ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﻓﺮﺽ ﻛﻨﻴﺪ ﻣﺘﻐﻴﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ‪ R‬ﺑﺎ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ‪ FD ,F,E,D,C,B,A‬ﺯﻳﺮ ﺩﺍﺩﻩ ﺷﺪﻩ ﺍﺳﺖ ﻧﺸﺎﻥ ﺩﻫﻴﺪ ﻭﺍﺑﺴﺘﮕﻲ‬ ‫ﺗﺎﺑﻌﻲ ‪ (A,D)→ F‬ﺑﺮﺍﻱ ‪ R‬ﺑﺮﻗﺮﺍﺭ ﺍﺳﺖ‪.‬‬ ‫)‪R=(A,B,C,D,E,F‬‬ ‫})‪FD={ A → (B,C) , B → E , (C,D) → (E,F‬‬ ‫)‪1) A → (B,C‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٨٩ /‬‬ ‫‪2) A →C‬‬

‫ﺗﺠﺰﻳﻪ‬

‫)‪3) (A,D) → (C,D‬‬

‫ﺑﺴﻂ ﭘﺬﻳﺮﻱ‬

‫)‪4) (C,D) → (E,F‬‬ ‫)‪5) (A,D) → (E,F‬‬ ‫‪6) (A,D) → F‬‬

‫)‪ R=(U,V,W,X,Y,Z‬ﻭ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ‪ F‬ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺩﺍﺩﻩ ﺷﺪﻩ ﺍﺳﺖ ‪ F + .‬ﺭﺍ‬

‫ﻣﺜﺎﻝ ‪ :‬ﺭﺍﺑﻄﻪ ‪ R‬ﺑﺎ ﺻﻔﺎﺕ ﺧﺎﺻﻪ‬ ‫ﻣﺤﺎﺳﺒﻪ ﻛﻨﻴﺪ‪.‬‬

‫})‪F={ U→ (X,Y) , X → Y , (X,Y) → (Z,V‬‬ ‫} )‪F + = { U → X , U → Y , X → Y , (X, Y ) → ( Z,V ), U → (Z,V‬‬

‫‪ -٥-٣-٦‬ﻣﺠﻤﻮﻋﻪ ﻭﺍﺑﺴﺘﮕﻲ ﺑﻬﻴﻨﻪ‪:‬‬ ‫ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﻗﻮﺍﻋﺪ ﺳﻪ ﮔﺎﻧﻪ ﺯﻳﺮ ﻣﻲ ﺗﻮﺍﻥ ﻳﻚ ﻣﺠﻤﻮﻋﻪ ﻭﺍﺑﺴﺘﮕﻲ ﺭﺍ ﺑﻪ ﻣﺠﻤﻮﻋﻪ ﺑﻬﻴﻨﻪ ﻣﻌﺎﺩﻝ ﺁﻥ ﺗﺒﺪﻳﻞ ﻛﺮﺩ‪:‬‬ ‫‪ -١‬ﺳﻤﺖ ﺭﺍﺳﺖ ﻫﺮ ﻭﺍﺑﺴﺘﮕﻲ ﻓﻘﻂ ﻳﻚ ﺻﻔﺖ ﺧﺎﺻﻪ ﺑﺎﺷﺪ‬ ‫‪ -٢‬ﻫﺮ ﺻﻔﺘﻲ ﻛﻪ ‪ F +‬ﺭ ﺍ ﺗﻐﻴﻴﺮ ﻧﻤﻲ ﺩﻫﺪ ﺍﺯ ﺳﻤﺖ ﭼﭗ ﺣﺬﻑ ﺷﻮﺩ‬ ‫‪ -٣‬ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ ﺗﻜﺮﺍﺭﻱ ﻭ ﺍﺿﺎﻓﻲ ﺣﺬﻑ ﺷﻮﺩ‪.‬‬ ‫ﺍﺳﺘﻨﺘﺎﺝ ﻣﻨﻄﻖ ﺑﻌﻀﻲ ﻭﺍﺑﺴﺘﮕﻴﻬﺎ ﺍﺯ ﻭﺍﺑﺴﺘﮕﻴﻬﺎﻱ ﺩﻳﮕﺮ ﺑﻪ ﻣﺎ ﺍﻣﻜﺎﻥ ﻣﻲ ﺩﻫﺪ ﺗﺎ ﺑﺎ ﺩﺍﺷﺘﻦ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ‬ ‫ﺭﺍﺑﻄﻪ ﻣﺠﻤﻮﻋﻪ ﻛﻤﻴﻨﻪ ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎ ﺭﺍ ﺑﺪﺳﺖ ﺁﻭﺭﺩ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﻣﺜﺎﻝ ﻗﺒﻞ ﻣﺠﻤﻮﻋﻪ ﻭﺍﺑﺴﺘﮕﻲ ﭘﻮﺷﺸﻲ ﺑﻬﻴﻨﻪ ﺭﺍ ﺑﺪﺳﺖ ﺁﻭﺭﻳﺪ‪.‬‬ ‫} )‪F + ={U → (X,Y) , X →Y , (X,Y) → (Z,V) , U → (Z,V‬‬

‫‪X , U→ Y‬‬

‫→ ‪U‬‬

‫⇒ )‪(X,Y‬‬

‫‪⇒ U→Z ,U→V‬‬ ‫)‪X→ (Z,V‬‬ ‫‪⇒ X→Y‬‬ ‫‪⇒ X→Z , X → V‬‬

‫→‬

‫‪U‬‬

‫♦‬

‫)‪U → (Z,V‬‬ ‫)‪(X,Y) → (Z,V‬‬

‫♦‬ ‫♦‬ ‫♦‬

‫}‪FOPT = { U → X , U→ Y, U → Z , U → V , X→Y, X→Z , X → V‬‬

‫♦‬

‫)‪X →(Z,V‬‬

‫‪-٦-٣-٦‬ﻧﻤﻮﺩﺍﺭ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ‬ ‫ﻣـﻲ ﺗـﻮﺍﻥ ﻭﺍﺑﺴـﺘﮕﻲ ﺗﺎﺑﻌـﻲ ﺭﺍ ﺑـﺎ ﺍﺳـﺘﻔﺎﺩﻩ ﺍﺯ ﻧﻤﻮﺩﺍﺭ ﻧﺸﺎﻥ ﺩﺍﺩ‪ .‬ﺩﺭ ﺍﻳﻦ ﻧﻤﻮﺩﺍﺭ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺩﺭ ﻣﺴﺘﻄﻴﻞ ﻗﺮﺍﺭ‬ ‫ﮔﻴﺮﻧﺪ ﻭ ﺧﻄﻲ ﺟﻬﺖ ﺩﺍﺭ ﺍﺯ ﺁﻧﻬﺎ ﺑﻪ ﻫﺮ ﻳﻚ ﺍﺯ ﺻﻔﺎﺕ ﻭﺍﺑﺴﺘﻪ ﺭﺳﻢ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﻣﺜﺎﻝ‪ :‬ﺟﺪﻭﻝ‬

‫‪ sp‬ﺭﺍ ﺩﺭ ﻧﻈﺮ ﻣﻲ ﮔﻴﺮﻳﻢ‬

‫) ‪sp ( s ≠, p ≠, Qty‬‬ ‫≠‪s‬‬

‫‪Qty‬‬ ‫≠‪p‬‬

‫ﻣﻲ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩٠ /‬‬

‫‪ -٤-٦‬ﻧﺮﻣﺎﻝ ﺳﺎﺯﻱ )‪(normalization‬‬ ‫‪ ١-٤-٦‬ﺭﺍﺑﻄﻪ ﻧﺮﻣﺎﻝ ﻳﻚ ‪INF‬‬

‫ﺭﺍﺑﻄﻪ ﺍﻱ ﺭﺍ ‪ INF‬ﮔﻮﻳﻨﺪ ﺍﮔﺮ ﻣﻘﺎﺩﻳﺮ ﺗﻤﺎﻡ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺍﺵ ﺍﺗﻤﻴﻚ ﺑﺎﺷﻨﺪ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺭﺍﺑﻄﻪ ﺯﻳﺮ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﻣﻲ ﮔﻴﺮﻳﻢ‪:‬‬ ‫)‪(S#,P#,QTY,CITY,STATUS‬‬

‫‪FIRST :‬‬

‫‪ FD‬ﻫﺎ ﺭﺍﺑﻄﻪ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ‪:‬‬ ‫‪(S#,P# ) → Qty , (S#,P# ) → CITY , (S#,P# ) → STATUS‬‬ ‫ﻫﺮ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ﺍﻱ ﺩﺭ ﻳﻚ ﺷﻬﺮ ﺳﺎﻛﻦ ﺍﺳﺖ ‪:‬‬ ‫‪(S#) → CITY‬‬

‫ﻫﺮ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ﺍﻱ ﻳﻚ ﻣﻘﺪﺍﺭ ﻭﺿﻌﻴﺖ ﺩﺍﺭﺩ‬

‫‪:‬‬

‫‪(S#) → STATUS‬‬

‫ﺗﻤﺎﻡ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ ﺳﺎﻛﻦ ﻳﻚ ﺷﻬﺮ ﻳﻚ ﻭﺿﻌﻴﺖ ﺩﺍﺭﺩ‪CITY → STATUS :‬‬

‫ﻧﻤﻮﺩﺍﺭ ‪ FD‬ﻧﻴﺰ ﺑﻔﺮﻡ ﻣﻘﺎﺑﻞ ﺍﺳﺖ ‪.‬‬ ‫‪First‬‬ ‫‪Status‬‬

‫‪city‬‬

‫‪Qty‬‬

‫≠‪p‬‬

‫‪CITY‬‬

‫≠‪s‬‬

‫≠‪s‬‬

‫‪QTY‬‬

‫‪STATUS‬‬

‫‪s1‬‬

‫‪١٠‬‬

‫‪c1‬‬

‫‪١٠٠‬‬

‫‪p1‬‬

‫‪١٠‬‬

‫‪c1‬‬

‫‪١٢٠‬‬

‫‪p2‬‬

‫‪s1‬‬

‫‪١٠‬‬

‫‪c1‬‬

‫‪٨٠‬‬

‫‪p3‬‬

‫‪s1‬‬

‫‪١٥‬‬

‫‪c2‬‬

‫‪٩٠‬‬

‫‪p1‬‬

‫‪s2‬‬

‫‪١٥‬‬

‫‪c2‬‬

‫‪١٠٠‬‬

‫‪p1‬‬

‫‪s3‬‬

‫‪١٠‬‬

‫‪c1‬‬

‫‪٦٠‬‬

‫‪p1‬‬

‫‪s4‬‬

‫≠‪p‬‬

‫♦ ﺁﻧﻮﻣﺎﻟﻴﻬﺎ‪:‬‬ ‫‪ -١‬ﺩﺭﺝ ﻛﻦ ﺍﻃﻼﻉ‬

‫〉‪〈 sv, c3,14‬‬

‫ﺍﻳﻦ ﺩﺭﺝ ﻧﺎﻣﻤﻜﻦ ﺍﺳﺖ ﺗﺎ ﻧﺪﺍﻧﻴﻢ ﭼﻪ ﻗﻄﻌﻪ ﺍﻱ ﺗﻬﻴﻪ ﻛﺮﺩﻩ ﺍﺳﺖ‪.‬‬ ‫‪ -٢‬ﺣﺬﻑ ﻛﻦ‬

‫〉‪〈 s3, p1,100‬‬

‫ﻣﻨﺠﺮ ﺑﻪ ﺣﺬﻑ ﺍﻃﻼﻉ ﻧﺎﺧﻮﺍﺳﺘﻪ 〉‪ 〈 s3, c 2,15‬ﻣﻲ ﺷﻮﺩ‬ ‫ﺭﺍﺑﻄﻪ ‪ FIRST‬ﺭﺍﺑﻄﻪ ﺧﻮﺵ ﺳﺎﺧﺘﺎﺭﻱ ﻧﻴﺴﺖ ‪ ،‬ﺍﻳﻦ ﺭﺍﺑﻄﻪ ﺑﺎﻳﺪ ﺑﺎ ﺍﻧﺘﺨﺎﺏ ﭘﺮﺗﻮﻫﺎﻱ ﻣﻨﺎﺳﺐ ﺑﻪ ﺩﻭ ﺭﺍﺑﻄﻪ ﺗﺠﺰﻳﻪ ﺷﻮﺩ‪:‬‬ ‫) ‪sec ond ( s ≠, status, city‬‬

‫ﻭ‬

‫) ‪sp ( s ≠, p ≠, Qty‬‬

‫ﻧﻜﺘﻪ ‪ :‬ﺭﺍﺑﻄﻪ ‪ FIRST‬ﺑﺎﻳﺪ ﺑﮕﻮﻧﻪ ﺍﻱ ﺗﺠﺰﻳﻪ ﺷﻮﺩ ﻛﻪ ﺩﺭ ﺭﺍﺑﻄﻪ ﻫﺎﻱ ﺣﺎﺻﻠﻪ ‪ FD‬ﻧﺎﻛﺎﻣﻞ ﻭﺟﻮﺩ ﻧﺪﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩١ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫‪ - ٢-٤-٦‬ﺭﺍﺑﻄﻪ ‪2NF‬‬

‫ﺭﺍﺑﻄﻪ ﺍﻱ ‪ 2NF‬ﺍﺳﺖ ﻛﻪ ‪:‬‬ ‫‪ INF -١‬ﺑﺎﺷﺪ‬ ‫‪ -٢‬ﻫﺮ ﺻﻔﺖ ﺧﺎﺻﻪ ﻏﻴﺮ ﻛﻠﻴﺪﺑﺎ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﻛﺎﻣﻞ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺗﻌﺮﻳﻒ ‪ 2NF‬ﻣﻲ ﺑﻴﻨﻴﻢ ﺭﺍﺑﻄﻪ ‪ 2NF ، FIRST‬ﻧﻴﺴﺖ‪ ،‬ﺭﺍﺑﻄﻪ ‪ SECOND‬ﻭ ‪ SP‬ﻫﺮ ﺩﻭ ‪ 2NF‬ﻣﻲ ﺑﺎﺷﻨﺪ‪.‬‬ ‫ﻧﻜـﺘﻪ ‪ FD -١‬ﻫـﺎﻱ ﺑـﻴﻦ ﻣﺠﻤﻮﻋﻪ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻳﻚ ﻣﺤﻴﻂ ﺑﻴﺎﻧﮕﺮ ﻗﻮﺍﻧﻴﻦ ﺳﻤﺎﻧﺘﻴﻚ ﺣﺎﻛﻢ ﺑﺮ ﺁﻥ ﻣﺤﻴﻂ ﻣﻲ ﺑﺎﺷﻨﺪ‪ .‬ﺑﻌﻨﻮﺍﻥ‬ ‫ﻣـﺜﺎﻝ ﻭﻗﺘـﻲ ﻣـﻲ ﮔﻮﺋـﻴﻢ ﺩﺭﺱ ≠ ‪ PR ≠→ CO‬ﺍﺳﺘﺎﺩ ﻳﻌﻨﻲ ﺍﻳﻦ ﻗﺎﻋﺪﻩ ﺑﺮ ﻣﺤﻴﻂ ﺣﺎﻛﻢ ﺍﺳﺖ ﻛﻪ ﻫﺮ ﺍﺳﺘﺎﺩ ﻓﻘﻂ ﻳﻚ ﺩﺭﺱ‬ ‫ﻣـﻲ ﺩﻫـﺪ‪ .‬ﺍﻳـﻦ ﻗﻮﺍﻧـﻴﻦ ﺳـﻤﺎﻧﺘﻴﻚ ﺑﺎﻳﺪ ﺑﻨﺤﻮﻱ ﺑﻪ ﺳﻴﺴﺘﻢ ﺩﺍﺩﻩ ﺷﻮﺩ‪ .‬ﺍﻳﻨﮕﻮﻧﻪ ﻗﻮﺍﻋﺪ ﻧﻮﻋﻲ ﻗﻮﺍﻋﺪ ﺟﺎﻣﻌﻴﺘﻲ ﺑﺮﮔﺮﻓﺘﻪ ﺍﺯ ﻣﺤﻴﻂ‬ ‫ﻋﻤﻠﻴﺎﺗﻲ ﻫﺴﺘﻨﺪ ﻛﻪ ﻣﻮﺳﻮﻡ ﺑﻪ ﻗﻮﺍﻧﻴﻦ ﺟﺎﻣﻌﻴﺖ ﻧﺎﺷﻲ ﺍﺯ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﻣﻲ ﺑﺎﺷﻨﺪ‪.‬‬ ‫ﻧﻜﺘﻪ ‪ -٢‬ﺑﺮﺍﻱ ﺗﺒﺪﻳﻞ ‪ INF‬ﺑﻪ ‪ 2NF‬ﺍﺯ ﻋﻤﻠﮕﺮ ﭘﺮﺗﻮ ﺑﻄﻮﺭ ﻣﻨﺎﺳﺐ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫•‬

‫‪SECOND‬‬

‫ﺁﻧﻮﻣﺎﻟﻴﻬﺎﻱ ﺭﺍﺑﻄﻪ‬

‫‪ -١‬ﺩﺭ ﺩﺭﺝ ‪ :‬ﺩﺭﺝ ﻛﻦ ﺍﻃﻼﻉ >‪ : ‪ <S5,15‬ﺭﺍ ﺣﺬﻑ ﻛﻦ ﺍﻳﻦ ﺣﺬﻑ ﻣﻨﺠﺮ ﺑﻪ‬ ‫ﺣﺬﻑ ﺍﻃﻼﻉ >‪
‫‪Status‬‬

‫‪ -٣‬ﺩﺭ ﺑﻪ ﻫﻨﮕﺎﻡ ﺳﺎﺯﻱ‪ :‬ﻭﺿﻌﻴﺖ ﺩﺍﺩﻩ ﺷﺪﻩ ﺑﻪ ﺷﻬﺮ ‪ c2‬ﺭﺍ ﻋﻮﺽ ﻛﻦ‬

‫‪١٠‬‬

‫ﺩﺭ ﺍﻳﻨﺠﺎ ﻋﻤﻞ ﺗﺎﭘﻠﻲ ﺑﻪ ﻋﻤﻞ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺗﺒﺪﻳﻞ ﻣﻴﺸﻮﺩ‪.‬‬

‫‪٢٠‬‬ ‫‪٢٠‬‬ ‫‪١٠‬‬ ‫‪١٥‬‬

‫‪city‬‬ ‫‪c1‬‬

‫≠‪s‬‬ ‫‪s1‬‬

‫‪c2‬‬

‫‪s2‬‬

‫‪c2‬‬

‫‪s3‬‬

‫‪c1‬‬ ‫‪c4‬‬

‫‪s4‬‬ ‫‪S5‬‬

‫ﺭﺍﺑﻄﻪ ‪ second‬ﻫﻢ ﺑﺎﻳﺪ ﺑﺎ ﻋﻤﻠﮕﺮ ﭘﺮﺗﻮ ﻣﻨﺎﺳﺐ ﺑﻪ ﺩﻭ ﺭﺍﺑﻄﻪ ﺗﺠﺰﻳﻪ ﺷﻮﺩ ‪.‬ﻓﺮﺽ ﻛﻨﻴﻢ ﺍﻳﻦ ﺭﺍﺑﻄﻪ ﺑﻪ ﺩﻭ ﺭﺍﺑﻄﻪ‬ ‫) ‪ sc( s ≠, city‬ﻭ ) ‪ cs(city, status‬ﺗﺠﺰﻳﻪ ﺷﻮﺩ‪.‬‬ ‫‪SC‬‬ ‫≠‪s‬‬ ‫‪City‬‬

‫‪CS‬‬ ‫‪status‬‬

‫‪city‬‬

‫≠‪s‬‬

‫‪city‬‬ ‫‪status‬‬

‫‪c1‬‬

‫‪s1‬‬

‫‪١٠‬‬

‫‪c1‬‬

‫‪c2‬‬

‫‪s2‬‬

‫‪٢٠‬‬

‫‪c2‬‬

‫‪c3‬‬

‫‪s3‬‬

‫‪١٥‬‬

‫‪c4‬‬

‫‪city‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩٢ /‬‬

‫ﻣﺸﺨﺺ ﺍﺳﺖ ﺑﺎ ﺗﺮﻛﻴﺐ ‪ SC‬ﻭ ‪ CS‬ﻫﺮ ﮔﺎﻩ ﻻﺯﻡ ﺑﺎﺷﺪ ﺑﻪ ﺭﺍﺑﻄﻪ ‪ SECOND‬ﻣﻲ ﺭﺳﻴﻢ‪.‬‬ ‫•‬

‫ﻋﻠﺖ ﺁﻧﻮﻣﺎﻟﻴﻬﺎﻱ ‪SECOND‬‬

‫ﺩﺭ ﺭﺍﺑﻄﻪ ‪ SECOND‬ﻧﻮﻋﻲ ﻭﺍﺑﺴﺘﮕﻲ ﺧﺎﺹ ﺑﻨﺎﻡ ﻭﺍﺑﺴﺘﮕﻲ ﺑﺎ ﻭﺍﺳﻄﻪ ) ﺍﺯ ﻃﺮﻳﻖ ﺗﻌﺪﻱ( ﻭﺟﻮﺩ ﺩﺍﺭﺩ‪.‬‬ ‫ﺗﻌﺮﻳﻒ ﻭﺍﺑﺴﺘﮕﻲ ﺑﺎ ﻭﺍﺳﻄﻪ‪:‬‬ ‫ﺩﺭ ﺭﺍﺑﻄﻪ )‪ R(A,B,C‬ﺍﮔﺮ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ‬ ‫ﻣﻲ ﮔﻮﺋﻴﻢ ‪ C‬ﺑﻪ ‪ A‬ﺍﺯ ﻃﺮﻳﻖ ‪ B‬ﻭﺍﺑﺴﺘﻪ ﺍﺳﺖ ‪:‬‬ ‫ﺩﺭ ﻣﺜﺎﻝ ﻗﺒﻞ ﺩﺍﺭﻳﻢ‪:‬‬

‫‪B →C , B → A,A → B‬‬ ‫→ ‪A → C) ⇒ (A → B , B‬‬

‫‪C‬‬

‫‪ S# → CITY‬ﻭ ‪ CITY → STATUS‬ﻣﻲ ﮔﻮﺋﻴﻢ ‪ STATUS‬ﺿﻤﻦ ﺍﻳﻨﻜﻪ ﺧﻮﺩ‬

‫ﻣﺴﺘﻘﻴﻤﹰﺎ ﺑﻲ ﻭﺍﺳﻄﻪ ﺑﺎ ‪ S#‬ﻭﺍﺑﺴﺘﮕﻲ ﺩﺍﺭﺩ ﺍﺯ ﻃﺮﻳﻖ ‪ CITY‬ﻧﻴﺰ ﺑﻪ ﺁﻥ ﻭﺍﺑﺴﺘﻪ ﺍﺳﺖ‪.‬‬ ‫‪ : ٣-٤-٦‬ﺭﺍﺑﻄﻪ ‪3NF‬‬

‫ﺭﺍﺑﻄﻪ ﺍﻱ ﺭﺍ ‪ 3NF‬ﮔﻮﻳﻨﺪ ﻫﺮ ﮔﺎﻩ‪:‬‬ ‫‪ 2NF -١‬ﺑﻮﺩﻩ‬ ‫‪ -٢‬ﻫﺮ ﺻﻔﺖ ﺧﺎﺻﻪ ﻏﻴﺮ ﻛﻠﻴﺪ ﺑﺎ ﻛﻠﻴﺪ ﺍﺻﻠﻲ ﻭﺍﺑﺴﺘﮕﻲ ﺑﻲ ﻭﺍﺳﻄﻪ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫≠‪S‬‬

‫ﻣﺜﺎﻝ ‪ :‬ﺭﺍﺑﻄﻪ ‪ SP‬ﻭ ‪ 3NF‬ﺍﺳﺖ‬

‫‪QTY‬‬ ‫≠‪P‬‬

‫‪ : ٤-٤-٦‬ﺭﺍﺑﻄﻪ ‪BCNF‬‬ ‫ﺍﻳﻦ ﺭﺍﺑﻄﻪ ﺗﻌﺮﻳﻔﻲ ﻣﺴﺘﻘﻞ ﺍﺯ ﺳﻄﻮﺡ ﻛﻼﺳﻴﻚ ﻛﺎﺩﻱ ﺩﺍﺭﺩ ‪:‬‬

‫ﺭﺍﺑﻄﻪﺍﻱ ‪ BCNF‬ﺍﺳﺖ ﻛﻪ ﺩﺭ ﺁﻥ ﻫﺮ ﺩﺗﺮﻣﻴﻨﺎﻥ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺑﺎﺷﺪ ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﺭﺍﺑﻄﻪ ‪ BCNF ، FIRST‬ﻧﻴﺴﺖ ﺯﻳﺮﺍ ﺩﺭ ﺭﺍﺑﻄﻪ ﺩﺍﺭﻳﻢ ‪ S# → City :‬ﻭ ‪ S#‬ﺩﺗﺮﻣﻴﻨﺎﻥ ﺍﺳﺖ ﺍﻣﺎ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﻧﻴﺴﺖ ‪.‬‬ ‫ﺩﺭ ﺳﻄﻮﺡ ﻛﻼﺳﻴﻚ ‪ Codd‬ﻣﻔﻬﻮﻡ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﻣﻄﺮﺡ ﻧﻴﺴﺖ ﻭﻟﻴﻜﻦ ﺩﺭ ‪ BCNF‬ﻣﻄﺮﺡ ﺍﺳﺖ ﻭ ﭼﻮﻥ ﻳﻚ ﺭﺍﺑﻄﻪ ﻣﻤﻜﻦ‬ ‫ﺍﺳﺖ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ‪ BCNF‬ﺑﺎﻳﺪ ﺑﻴﺸﺘﺮ ﺑﺮﺭﺳﻲ ﺷﻮﺩ ‪.‬‬ ‫ﻫﺮ ﺭﺍﺑﻄﻪ ‪ 3NF BCNF‬ﺍﺳﺖ ﻭﻟﻲ ﻫﺮ ‪ 3NF‬ﺍﻱ ‪ BCNF‬ﻧﻴﺴﺖ ‪.‬ﺑﻠﻜﻪ ﺑﺎﻳﺪ ﺑﺮﺭﺳﻲ ﺷﻮﺩ‪ .‬ﻟﺬﺍ ﺩﻭ ﺣﺎﻟﺖ ﺭﺍ ﺩﺭ ﻧﻈﺮ‬ ‫ﻣﻲﮔﻴﺮﻳﻢ ‪:‬‬ ‫ﺍﻟﻒ ‪ :‬ﺭﺍﺑﻄﻪﻫﺎﻳﻲ ﺑﺎ ﻳﻚ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ‪.‬‬ ‫ﺩﺭ ﺍﻳﻦ ﺣﺎﻟﺖ ﻣﻲﺗﻮﺍﻥ ﮔﻔﺖ ‪ :‬ﺍﮔﺮ ﺭﺍﺑﻄﻪ ‪ 3NF‬ﺑﺎﺷﺪ ﻗﻄﻌﹰﺎ ‪ BCNF‬ﻫﻢ ﻫﺴﺖ ‪.‬‬ ‫ﻣﺜﺎﻝ‪ :‬ﺭﺍﺑﻄﻪ ‪ S‬ﻭ ‪SP‬‬

‫ﺏ ‪ :‬ﺭﺍﺑﻄﻪﻫﺎﻳﻲ ﺑﺎ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ‪:‬‬ ‫ﺩﺭ ﺍﻳﻦ ﺣﺎﻟﺖ ﻧﻴﺰ ﻣﻲﺗﻮﺍﻥ ﺩﻭ ﺣﺎﻟﺖ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺖ‬ ‫‪ -١‬ﻋﺪﻡ ﻭﺟﻮﺩ ﻫﻤﭙﻮﺷﺎﻧﻲ ﺩﺭ ﻛﻠﻴﺪﻫﺎﻱ ﻛﺎﻧﺪﻳﺪ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩٣ /‬‬

‫‪ -٢‬ﻭﺟﻮﺩ ﻫﻤﭙﻮﺷﺎﻧﻲ ﺩﺭ ﻛﻠﻴﺪﻫﺎﻱ ﻛﺎﻧﺪﻳﺪ‬ ‫ﻭ ﻣﻨﻈﻮﺭ ﺍﺯ ﻫﻤﭙﻮﺷﺎﻧﻲ ‪ :‬ﺍﮔﺮ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ )‪ R : (x,y) ,(y,z‬ﻭﺟﻮﺩ ‪ y‬ﻋﻨﺼﺮ ﻣﺸﺘﺮﻙ ﺭﺍ ﻫﻤﭙﻮﺷﺎﻧﻲ ﮔﻮﻳﻨﺪ ‪.‬‬ ‫ﻣـﺜﺎﻝ ‪ ١‬ﺭﺍﺑﻄـﻪ ‪ S‬ﺭﺍ ﺩﺭ ﻧﻈﺮ ﻣﻲﮔﻴﺮﻳﻢ ‪ .‬ﻓﺮﺽ ﻛﻨﻴﻢ ﻋﻼﻭﻩ ﺑﺮ ‪ Sname ، S#‬ﻫﻢ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺑﺎﺷﺪ ) ﺍﺳﺎﻣﻲ ﺗﻜﺮﺍﺭﻱ ﻧﺪﺍﺷﺘﻪ‬ ‫ﺑﺎﺷﻴﻢ (‬ ‫ﻃﺒﻖ ﺗﻌﺮﻳﻒ ﻛﻠﻴﺪﻫﺎﻱ ﻛﺎﻧﺪﻳﺪ ﻧﻤﻮﺩﺍﺭ ‪ FD‬ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ ‪:‬‬ ‫‪S#‬‬

‫‪Status‬‬ ‫‪City‬‬

‫‪Sname‬‬

‫ﺍﻳﻦ ﺭﺍﺑﻄﻪ ‪ BCNF‬ﺍﺳﺖ ﺯﻳﺮﺍ ﻫﺮ ﺩﻭ ﺗﺮﻣﻴﻨﺎﻥ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﻭ ‪ 3NF‬ﻫﻢ ﻣﻲﺑﺎﺷﺪ ‪.‬‬ ‫ﺍﻳﻦ ﺭﺍﺑﻄﻪ ‪ 1NF‬ﺍﺳﺖ ﺯﻳﺮﺍ ﻋﻨﺎﺻﺮﺵ ﺍﺗﻤﻴﻚ ﻫﺴﺘﻨﺪ ‪.‬‬ ‫ﺍﻳﻦ ﺭﺍﺑﻄﻪ ‪ 2NF‬ﺍﺳﺖ ﺯﻳﺮﺍ ‪ 1NF‬ﺍﺳﺖ ﻭ ﻭﺍﺑﺴﺘﮕﻲ ﻧﺎﻛﺎﻣﻞ ﻧﺪﺍﺭﻳﻢ ‪.‬‬ ‫ﺍﻳﻦ ﺭﺍﺑﻄﻪ ‪ 3NF‬ﺍﺳﺖ ﺯﻳﺮﺍ ﺗﻌﺪﻱ ﻧﺪﺍﺭﻳﻢ ‪.‬‬ ‫♦ ﺩﺭ ﺍﻳﻦ ﺣﺎﻟﺖ)ﻧﺒﻮﺭ ﺻﻔﺖ ﻣﺸﺘﺮﻙ( ﺍﮔﺮ ‪ 3NF‬ﺍﺳﺖ‪ BCNF‬ﻧﻴﺰ ﻣﻲ ﺑﺎﺷﺪ‪.‬‬ ‫ﻣـﺜﺎﻝ ‪ ٢‬ﺭﺍﺑﻄـﻪ ‪ SPS‬ﺭﺍ ﺩﺭ ﻧﻈـﺮ ﺑﮕﻴﺮﻳﻢ ‪ SPS ( S# , P#, SNAME ,QTY ) :‬ﺩﺭ ﺍﻳﻨﺠﺎ ﺩﻭ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺩﺍﺭﻳﻢ ﻛﻪ ﺑﺎ ﻫﻢ‬ ‫ﻫﻤﭙﻮﺷﺎﻧﻲ ﺩﺍﺭﻧﺪ ‪ .‬ﻧﻤﻮﺩﺍﺭ ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﺑﻔﺮﻡ ﺯﻳﺮ ﺍﺳﺖ ‪:‬‬

‫‪QTY‬‬

‫ﺍﻳﻦ ﺭﺍﺑﻄﻪ ‪ BCNF‬ﻧﻴﺴﺖ ﺯﻳﺮﺍ ‪ S#‬ﺩﺗﺮﻣﻴﻨﺎﻥ‬

‫‪Sname‬‬

‫‪S#‬‬ ‫‪P#‬‬

‫ﺍﺳﺖ ﻭﻟﻲ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﻧﻴﺴﺖ ‪ .‬ﻣﻲﺧﻮﺍﻫﻴﻢ‬ ‫ﺑﺮﺭﺳﻲ ﻛﻨﻴﻢ ﺍﻳﻦ ﺭﺍﺑﻄﻪ ﭼﻨﺪ ‪ NF‬ﺍﺳﺖ ‪.‬‬ ‫♦ ﺍﻳﻦ ﺭﺍﺑﻄﻪ ‪ 1NF‬ﺍﺳﺖ ﺯﻳﺮﺍ ﺻﻔﺎﺕ ﺧﺎﺻﻪﺍﺵ ﺍﺗﻤﻴﻚ ﻫﺴﺘﻨﺪ ‪.‬‬ ‫♦ ‪ 2NF‬ﻧﻴﺰ ﻣﻲﺑﺎﺷﺪ ﺯﻳﺮﺍ ﻭﺍﺑﺴﺘﮕﻲ ﻧﺎﻛﺎﻣﻞ ﻧﺪﺍﺭﻳﻢ ‪.‬‬ ‫ﺍﻟﺒـﺘﻪ ﻇﺎﻫـﺮﹰﺍ ﺑـﻪ ﻧﻈـﺮ ﻣﻲﺭﺳﺪ ﻭﺍﺑﺴﺘﮕﻲ ﻧﺎﻛﺎﻣﻞ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ﻭﻟﻴﻜﻦ ﺍﻳﻨﻄﻮﺭ ﻧﻴﺴﺖ ﺯﻳﺮﺍ ‪ Sname‬ﺧﻮﺩ ﺟﺰﺋﻲ ﺍﺯ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ‬ ‫ﻼ ﻋﻀﻮﻳﺖ ﺻﻔﺖ ﺧﺎﺻﻪ ﺩﺭ ﻛﻠﻴﺪ‬ ‫ﺍﺳـﺖ ﺩﺭ ﺣﺎﻟـﻴﻜﻪ ﺩﺭ ﺗﻌـﺮﻳﻒ ‪ 2NF‬ﻛـﺎﺩﻱ ﺁﻣﺪﻩ ﺍﺳﺖ ﻫﺮ ﺻﻔﺖ ﺧﺎﺻﻪ ﻏﻴﺮ ﻛﻠﻴﺪ ﻭ ﺍﺻ ﹰ‬ ‫ﻛﺎﻧﺪﻳﺪ ﻣﻄﺮﺡ ﻧﻴﺴﺖ ‪ .‬ﻟﺬﺍ ‪ 2NF‬ﻣﻲﺑﺎﺷﺪ ‪.‬‬ ‫♦ ﺍﻳﻦ ﺭﺍﺑﻄﻪ ‪ 3NF‬ﻧﻴﺰ ﻣﻲﺑﺎﺷﺪ ﺯﻳﺮﺍ ﺗﻌﺪﻱ ﻭﺟﻮﺩ ﻧﺪﺍﺭﺩ ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩٤ /‬‬

‫ﻣﻲﺑﻴﻨﻴﻢ ‪ 3NF ، SPS‬ﺍﺳﺖ ﻭﻟﻲ ‪ BCNF‬ﻧﻴﺴﺖ ‪ .‬ﻧﻜﺘﻪ ﺟﺎﻟﺒﺘﺮ ﺁﻧﻜﻪ ﺭﺍﺑﻄﻪ ‪ sps‬ﺍﺧﺘﻼﻁ ﺍﻃﻼﻋﺎﺗﻲ ﺩﺍﺭﺩ ﺑﺎ ﺍﻳﻦ ﻫﻤﻪ ﺑﺎ‬ ‫ﻻ ﻭﺟﻮﺩ ﭘﺪﻳﺪﻩ ﺍﺧﺘﻼﻁ ﺍﻃﻼﻋﺎﺗﻲ ﺭﺍﺑﻄﻪ ﺭﺍ ﺩﺭ ﺣﺪ ‪ 1NF‬ﻳﺎ ﺣﺪﺍﻛﺜﺮ‬ ‫ﺩﺍﺷﺘﻦ ﺩﻭ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ‪ 3NF‬ﺍﺳﺖ ﺩﺭ ﺣﺎﻟﻴﻜﻪ ﻣﻌﻤﻮ ﹰ‬ ‫‪ 2NF‬ﻧﮕﻪ ﻣﻲﺩﺍﺭﺩ ‪.‬‬ ‫ﻧﺘﻴﺠﻪ ‪ :‬ﺻﺮﻑ ﮔﻔﺘﻦ ﺭﺍﺑﻄﻪﺍﻱ ﺍﺧﺘﻼﻁ ﺍﻃﻼﻋﺎﺗﻲ ﺩﺍﺭﺩ ﻟﺰﻭﻣﹸﺎ ﻣﻌﻨﺎﻳﺶ ﺍﻳﻦ ﻧﻴﺴﺖ ﻛﻪ ﺳﻄﺢ ﻧﺮﻣﺎﻟﻴﺘﻲ ﺁﻥ ﭘﺎﻳﻴﻦ ﺍﺳﺖ ‪.‬‬ ‫ﺩﺭ ﻋﻤـﻞ ﺑـﺮﺍﻱ ﻃﺮﺍﺣـﻲ ﺭﺍﺑﻄـﻪﻫـﺎ ﺗـﺎ ﺳﻄﺢ ‪ BCNF‬ﻧﺮﻣﺎﻝ ﻣﻲ ﺷﻮﻧﺪ ‪ .‬ﺳﻄﻮﺡ ﺑﺎﻻﺗﺮ ﺑﻴﺸﺘﺮ ﺟﻨﺒﻪ ﺗﺌﻮﺭﻳﻚ ﻭ ﭘﮋﻭﻫﺸﻲ ﺩﺍﺭﺩ ﻭ‬ ‫ﻼ ‪ 5NF‬ﻭ ‪ ٤NF‬ﻫﺴﺘﻨﺪ ﺑﻌﺒﺎﺭﺕ ﺩﻳﮕﺮ ﺭﺍﺑﻄﻪﻫﺎﻳﻲ‬ ‫ﻣﻌﻨﺎﻳﺶ ﺍﻳﻦ ﺍﺳﺖ ﻛﻪ ﺗﻘﺮﻳﺒﹰﺎ ﺗﻤﺎﻡ ﺭﺍﺑﻄﻪﻫﺎﻳﻲ ﻛﻪ ‪ BCNF‬ﻫﺴﺘﻨﺪ ﻋﻤ ﹰ‬ ‫ﻛﻪ‪ BCNF‬ﺑﺎﺷﺪ ﺍﻣﺎ ‪ 4NF‬ﻭﻳﺎ ‪ 5NF‬ﻧﺒﺎﺷﻨﺪ ﺑﺴﻴﺎﺭ ﻛﻢﺍﻧﺪ ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ : ٣‬ﺭﺍﺑﻄﻪﺍﻱ ﻛﻪ ‪ 3NF‬ﻫﺴﺖ ﺍﻣﺎ ‪ BCNF‬ﻧﻴﺴﺖ ‪.‬‬ ‫ﻓﺮﺽ ﻛﻨﻴﺪ ﺩﺭ ﻣﺤﻴﻂ ﺁﻣﻮﺯﺷﻲ ﻗﻮﺍﻋﺪ ﺯﻳﺮ ﻣﻮﺟﻮﺩﻧﺪ ‪:‬‬ ‫‪ . ١‬ﻳﻚ ﺩﺍﻧﺸﺠﻮ ﻳﻚ ﺩﺭﺱ ﺭﺍ ﻓﻘﻂ ﺑﺎ ﻳﻚ ﺍﺳﺘﺎﺩ ﺍﺧﺬ ﻣﻲﻛﻨﺪ ‪.‬‬ ‫‪ . ٢‬ﻳﻚ ﺍﺳﺘﺎﺩ ﻓﻘﻂ ﻳﻚ ﺩﺭﺱ ﺗﺪﺭﻳﺲ ﻣﻲﻛﻨﺪ ‪.‬‬ ‫‪ . ٣‬ﺩﺭﺱ ﻣﻤﻜﻦ ﺍﺳﺖ ﺗﻮﺳﻂ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﺍﺳﺘﺎﺩ ﺗﺪﺭﻳﺲ ﺷﻮﺩ ‪.‬‬ ‫ﺩﺭ ﺍﻳﻦ ﺭﺍﺑﻄﻪ ﺩﻭ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺩﺍﺭﻳﻢ ‪:‬‬ ‫‪SCP‬‬

‫‪ CO#‬ﻭ ‪ ST#‬ﻭ‬ ‫‪ PR#‬ﻭ ‪ST#‬‬

‫ﻭﻛﻠﻴﺪﻫﺎﻱ ﻛﺎﻧﺪﻳﺪ ﺑﺎ ﻫﻢ ﻫﻤﭙﻮﺷﺎﻧﻲ ﺩﺍﺭﻧﺪ ‪.‬‬ ‫ﺍﻳﻦ ﺭﺍﺑﻄﻪ ‪ BCNF‬ﻧﻴﺴﺖ ﺯﻳﺮﺍ ‪ PR#‬ﺩﺗﺮﻣﻴﻨﺎﻥ ﺍﺳﺖ ﻭﻟﻲ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﻧﻴﺴﺖ ‪.‬‬

‫‪CO# PR#‬‬ ‫‪P1‬‬ ‫‪P1‬‬ ‫‪P2‬‬ ‫‪P3‬‬ ‫‪P2‬‬

‫‪C1‬‬ ‫‪C1‬‬ ‫‪C2‬‬ ‫‪C2‬‬ ‫‪C2‬‬

‫‪ST#‬‬ ‫‪ST1‬‬ ‫‪ST2‬‬ ‫‪ST1‬‬ ‫‪ST2‬‬ ‫‪ST3‬‬

‫ﺍﻣﺎ ‪ 3NF‬ﻫﺴﺖ ‪.‬‬ ‫‪PR# → CO#‬‬ ‫‪(ST# , CO#) → PR#‬‬ ‫‪ - ٥-٤-٦‬ﺭﺍﺑﻄﻪ ‪4NF‬‬

‫♦‬

‫ﻭﺍﺑﺴـﺘﮕﻲ ﭼـﻨﺪ ﻣﻘـﺪﺍﺭﻱ ‪MVD‬‬

‫)‪(multivalued dependency‬‬

‫ﻭﺍﺑﺴﺘﮕﻲ ﭼﻨﺪﻣﻘﺪﺍﺭﻱ ﻧﻮﻋﻲ ﻭﺍﺑﺴﺘﮕﻲ ﺑﻴﻦ ﺩﻭ ﻣﺠﻤﻮﻋﻪ ﻣﺴﺘﻘﻞ ﺍﺯ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﺍﺳﺖ ‪ .‬ﻭﺍﺑﺴﺘﮕﻲ ﭼﻨﺪﻣﻘﺪﺍﺭﻱ‬ ‫) ‪ (A1,A2,...An ) →→ (B1,B2,...,Bm‬ﺩﺭ ﺭﺍﺑﻄﻪ ‪ R‬ﺑﺮﻗﺮﺍﺭ ﺍﺳﺖ ﺍﮔﺮ ﺑﺮﺍﻱ ﺩﻭ ﺗﺎﭘﻞ ‪ t‬ﻭ ‪ u‬ﺩﺭ ‪ R‬ﻛﻪ ﺩﺭ ﺗﻤﺎﻡ ﻣﻘﺎﺩﻳﺮ ‪A‬‬

‫ﻣﺸﺘﺮﻛﻨﺪ ﺗﺎﭘﻞ ﺩﻳﮕﺮ ‪ V‬ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ﻛﻪ ‪:‬‬ ‫‪ .١‬ﺩﺭ ﻣﻘﺎﺩﻳﺮ ‪ A‬ﺑﺎ ‪ t‬ﻭ ‪ u‬ﻣﺸﺘﺮﻙ ﺑﺎﺷﺪ ‪.‬‬ ‫‪ .٢‬ﺩﺭ ﻣﻘﺎﺩﻳﺮ ‪ B‬ﺑﺎ ‪ t‬ﻣﺸﺘﺮﻙ ﺑﺎﺷﺪ ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩٥ /‬‬

‫‪ .٣‬ﺩﺭ ﺗﻤﺎﻡ ﺳﺘﻮﻧﻬﺎﻱ ﺩﻳﮕﺮ ‪ R‬ﺑﺎ ‪ u‬ﻣﺸﺘﺮﻙ ﺑﺎﺷﺪ ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ ١‬ﺟﺪﻭﻝ ﺗﺪﺭﻳﺲ ﺍﺳﺎﺗﻴﺪ ﺭﺍ ﺷﺎﻣﻞ ﻛﺪ ﺍﺳﺘﺎﺩ ‪ ،‬ﻛﺪ ﺩﺍﻧﺸﻜﺪﻩ ‪ ،‬ﺷﻬﺮ ﺩﺍﻧﺸﻜﺪﻩ ‪ ،‬ﻛﺪ ﺩﺭﺱ ﻭ ﻛﺘﺎﺏ ﺩﺭﺱ ﺩﺭ ﻧﻈﺮ‬ ‫ﻣـﻲ ﮔﻴـﺮﻳﻢ ‪ .‬ﻓـﺮﺽ ﻛﻨـﻴﻢ ﺩﺍﻧﺸﻜﺪﻩﻫﺎﻳﻲ ﻛﻪ ﺍﺳﺘﺎﺩ ﺩﺭ ﺁﻧﻬﺎ ﺗﺪﺭﻳﺲ ﻣﻲﻛﻨﺪ ﻭ ﺩﺭﻭﺳﻲ ﻛﻪ ﺩﺭﺱ ﻣﻲﺩﻫﺪ ﺍﺯ ﻫﻢ ﻣﺴﺘﻘﻞ‬ ‫ﺑﺎﺷـﻨﺪ ﻳﻌﻨـﻲ ﻭﺍﺑﺴـﺘﮕﻲ ﺗﺎﺑﻌﻲ ﻧﺪﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ ‪ .‬ﺍﮔﺮ ﺍﺳﺘﺎﺩ ﺩﺭ ﭼﻨﺪ ﺩﺍﻧﺸﻜﺪﻩ ﺩﺭﺱ ﺑﺪﻫﺪ ﻭ ﺩﺭﻭﺱ ﻣﺨﺘﻠﻒ ﺭﺍ ﻧﻴﺰ ﺗﺪﺭﻳﺲ‬ ‫ﻛﻨﺪ ﺍﻓﺰﻭﻧﮕﻲ ﺩﺍﺭﻳﻢ ‪ .‬ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺟﺪﻭﻝ ﻣﻘﺎﺑﻞ ﺩﺍﺭﻳﻢ ‪:‬‬ ‫ﺩﺍﻧﺸـﻜﺪﻩ ﻫـﺎﻱ ﺍﺳـﺘﺎﺩ )‪ (100‬ﻭ ﻧﻴـﺰ ﺩﺭﻭﺳـﻲ ﻛـﻪ ﺗـﺪﺭﻳﺲ ﻣـﻲﻛـﻨﺪ ﺗﻜﺮﺍﺭ ﺷﺪﻩ ﺍﺳﺖ ) ﺍﻓﺰﻭﻧﮕﻲ ( ﺍﻳﻦ ﺩﺭ ﺣﺎﻟﻲ ﺍﺳﺖ ﻛﻪ‬ ‫ﺟﺪﻭﻝ ﻓﻮﻕ ﺗﺎ ﺳﻄﺢ ‪ BCNF‬ﻧﺮﻣﺎﻝﺳﺎﺯﻱ ﺷﺪﻩ ﺍﺳﺖ ‪.‬‬ ‫‪Book‬‬

‫‪Co#‬‬

‫‪City‬‬

‫‪College‬‬

‫‪PR#‬‬

‫‪B1‬‬

‫‪C1‬‬

‫ﺗﻬﺮﺍﻥ‬

‫‪01‬‬

‫‪100‬‬

‫‪B1‬‬

‫‪C1‬‬

‫ﻗﺰﻭﻳﻦ‬

‫‪02‬‬

‫‪100‬‬

‫‪B2‬‬

‫‪C2‬‬

‫ﺗﻬﺮﺍﻥ‬

‫‪01‬‬

‫‪100‬‬

‫‪B2‬‬

‫‪C2‬‬

‫ﻗﺰﻭﻳﻦ‬

‫‪02‬‬

‫‪100‬‬

‫‪B3‬‬

‫‪C3‬‬

‫ﺗﻬﺮﺍﻥ‬

‫‪02‬‬

‫‪100‬‬

‫‪B3‬‬

‫‪C3‬‬

‫ﻗﺰﻭﻳﻦ‬

‫‪02‬‬

‫ﻣﺜﺎﻝ ‪ : ٢‬ﺭﺍﺑﻄﻪ ‪ CTX‬ﺣﺎﻭﻱ ﺍﻃﻼﻋﺎﺕ ﺩﺭﺱ ‪ ،‬ﻣﺪﺭﺱ ﻭ ﻛﺘﺎﺏ ﺩﺭ ﻧﻈﺮ ﻣﻲﮔﻴﺮﻳﻢ ‪ .‬ﻳﻚ ﺩﺭﺱ ﻣﻲﺗﻮﺍﻧﺪ ﺗﻮﺳﻂ ﻫﺮ ﻳﻚ‬ ‫ﺍﺯ ﻣﺪﺭﺳﻴﻦ ﻣﺸﺨﺺ ﺷﺪﻩ ﻭ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺗﻤﺎﻡ ﻛﺘﺎﺑﻬﺎﻱ ﻣﺸﺨﺺ ﺷﺪﻩ ﺗﺪﺭﻳﺲ ﺷﻮﺩ ‪ .‬ﻣﺜ ﹰ‬ ‫ﻼ ﺩﺭﺱ ‪ C1‬ﻣﻲﺗﻮﺍﻧﺪ ﺗﻮﺳﻂ ‪ t1‬ﻭ‬ ‫‪ t2‬ﺗﺪﺭﻳﺲ ﺷﻮﺩ ﻫﻢ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﻛﺘﺎﺏ ‪ x1‬ﻭ ﻫﻢ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﻛﺘﺎﺏ ‪. x2‬‬ ‫ﺩﺭ ﻭﺍﻗﻊ ﻣﻲﺑﻴﻨﻴﻢ ﺑﻪ ﻳﻚ ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﺠﻤﻮﻋﻪﺍﻱ ﺍﺯ ﻣﻘﺎﺩﻳﺮ ﻣﺘﻨﺎﻇﺮ ﺍﺳﺖ ‪.‬‬ ‫‪ C →→ T‬ﻭ ‪C→→ X‬‬

‫‪X‬‬

‫‪T‬‬

‫‪C‬‬

‫ﻣﻲﺗﻮﺍﻥ ﻭﺍﺑﺴﺘﮕﻲ ﭼﻨﺪ ﻣﻘﺪﺍﺭﻱ ﺭﺍ ﺑﻔﺮﻡ ﺯﻳﺮ ﺗﻌﺮﻳﻒ ﻧﻤﻮﺩ ‪:‬‬

‫‪x1‬‬ ‫‪x2‬‬

‫‪t1‬‬ ‫‪t2‬‬

‫‪c1‬‬ ‫‪c1‬‬

‫ﺭﺍﺑﻄﻪ ‪ R‬ﺑﺎ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ‪ A‬ﻭ ‪ B‬ﻭ ‪ C‬ﺭﺍ ﺩﺭ ﻧﻈﺮ ﺑﮕﻴﺮﻳﻢ ‪.‬‬ ‫ﻣﻲﮔﻮﻳﻴﻢ ‪ B‬ﺑﺎ ‪ A‬ﻭﺍﺑﺴﺘﮕﻲ ﭼﻨﺪﻣﻘﺪﺍﺭﻱ ﺩﺍﺭﺩ ﻭ ﭼﻨﻴﻦ ﻧﻤﺎﻳﺶ ﻣﻲﺩﻫﻴﻢ‬

‫‪c2‬‬

‫‪t1‬‬ ‫‪x1‬‬ ‫‪ A →→ B‬ﺍﮔـﺮ ﻭ ﻓﻘﻂ ﺍﮔﺮ ﻣﺠﻤﻮﻋﻪ ﻣﻘﺎﺩﻳﺮ ‪ B‬ﻣﺘﻨﺎﻇﺮ ﻣﻘﺎﺩﻳﺮ ‪ A‬ﻭ ‪ C‬ﺗﻨﻬﺎ ﺑﻪ ‪ A‬ﺑﺴﺘﮕﻲ ‪x3‬‬ ‫ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ ﻭ ﺑﻪ‪t1‬ﻣﻘﺪﺍﺭ ‪ C‬ﺑﺴﺘﮕﻲ‬ ‫‪t‬‬ ‫‪x‬‬

‫ﻧﺪﺍﺷﺘﻪ ﺑﺎﺷﺪ ‪.‬‬

‫ﻓﺎﮔـﻴﻦ ﻧﺸـﺎﻥ ﺩﺍﺩ ﻛﻪ ﺩﺭ ﺭﺍﺑﻄﻪ )‪ R(A,B,C‬ﻭﺍﺑﺴﺘﮕﻲ ﭼﻨﺪﻣﻘﺪﺍﺭﻱ ‪ A →→ B‬ﻭﺟﻮﺩ ﺩﺍﺭﺩ ﺍﮔﺮ ﻭ ﻓﻘﻂ ﺍﮔﺮ ﻭﺍﺑﺴﺘﮕﻲ‬ ‫ﭼـﻨﺪﻣﻘﺪﺍﺭﻱ ‪ A →→ C‬ﻧﻴـﺰ ﺑﺮﻗـﺮﺍﺭ ﺑﺎﺷـﺪ ‪ .‬ﺑـﻪ ﺑـﻴﺎﻥ ﺩﻳﮕـﺮ ﺩﺭ ﻳـﻚ ﺭﺍﺑﻄـﻪ ﺑﺎ ﺳﻪ ﺻﻔﺖ ﺧﺎﺻﻪ ‪ ،‬ﻫﻤﻴﺸﻪ ﻭﺍﺑﺴﺘﮕﻲ ﭼﻨﺪ‬ ‫ﻣﻘﺪﺍﺭﻱ ﺑﺼﻮﺭﺕ ﺟﻔﺖ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩٦ /‬‬

‫♦ ﺗﻌﺮﻳﻒ ‪ :‬ﺭﺍﺑﻄـﻪﺍﻱ ﺭﺍ ‪ 4NF‬ﮔﻮﻳﻨﺪ ﺍﮔﺮ ﻭ ﻓﻘﻂ ﺍﮔﺮ ﻳﻚ ﻭﺍﺑﺴﺘﮕﻲ ﭼﻨﺪﻣﻘﺪﺍﺭﻱ ﻣﺜﻞ ‪ A →→ B‬ﺩﺭ ‪ R‬ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ‬ ‫ﺑﺎﺷـﺪ ﺗﻤـﺎﻡ ﺻـﻔﺎﺕ ﺧﺎﺻـﻪ ‪ R‬ﺑﺎ ‪ A‬ﻭﺍﺑﺴﺘﮕﻲ ﺗﺎﺑﻌﻲ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ ‪ .‬ﺑﻪ ﺑﻴﺎﻥ ﺩﻳﮕﺮ ﻫﻤﻪ ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ ﻣﻮﺟﻮﺩ ﺩﺭ ‪ R‬ﺑﺼﻮﺭﺕ‬ ‫‪ K → X‬ﺑﺎﺷـﻨﺪ ‪ ) .‬ﻳﻌﻨـﻲ ﻳـﻚ ﻭﺍﺑﺴـﺘﮕﻲ ﺗﺎﺑﻌـﻲ ﺑـﻴﻦ ﺻـﻔﺎﺕ ﺧﺎﺻـﻪ ‪ X‬ﻭ ﻛﻠـﻴﺪ ﻛﺎﻧﺪﻳﺪ ‪ . ( K‬ﺑﺮ ﺍﺳﺎﺱ ﺍﻳﻦ ﺗﻌﺮﻳﻒ‬ ‫ﻣـﻲ ﺗـﻮﺍﻥ ﻧﺘﻴﺠﻪ ﮔﺮﻓﺖ ‪ :‬ﺭﺍﺑﻄﻪ ‪ R‬ﺑﺎ ﺳﻪ ﺻﻔﺖ ﺧﺎﺻﻪ ﺩﺭ ﭼﻬﺎﺭﻣﻴﻦ ﺻﻮﺭﺕ ﻧﺮﻣﺎﻝ ﺍﺳﺖ ﺍﮔﺮ ‪ BCNF‬ﺑﺎﺷﺪ ﻭ‬ ‫ﺗﻤﺎﻡ ‪ MVD‬ﻫﺎﻱ ﺁﻥ ‪ FD‬ﺑﺎﺷﻨﺪ ‪.‬‬ ‫ﻣﻲﺑﻴﻨﻴﻢ ﺭﺍﺑﻄﻪ ‪ 4NF ، CTX‬ﻧﻴﺴﺖ ﺯﻳﺮﺍ ﻳﻚ ‪ MVD‬ﺩﺍﺭﺩ ﻛﻪ ‪ FD‬ﻧﻴﺴﺖ )‪. ( C →→X‬‬ ‫ﺍﮔﺮ ‪ CTX‬ﺭﺍ ﺑﻪ ﺩﻭ ﺭﺍﺑﻄﻪ ‪ CT‬ﻭ ‪ CX‬ﺗﺠﺰﻳﻪ ﻛﻨﻴﻢ ‪ CT‬ﻭ ‪ CX‬ﺭﺍﺑﻄﻪ ‪ 4NF‬ﻫﺴﺘﻨﺪ ‪.‬‬ ‫‪ -٦-٤-٦‬ﺭﺍﺑﻄﻪ ‪5NF‬‬

‫•‬

‫ﺗﻌﺮﻳﻒ ﻭﺍﺑﺴﺘﮕﻲ ﭘﻴﻮﻧﺪﻱ ‪Join Dependency:‬‬

‫ﺍﮔﺮ ‪ R‬ﻳﻚ ﺭﺍﺑﻄﻪ ﻭ ﺳﺘﻮﻧﻬﺎﻱ ﻫﺮﻳﻚ ﺍﺯ ﺭﺍﺑﻄﻪ ﻫﺎﻱ ‪ Rn,…R2,R1‬ﺯﻳﺮﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﺳﺘﻮﻧﻬﺎﻱ ‪R‬ﺑﺎﺷﻨﺪ ‪،‬ﺁﻧﮕﺎﻩ‪ R‬ﺩﺍﺭﺍﻱ‬ ‫ﻭﺍﺑﺴﺘﮕﻲ ﭘﻴﻮﻧﺪﻱ ﺭﻭﻱ ‪ Rn,…R2,R1‬ﺍﺳﺖ ﺍﮔﺮ ﻭ ﺗﻨﻬﺎ ﺍﮔﺮ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ ‪:‬‬ ‫‪R = R1 ∝R2 ∝R3 …..∝Rn‬‬

‫•‬

‫ﺭﺍﺑﻄﻪ ‪5NF‬‬

‫ﺭﺍﺑﻄﻪ ‪ R‬ﺭﺍ ‪ 5NF‬ﮔﻮﻳﻨﺪ ﺍﮔﺮ ﻭ ﺗﻨﻬﺎ ﺍﮔﺮ ﻓﻘﻂ ﺑﻪ ﻛﻠﻴﺪﻫﺎﻱ ﻛﺎﻧﺪﻳﺪﺵ ﻭﺍﺑﺴﺘﮕﻲ ﭘﻴﻮﻧﺪﻱ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪ .‬ﺑﻌﺒﺎﺭﺗﻲ ﺩﻳﮕﺮ ﻭﺟﻮﺩ‬ ‫ﻫﺮ ﻭﺍﺑﺴﺘﮕﻲ ﭘﻴﻮﻧﺪﻱ ﺩﺭ ﺁﻥ ﻧﺎﺷﻲ ﺍﺯ ﻛﻠﻴﺪﻫﺎﻱ ﻛﺎﻧﺪﻳﺪ ﺑﺎﺷﺪ‪.‬ﺍﺯ ﺍﻳﻦ ﺗﻌﺮﻳﻒ ﺍﻳﻦ ﻧﺘﻴﺠﻪ ﺑﺪﺳﺖ ﻣﻲ ﺁﻳﺪ ﻛﻪ ﺍﮔﺮ ﺑﺘﻮﺍﻧﻴﻢ ﻳﻚ‬ ‫ﻭﺍﺑﺴﺘﮕﻲ ﻳﻮﻧﺪﻱ ﺩﺭ ﺭﺍﺑﻄﻪ ‪ R‬ﭘﻴﺪﺍ ﻛﻨﻴﻢ ﻛﻪ ﺩﺭ ﻫﻤﻪ ﭘﺮﺗﻮﻫﺎﻳﺶ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺭﺍﺑﻄﻪ ﻭﺟﻮﺩ ﻧﺪﺍﺷﺘﻪ ﺑﺎﺷﺪ ﺭﺍﺑﻄﻪ ‪ 5NF‬ﻧﻴﺴﺖ‪.‬‬ ‫ﺩﻳﺖ ﻭ ﻓﺎﮔﻴﻦ ﻧﺸﺎﻥ ﺩﺍﺩﻩ ﺍﻧﺪ ﻛﻪ ‪:‬‬ ‫ﺍﮔﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ‪ 3NF‬ﺑﺎﺷﺪ ﻭ ﺗﻤﺎﻡ ﻛﻠﻴﺪﻫﺎﻱ ﻛﺎﻧﺪﻳﺪ ﺁﻥ ﺻﻔﺎﺕ ﺳﺎﺩﻩ ﺑﺎﺷﻨﺪ ﺁﻥ ﺭﺍﺑﻄﻪ ‪ 5NF‬ﺍﺳﺖ‪.‬‬ ‫ﺍﮔﺮ ﺭﺍﺑﻄﻪ ﺍﻱ ‪ BCNF‬ﺑﺎﺷﺪ ﻭﺣﺪﺍﻗﻞ ﻳﻜﻲ ﺍﺯﻛﻠﻴﺪﻫﺎﻱ ﻛﺎﻧﺪﻳﺪ ﺁﻥ ﺻﻔﺎﺕ ﺳﺎﺩﻩ ﺑﺎﺷﻨﺪ ﺁﻥ ﺭﺍﺑﻄﻪ‬ ‫‪ 4NF‬ﺍﺳﺖ‪.‬‬

‫ﻣﺮﺍﺣﻞ ﻧﺮﻣﺎﻟﺘﺮ ﺳﺎﺯﻱ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩٧ /‬‬

‫‪ -٥-٦‬ﺗﺠﺰﻳﻪ ﺧﻮﺏ ﻭ ﺑﺪ‬ ‫ﺩﺭ ﻓـﺮﺍﻳﻨﺪ ﻧﺮﻣﺎﻟﺘﺮﺳـﺎﺯﻱ ﻣـﻮﺍﺭﺩﻱ ﻭﺟـﻮﺩ ﺩﺍﺭﺩ ﻛﻪ ﺩﺭ ﺁﻧﻬﺎ ﺗﺠﺰﻳﻪ ﻳﻚ ﺭﺍﺑﻄﻪ ﺑﻪ ﭼﻨﺪ ﮔﻮﻧﻪ ﺍﻣﻜﺎﻥﭘﺬﻳﺮ ﺍﺳﺖ ‪.‬ﻃﺮﺍﺡ ﺑﺎﻳﺴﺘﻲ‬ ‫ﺗﺠﺰﻳﻪ ﺧﻮﺏ ﻭ ﺑﺪ ﺭﺍ ﺑﺎﺯ ﺷﻨﺎﺳﺪ ‪ .‬ﺑﻌﻨﻮﺍﻥ ﻣﺜﺎﻝ ﺭﺍﺑﻄﻪ ‪ S ECOND‬ﺭﺍ ﺩﺭ ﻧﻈﺮ ﻣﻲﮔﻴﺮﻳﻢ ‪:‬‬ ‫)‪SECOND(S#, CITY,STATUS‬‬ ‫ﻭﺍﺑﺴﺘﮕﻲﻫﺎﻱ ﺗﺎﺑﻌﻲ ﺍﻳﻦ ﺭﺍﺑﻄﻪ ﺑﻔﺮﻡ ‪ S# → STATUS ، CITY → STATUS ، S# → CITY‬ﻣﻲﺑﺎﺷﺪ ‪.‬‬

‫ﻗـﺒ ﹰ‬ ‫ﻼ ﺍﻳـﻦ ﺭﺍﺑﻄـﻪ ﺑـﻪ ﺩﻭ ﺭﺍﺑﻄـﻪ )‪ S C(S#, City‬ﻭ )‪ C S(City, Status‬ﺗﺠـﺰﻳﻪ ﺷﺪ ‪ .‬ﺍﻳﻦ ﺗﺠﺰﻳﻪ ﺗﻨﻬﺎ ﺗﺠﺰﻳﻪ ﻣﻤﻜﻦ ﻧﻴﺴﺖ‬ ‫ﺑﻠﻜﻪ ﺗﺠﺰﻳﻪﻫﺎﻱ ﺩﻳﮕﺮﻱ ﻣﺘﺼﻮﺭ ﺍﺳﺖ ‪:‬‬ ‫)‪SC(S#, City‬‬ ‫)‪SS(S#, Status‬‬

‫‪B:‬‬

‫)‪SS(S#, Status‬‬ ‫)‪CS(City, Status‬‬

‫‪C :‬‬

‫ﻛﺪﺍﻣﻴﻚ ﺍﺯ ﺍﻳﻦ ﺳﻪ ﺗﺠﺰﻳﻪ ﺭﺍ ﺑﺎﻳﺪ ﺍﻧﺘﺨﺎﺏ ﻛﺮﺩ ؟‬ ‫ﻼ ﻧﻤﻲﺗﻮﺍﻥ ﺍﻳﻦ ﺍﻃﻼﻉ ﺭﺍ ﻛﻪ ﺷﻬﺮ ﺧﺎﺻﻲ ﺩﺍﺭﺍﻱ‬ ‫ﺗﺠـﺰﻳﻪ ‪ B‬ﻣﻄﻠﻮﺑـﻴﺖ ﺍﻭﻟـﻴﻪ ﺭﺍ ﻧـﺪﺍﺭﺩ ﺯﻳﺮﺍ ﻣﺸﻜﻼﺗﻲ ﺩﺭ ﺁﻥ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ‪ .‬ﻣﺜ ﹰ‬ ‫ﻣﻘـﺪﺍﺭ ﻭﺿـﻌﻴﺖ ﺧﺎﺻـﻲ ﺍﺳـﺖ ﺩﺭ ﺑﺎﻧـﻚ ﺩﺭﺝ ﻛـﺮﺩ ﺗـﺎ ﺯﻣﺎﻧـﻴﻜﻪ ﻧﺪﺍﻧﻴﻢ ﭼﻪ ﺗﻬﻴﻪﻛﻨﻨﺪﻩﺍﻱ ﺩﺭ ﺁﻥ ﺷﻬﺮ ﺳﺎﻛﻦ ﺍﺳﺖ ‪ .‬ﺍﺯ ﻧﻈﺮ‬ ‫ﺗـﺌﻮﺭﻱ ﺗﺠـﺰﻳﻪﺍﻱ ﺑﻬﺘـﺮ ﺍﺳـﺖ ﻛﻪ ﺩﻭ ﺭﺍﺑﻄﻪ ﺣﺎﺻﻞ ﺍﺯ ﺁﻥ ﺍﺯ ﻫﻢ ﻣﺴﺘﻘﻞ ﺑﺎﺷﻨﺪ ‪ .‬ﺍﮔﺮ ﺭﺍﺑﻄﻪ ‪ R‬ﺑﻪ ﺩﻭ ﺭﺍﺑﻄﻪ ‪ R1‬ﻭ ‪ R2‬ﺗﻘﺴﻴﻢ‬ ‫ﺷﻮﺩ ﮔﻮﺋﻴﻢ ‪ R1‬ﻭ ‪ R2‬ﺍﺯ ﻫﻢ ﻣﺴﺘﻘﻠﻨﺪ ﺍﮔﺮ ﺷﺮﺍﻳﻂ ﻗﻀﻴﻪ ﺭﻳﺴﺎﻧﻦ ﺭﺍ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ ‪:‬‬ ‫‪ -١-٥-٦‬ﻗﻀﻴﻪ ﺭﻳﺴﺎﻧﻦ ‪:‬‬ ‫ﺍﮔﺮ ‪ R1‬ﻭ ‪ R2‬ﺩﻭ ﭘﺮﺗﻮ ﻣﺴﺘﻘﻞ ﺍﺯ ‪ R‬ﺑﺎﺷﻨﺪ ‪ ،‬ﺍﻳﻦ ﺩﻭ ﭘﺮﺗﻮ ﺍﺯ ﻳﻜﺪﻳﮕﺮ ﻣﺴﺘﻘﻠﻨﺪ ﺍﮔﺮ ﻭ ﻓﻘﻂ ﺍﮔﺮ‬ ‫‪ .١‬ﺗﻤﺎﻡ ﻭﺍﺑﺴﺘﮕﻲﻫﺎﻱ ﺗﺎﺑﻌﻲ ﻣﻮﺟﻮﺩ ﺩﺭ ﺭﺍﺑﻄﻪ ‪ R‬ﺩﺭ ‪ R1‬ﻭ ‪ R2‬ﺑﺎ ﻫﻢ ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻨﺪ ﻭ ﻳﺎ ﺍﺯ‬ ‫ﻭﺍﺑﺴﺘﮕﻲﻫﺎﻱ ﻣﻮﺟﻮﺩ ﺩﺭ ‪ R1‬ﻭ ‪ R2‬ﻣﻨﻄﻘﹰﺎ ﻗﺎﺑﻞ ﺍﺳﺘﻨﺘﺎﺝ ﺑﺎﺷﻨﺪ ‪.‬‬ ‫ﻼ ﺩﺭ ﻳﻜﻲ ﺍﺯ ﺁﻧﻬﺎ ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺑﺎﺷﺪ ‪.‬‬ ‫‪ .٢‬ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻣﺸﺘﺮﻙ ﺩﺭ ‪ R1‬ﻭ ‪ R2‬ﺍﻗ ﹰ‬ ‫ﺑﺎﺗﻮﺟﻪ ﺑﻪ ﻗﻀﻴﻪ ﺭﻳﺴﺎﻧﻦ ﻣﻲﺑﻴﻨﻴﻢ ﺗﺠﺰﻳﻪ ﺍﻭﻟﻴﻪ ‪ ،‬ﺗﺠﺰﻳﻪ ﺧﻮﺑﻲ ﺍﺳﺖ ﺯﻳﺮﺍ ‪ CITY‬ﺻﻔﺖ ﺧﺎﺻﻪ ﻣﺸﺘﺮﻙ ﺩﺭ ﻳﻜﻲ ﺍﺯ ﺭﺍﺑﻄﻪ ﻫﺎ‬ ‫ﻳﻌﻨﻲ ‪ cs‬ﻛﻠﻴﺪ ﻛﺎﻧﺪﻳﺪ ﺍﺳﺖ ﻭ ﺗﻤﺎﻡ ﻭﺍﺑﺴﺘﮕﻲ ﻫﺎﻱ ﺗﺎﺑﻌﻲ ﻗﺎﺑﻞ ﺍﺳﺘﻨﺘﺎﺝ ﻫﺴﺘﻨﺪ‪.‬‬ ‫‪S#‬‬ ‫‪→ City‬‬ ‫‪City → Status‬‬

‫ﻭ ‪ S# → Status‬ﻣﻨﻄﻘﹰﺎ ﻗﺎﺑﻞ ﺍﺳﺘﻨﺘﺎﺝ ﺍﺳﺖ ‪.‬‬

‫ﺑﺮﺭﺳﻲ ﺗﺠﺰﻳﻪ‪ : B‬ﺩﺭ ﺍﻳﻦ ﺗﺠﺰﻳﻪ ﺩﺍﺭﻳﻢ ‪ S# → City‬ﻭ ‪ S# → Status‬ﻭ ﻧﻤﻲﺗﻮﺍﻥ ﻭﺍﺑﺴﺘﮕﻲ ‪ City → Status‬ﺭﺍ‬ ‫ﺍﺯ ﺍﻳﻦ ﺩﻭ ﻭﺍﺑﺴﺘﮕﻲ ﻣﻨﻄﻘﹰﺎ ﺍﺳﺘﻨﺘﺎﺝ ﻛﺮﺩ ‪.‬‬ ‫ﻻﺯﻡ ﺑﻪ ﺫﻛﺮ ﺍﺳﺖ ﻛﻪ ﺩﺭ ﺗﺠﺰﻳﻪ ﻳﻚ ﺷﻤﺎ ) ‪ ( Schema‬ﺑﻪ ﭼﻨﺪ ﺷﻤﺎﻱ ﻛﻮﭼﻜﺘﺮ ﺑﺎﻳﺪ ﺗﺠﺰﻳﻪ ﺑﺪﻭﻥ ﮔﻤﺸﺪﮔﻲ ﺍﻃﻼﻋﺎﺕ‬ ‫ﺑﺎﺷﺪ ﻳﻌﻨﻲ ﺑﺎﺯﺍﻱ ﺗﻤﺎﻡ ﺟﺪﺍﻭﻝ ﻣﺮﺑﻮﻃﻪ ﺍﺯ ﭘﻴﻮﻧﺪ ﻃﺒﻴﻌﻲ ﺁﻥ ﺟﺪﺍﻭﻝ ﺩﻗﻴﻘﹰﺎ ﺟﺪﺍﻭﻝ ﺍﺻﻠﻲ ﺑﺪﺳﺖ ﺁﻳﺪ ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩٨ /‬‬

‫‪-٢-٥-٦‬ﺭﺍﺑﻄﻪ ﺍﺗﻤﻴﻚ‪:‬‬ ‫ﺭﺍﺑﻄـﻪﺍﻱ ﻛﻪ ﺑﻪ ﻋﻨﺎﺻﺮ ﻣﺴﺘﻘﻞ ﺗﺠﺰﻳﻪ ﻧﺸﻮﺩ )ﻃﺒﻖ ﺭﺍﺑﻄﻪ ﺭﻳﺴﺎﻧﺲ ( ﺑﻪ ﺭﺍﺑﻄﻪ ﺍﺗﻤﻴﻚ ﻣﻮﺳﻮﻡ ﺍﺳﺖ ‪.‬ﺍﺗﻤﻴﻚ ﺑﻮﺩﻥ ﺑﻪ ﺍﻳﻦ ﻣﻌﻨﺎ‬ ‫ﻧﻴﺴـﺖ ﻛﻪ ﻧﺒﺎﻳﺪ ﺗﺠﺰﻳﻪ ﺷﻮﺩ ﻭﻟﻲ ﻟﺰﻭﻣﻲ ﺑﻪ ﺗﺠﺰﻳﻪ ﺁﻧﻬﺎ ﻧﻴﺴﺖ ﻳﻌﻨﻲ ﺩﺭ ﺻﻮﺭﺕ ﺗﺠﺰﻳﻪ ﻣﻤﻜﻦ ﺍﺳﺖ ﺑﻪ ﺭﺍﺑﻄﻪ ﻧﺮﻣﺎﻟﺘﺮﻱ ﻧﺮﺳﻴﺪ‬ ‫‪ .‬ﺑﻪ ﻋﻨﻮﺍﻥ ﻣﺜﺎﻝ ‪:‬‬ ‫)‪ S( S#, Sname, Status, City‬ﻣﻲﺗﻮﺍﻧﺪ ﺑﻪ ﺩﻭ ﺭﺍﺑﻄﻪ )‪ SX(S#, Sname, Status‬ﻭ )‪ SY(S#, City‬ﺗﺠﺰﻳﻪ ﺷﻮﺩ ﻛﻪ ﺍﺯ‬ ‫ﻧﻈﺮ ﻧﺮﻣﺎﻟﻴﺘﻲ ﻓﺮﻗﻲ ﻧﺪﺍﺭﺩ ﻭ ﻣﻤﻜﻦ ﺍﺳﺖ ﺑﺪﻻﻳﻞ ﺩﻳﮕﺮ ﺗﺠﺰﻳﻪ ﺷﺪﻩ ﺑﺎﺷﺪ ‪.‬‬ ‫‪ -٦-٦‬ﻧﻤﻮﻧﻪ ﻣﺴﺎﺋﻞ ﺍﻳﻦ ﻓﺼﻞ ‪:‬‬ ‫ﻣﺠﻤﻮﻋﻪ ﺣﺪﺍﻗﻞ ‪ FD‬ﻫﺎﻱ ﺍﻳﻦ ﺭﺍﺑﻄﻪ ﺭﺍ ﺑﺪﺳﺖ ﺁﻭﺭﻳﺪ ‪.‬‬ ‫‪L‬‬

‫ﺣﻞ ‪ :‬ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﻧﻤﻮﺩﺍﺭ ‪ FD‬ﻫﺎ ﺩﺍﺭﻳﻢ ‪:‬‬ ‫‪4. N → Q‬‬ ‫)‪5.N → (L,M‬‬ ‫‪6. M → Q‬‬

‫‪P‬‬

‫‪1. P → N‬‬ ‫‪2. N → L‬‬ ‫‪3. P → L‬‬

‫‪N‬‬ ‫‪M‬‬

‫‪Q‬‬

‫‪ FD‬ﺷﻤﺎﺭﻩ ‪ 3‬ﺍﻓﺰﻭﻧﻪ ﺍﺳﺖ ﺯﻳﺮﺍ ﻣﻨﻄﻘﹰﺎ ﺍﺯ‪ FD‬ﻫﺎﻱ ‪ 1‬ﻭ ‪ 2‬ﻗﺎﺑﻞ‬ ‫ﺍﺳﺘﻨﺘﺎﺝ ﺍﺳﺖ ‪ .‬ﺍﺯ ‪ FD‬ﺷﻤﺎﺭﻩ ‪ 2‬ﻭ ‪ 5‬ﺩﺍﺭﻳﻢ ‪:‬‬

‫‪7. N → M‬‬

‫ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ‪ FD‬ﻫﺎﻱ ‪ 7‬ﻭ ‪ FD ، 6‬ﺷﻤﺎﺭﻩ ‪ 4‬ﺍﻓﺰﻭﻧﻪ ﺍﺳﺖ ‪ ،‬ﺑﻨﺎﺑﺮﺍﻳﻦ ﻣﺠﻤﻮﻋﻪ ﺣﺪﺍﻗﻞ ‪ FD‬ﻫﺎ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ ‪:‬‬ ‫‪P → N‬‬

‫ﻭ‪N → L‬‬

‫ﻭ‪N→ M‬‬

‫ﻭ ‪M→ Q‬‬

‫‪L‬‬

‫‪N‬‬

‫‪M‬‬

‫‪P‬‬

‫‪Q‬‬

‫‪-٢‬ﺩﺭ ﻧﻤﻮﺩﺍﺭ ‪ FD‬ﻫﺎﻱ ﺯﻳﺮ ﻣﺠﻤﻮﻋﻪ ﺣﺪﺍﻗﻞ ‪ FD‬ﻫﺎ ﺭﺍ ﺑﺪﺳﺖ ﺁﻭﺭﻳﺪ ‪.‬‬ ‫‪1. (X,Y) → Z‬‬ ‫‪2. Y → Z‬‬ ‫‪3. T → U‬‬ ‫‪4. U → Y‬‬ ‫‪5. T → Z‬‬

‫‪ FD‬ﺷﻤﺎﺭﻩ ‪ ٥‬ﺍﻓﺰﻭﻧﻪ ﺍﺳﺖ ‪.‬‬ ‫‪ FD‬ﺷﻤﺎﺭﻩ ‪ ١‬ﻧﻴﺰ ﺍﻓﺰﻭﻧﻪ ﺍﺳﺖ ‪ .‬ﭼﺮﺍ ؟‬ ‫ﭘﺲ ﺩﺍﺭﻳﻢ ‪, Y → Z :‬‬ ‫] ﭼﻮﻥ ﺍﺯ ‪Z‬‬

‫‪Z‬‬

‫‪Y‬‬

‫‪X‬‬

‫‪U‬‬

‫‪T‬‬

‫‪T→ U‬‬

‫→ ‪ Y‬ﻣﻲﺗﻮﺍﻥ ﻧﺘﻴﺠﻪ ﮔﺮﻓﺖ ‪ (X,Y) → Z‬ﺯﻳﺮﺍ ﺍﮔﺮ ‪ (X,Y) → Z‬ﻳﻌﻨﻲ)‪ (X1 ,Y1 , Z١‬ﻭ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫)‪ ( X1, Y1 , Z٢‬ﻭ ﭼﻮﻥ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪٩٩ /‬‬

‫)‪ (Y1, Z2) , (Y1, Z1‬ﻟﺬﺍ ‪ Y→Z‬ﺧﻼﻑ ﻓﺮﺽ ﺍﺳﺖ ﭘﺲ ‪[ Y→Z‬‬

‫‪ -٣‬ﺭﺍﺑﻄﻪ )‪ R(A,B,C‬ﺭﺍ ﺩﺭ ﻧﻈﺮ ﻣﻲﮔﻴﺮﻳﻢ ‪ .‬ﺩﺭ ﻳﻚ ﻟﺤﻈﻪ ﺍﺯ ﺣﻴﺎﺕ ﺭﺍﺑﻄﻪ ‪ ،‬ﺑﺴﻂ ﺁﻥ ﭼﻨﻴﻦ ﺍﺳﺖ ﻓﺮﺽ ﻛﻨﻴﻢ ﻛﻪ ﺍﻳﻦ ﺭﺍﺑﻄﻪ‬ ‫ﺑﺎﻳﺪ ﺗﺠﺰﻳﻪ ﺷﻮﺩ ﭼﮕﻮﻧﻪ ﺑﺎﻳﺪ ﺁﻧﺮﺍ ﺗﺠﺰﻳﻪ ﻛﺮﺩ ؟‬

‫‪C‬‬ ‫‪c3‬‬ ‫‪c6‬‬ ‫‪c2‬‬

‫‪A‬‬ ‫‪a1‬‬ ‫‪a3‬‬ ‫‪a3‬‬

‫‪C‬‬ ‫‪c3‬‬ ‫‪c6‬‬ ‫‪c2‬‬

‫‪B‬‬ ‫‪b2‬‬ ‫‪b2‬‬ ‫‪b4‬‬

‫‪B‬‬ ‫‪b2‬‬ ‫‪b2‬‬ ‫‪b4‬‬

‫‪A‬‬ ‫‪a1‬‬ ‫‪a3‬‬ ‫‪a3‬‬

‫‪A B C‬‬ ‫‪a1 b2 c3‬‬ ‫‪a3 b2 c6‬‬ ‫‪a3 b4 c2‬‬

‫‪Join‬‬

‫‪C‬‬ ‫‪c3‬‬ ‫‪c6‬‬ ‫‪c2‬‬

‫‪B‬‬ ‫‪b2‬‬ ‫‪b2‬‬ ‫‪b4‬‬

‫‪A‬‬ ‫‪a1‬‬ ‫‪a3‬‬ ‫‪a3‬‬

‫‪BC ∞ AC‬‬

‫‪C‬‬ ‫‪c3‬‬ ‫‪c6‬‬ ‫‪c3‬‬ ‫‪c6‬‬ ‫‪c2‬‬

‫‪A B‬‬ ‫‪a1 b2‬‬ ‫‪a1 b2‬‬ ‫ﺍﻓﺰﻭﻧﻪ‬ ‫‪b2‬‬ ‫ﺗﺎﭘﻞ ‪a3‬‬ ‫‪a3 b2‬‬ ‫‪a3 b4‬‬ ‫‪C‬‬ ‫‪c3‬‬ ‫‪c6‬‬ ‫‪c2‬‬ ‫‪c6‬‬ ‫‪c2‬‬

‫‪B‬‬ ‫‪b2‬‬ ‫‪b2‬‬ ‫‪b2‬‬ ‫‪b4‬‬ ‫‪b4‬‬

‫‪AB ∞ AC‬‬

‫‪A‬‬ ‫‪a1‬‬ ‫‪a3‬‬ ‫‪a3‬‬ ‫‪a3‬‬ ‫‪a3‬‬

‫ﻣــﻲ ﺑﻴﻨــﻴﻢ ﻛــﻪ ﺗﺠــﺰﻳﻪ ‪ R‬ﺑﺼــﻮﺭﺕ )‪ R :(AB,AC‬ﻳــﺎ )‪R :(AB,BC‬ﻣﻨﺎﺳــﺐ ﻧﻴﺴــﺖ ﺯﻳــﺮﺍ ﺑــﺎ ﭘــﻴﻮﻧﺪ ﺗﺠــﺰﻳﻪﻫــﺎ‬ ‫ﺗﺎﭘـﻞ ﺍﻓـﺰﻭﻧﻪ ﺑـﺮﻭﺯ ﻣـﻲﻛـﻨﺪ ﺍﻣﺎ ﺩﺭ ﺗﺠﺰﻳﻪ )‪ R : (BC,AC‬ﺍﻳﻦ ﭘﺪﻳﺪﻩ ﻧﺎﻣﻄﻠﻮﺏ ﺭﺍ ﺩﺭ ﭘﻲ ﻧﺪﺍﺭﺩ ﻟﺬﺍ ﺍﻳﻦ ﺗﺠﺰﻳﻪ ﻣﻨﺎﺳﺐ‬ ‫ﺍﺳﺖ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠٠ /‬‬

‫ﻓﺼﻞ ﻫﻔﺘﻢ ‪:‬‬ ‫ﻣﻌﻤﺎﺭﻱ ﺳﻴﺴﺘﻢ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ‬

‫‪:‬‬

‫‪-١-٣‬ﻣﻘﺪﻣﻪ ‪:‬‬ ‫ﻣـﻲ ﺩﺍﻧـﻴﻢ ﻃـﺮﺍﺡ ﺑﺎﻧـﻚ‪ ،‬ﺗﺼـﻮﺭ ﻳﺎ ﺩﺭﻙ ﺧﻮﺩ ﺭﺍ ﺍﺯ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ )ﺟﻬﺎﻥ ﻭﺍﻗﻌﻲ( ﻭ ﺩﺭ ﻭﺍﻗﻊ ﺩﻳﺪ ﺧﻮﺩ ﺭﺍ ﺍﺯ ﺩﺍﺩﻩ ﻫﺎﻱ‬ ‫ﻋﻤﻠﻴﺎﺗـﻲ ﻣﺤـﻴﻂ ﺑﺼـﻮﺭﺕ ﻧﻤـﻮﺩﺍﺭ ‪ E/R‬ﻣﺘﺠﻠـﻲ ﻣـﻲ ﺳﺎﺯﺩ‪ .‬ﺍﻳﻦ ﻧﻤﻮﺩﺍﺭ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﻫﺎﻱ ﻋﻤﻠﻴﺎﺗﻲ ﺑﺎﻧﻚ ﺩﺭ ﺑﺎﻻﺗﺮﻳﻦ ﺳﻄﺢ‬ ‫ﺍﻧﺘﺰﺍﻉ ﻣﻲ ﺑﺎﺷﺪ ﻭ ﺍﺯ ﺳﻮﻳﻲ ﺩﻳﮕﺮ ﻣﺤﻴﻂ ﻓﻴﺰﻳﻜﻲ ﺑﺎﻧﻚ ﻛﻪ ﭘﺎﻳﻴﻦ ﺗﺮﻳﻦ ﻭ ﻋﻴﻨﻲ ﺗﺮﻳﻦ ﺳﻄﺢ ﺑﺎﻧﻚ ﺍﺳﺖ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺳﺖ ﺍﺯ‬ ‫ﻓﺎﻳﻠﻬـﺎ ﺑﺎ ﺳﺎﺧﺘﺎﺭ ﻣﺸﺨﺺ ﻭ ﺍﺭﺗﺒﺎﻃﺎﺕ ﺑﻴﻦ ﺁﻧﻬﺎ‪ ،‬ﻟﺬﺍ ﺑﺎﻳﺴﺘﻲ ﺑﻴﻦ ﺑﺎﻻﺗﺮﻳﻦ ﺳﻄﺢ ﺍﻧﺘﺰﺍﻋﻲ ﻭ ﭘﺎﻳﻴﻦ ﺗﺮﻳﻦ ﺳﻄﺢ ﻋﻴﻨﻲ ﺁﻥ ﺳﻄﻮﺡ‬ ‫ﻭﺍﺳـﻄﻲ ﻭﺟـﻮﺩ ﺩﺍﺷﺘﻪ ﻛﻪ ﺩﺭ ﺍﻳﻦ ﺳﻄﻮﺡ ﻭﺍﺳﻂ ﺩﺍﺩﻩ ﻫﺎﻱ ﻋﻤﻠﻴﺎﺗﻲ ﻣﺤﻴﻂ ﻫﻢ ﺑﺼﻮﺭﺗﻲ ﻛﻪ ﻃﺮﺍﺡ ﻣﻲ ﺑﻴﻨﺪ ﻭ ﻫﻢ ﺑﺼﻮﺭﺗﻲ‬ ‫ﻛﻪ ﻫﺮ ﻳﻚ ﺍﺯ ﻛﺎﺭﺑﺮﺍﻥ ﺑﻪ ﻧﺤﻮﻱ ﺗﻌﺮﻳﻒ ﺷﻮﻧﺪ‪.‬‬ ‫ﺑـﺎ ﺍﻳـﻦ ﺗﻮﺻـﻴﻒ ﺩﺭ ﻣﻲ ﻳﺎﺑﻴﻢ ﻛﻪ ﻳﻚ ﺳﻴﺴﺘﻢ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺳﻴﺴﺘﻤﻲ ﺍﺳﺖ ﭼﻨﺪ ﺳﻄﺤﻲ ﻛﻪ ﻃﺒﻌﹰﺎ ﻣﻌﻤﺎﺭﻱ ﺧﺎﺹ ﺧﻮﺩ ﺭﺍ‬ ‫ﺩﺍﺭﺩ‪ .‬ﺍﺯ ﺁﻧﺠﺎﻳـﻴﻜﻪ ﻃﺮﺍﺣﺎﻥ ﻣﺨﺘﻠﻒ ﺳﻴﺴﺘﻢ ﻫﺎﻱ ﺑﺎﻧﻜﻲ ﻃﺮﺣﻬﺎﻱ ﻣﺘﻔﺎﻭﺗﻲ ﺑﺮﺍﻱ ﻣﻌﻤﺎﺭﻱ ﭼﻨﻴﻦ ﺳﻴﺴﺘﻤﻲ ﺍﺭﺍﺋﻪ ﻭ ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ‬ ‫ﻛﺮﺩﻩ ﺍﻧﺪ ﻟﺬﺍ ‪ ANSI‬ﻧﻴﺰ ﻃﺮﺣﻲ ﺍﺳﺘﺎﻧﺪﺍﺭﺩ ﺑﺮﺍﻱ ﻣﻌﻤﺎﺭﻱ ﺳﻴﺴﺘﻢ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﻋﺮﺿﻪ ﻛﺮﺩﻩ ﺍﺳﺖ‪.‬‬ ‫‪ -٢-٧‬ﻣﻌﻤﺎﺭﻱ ‪ANSI‬‬

‫ﻣﻌﻤﺎﺭﻱ ‪ ANSI‬ﺑﻪ ﺳﻪ ﺳﻄﺢ ﻣﺨﺘﻠﻒ ﺗﻘﺴﻴﻢ ﺑﻨﺪﻱ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﺑﻪ ﺗﺮﺗﻴﺐ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ‪ :‬ﺳﻄﺢ ﺩﺍﺧﻠﻲ‪ ،‬ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﻭ‬ ‫ﺳﻄﺢ ﺧﺎﺭﺟﻲ‪ .‬ﺷﻜﻞ ﺯﻳﺮ ﺑﻴﺎﻧﮕﺮ ﺍﻳﻦ ﻣﻌﻤﺎﺭﻱ ﺍﺳﺖ‪:‬‬ ‫‪HL +‬‬ ‫‪DSL‬‬

‫‪HL +‬‬ ‫‪DSL‬‬ ‫‪External‬‬ ‫‪View B‬‬

‫‪HL‬‬ ‫‪DSL‬‬

‫‪External Level‬‬

‫‪HL‬‬ ‫‪DSL‬‬ ‫‪External‬‬ ‫‪View A‬‬

‫‪DBMS‬‬ ‫‪External/conceptual Mapping‬‬ ‫‪Conceptual‬‬ ‫‪View‬‬ ‫‪Conceptual/internal Mapping‬‬ ‫‪Stored data base‬‬ ‫)‪(internal view‬‬

‫‪Schema A‬‬

‫‪DBA‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠١ /‬‬

‫ﻫﻤﺎﻧﻄﻮﺭ ﻛﻪ ﺩﺭ ﺷﻜﻞ ﺩﻳﺪﻩ ﻣﻲ ﺷﻮﺩ ﻣﻌﻤﺎﺭﻱ ﺳﻴﺴﺘﻢ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺍﺯ ﺍﺟﺰﺍﺀ ﺯﻳﺮ ﺗﺸﻜﻴﻞ ﺷﺪﻩ ﺍﺳﺖ‬ ‫‪ HL – ١‬ﺯﺑﺎﻥ ﻣﻴﺰﺑﺎﻥ‬ ‫‪ - ٢‬ﺯﺑﺎﻥ ﻓﺮﻋﻲ ﺩﺍﺩﻩ ﺍﻱ ‪DSL‬‬ ‫‪ – ٣‬ﺩﻳﺪ ﺧﺎﺭﺟﻲ ‪External View‬‬ ‫‪ – ٤‬ﺩﻳﺪ ﻣﻔﻬﻮﻣﻲ ‪Conceptual View‬‬ ‫‪ – ٥‬ﺩﻳﺪ ﺩﺍﺧﻠﻲ ‪Internal View‬‬ ‫‪ – ٦‬ﺗﺒﺪﻳﻼﺕ ﺑﻴﻦ ﺳﻄﻮﺡ ‪mapping‬‬ ‫‪ – ٧‬ﻛﺎﺭﺑﺮ ‪User‬‬ ‫‪ – ٨‬ﺍﺩﺍﺭﻩ ﻛﻨﻨﺪﻩ ﭘﺎﻳﮕﺎﻩ ‪DBA‬‬ ‫‪ – ٩‬ﺳﻴﺴﺘﻢ ﻣﺪﻳﺮﻳﺖ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ‪DBMS‬‬

‫‪ -٣-٧‬ﺷﺮﺡ ﺍﺟﺰﺍﺀ ﻣﻌﻤﺎﺭﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ‪:‬‬ ‫‪ – ١-٣-٧‬ﺩﻳﺪ ﻣﻔﻬﻮﻣﻲ )ﺍﺩﺭﺍﻛﻲ(‬ ‫ﺩﻳـﺪ ﻃـﺮﺍﺡ ﺑﺎﻧﻚ ﺍﺯ ﺩﺍﺩﻩ ﻫﺎﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺩﺭ ﺁﻥ ﻣﻲ ﺑﺎﺷﺪ‪ .‬ﺍﻳﻦ ﺩﻳﺪ ﺩﻳﺪﻱ ﺟﺎﻣﻊ ﻭ ﺳﺮﺍﺳﺮﻱ ﻣﻲ ﺑﺎﺷﺪ‪ ،‬ﻳﻌﻨﻲ ﺟﺎﻣﻊ ﺗﻤﺎﻡ‬ ‫ﻧـﻴﺎﺯﻫﺎﻱ ﻛﺎﺭﺑـﺮﺍﻥ ﺍﺳـﺖ‪ .‬ﺍﻳﻦ ﺩﻳﺪ ﺗﺸﻜﻴﻞ ﺩﻫﻨﺪﻩ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﻭ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﺍﺯ ﺳﻄﻮﺡ ﺍﻧﺘﺰﺍﻋﻲ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ‬

‫ﺍﺳﺖ‪.‬‬

‫ﺩﻳـﺪ ﺍﺩﺭﺍﻛﻲ ﺑﺎﻳﺪ ﺑﻪ ﻛﻤﻚ ﺍﻣﻜﺎﻧﺎﺗﻲ ﻧﻈﻴﺮ ﺍﺣﻜﺎﻡ ﺗﻌﺮﻳﻒ ﻛﻨﻨﺪﻩ ﺍﺯ ﺍﻳﻦ ﺯﺑﺎﻥ ﺩﺍﺩﻩ ﺍﻱ ﻭ ﺳﺎﺧﺘﺎﺭ ﺩﺍﺩﻩ ﺍﻱ ﺗﻌﺮﻳﻒ ﺷﻮﺩ ﻛﻪ ﺑﻪ‬ ‫ﺗﻌـﺮﻳﻒ ﺁﻥ ﺷـﻤﺎﻱ ﺍﺩﺭﺍﻛـﻲ ﮔﻔـﺘﻪ ﻣـﻲ ﺷـﻮﺩ‪ .‬ﺩﺭ ﻭﺍﻗﻊ ﺷﻤﺎﻱ ﺍﺩﺭﺍﻛﻲ ﺩﺭ ﻣﻌﻨﺎﻱ ﻋﺎﻡ ﻧﻮﻋﻲ ﺑﺮﻧﺎﻣﻪ ﺣﺎﻭﻱ ﺗﻌﺮﻳﻒ ﺩﺍﺩﻩ ﻫﺎ ﻭ‬ ‫ﺍﺭﺗـﺒﺎﻃﺎﺕ ﺑـﻴﻦ ﺁﻧﻬـﺎ ﻭ ﻧﻴـﺰ ﻣﺠﻤـﻮﻋﻪ ﺍﻱ ﺍﺯ ﻗـﻮﺍﻋﺪ ﻋﻤﻠﻴﺎﺗﻲ ﻣﻲ ﺑﺎﺷﺪ‪ .‬ﺍﻳﻦ ﻗﻮﺍﻋﺪ ﻋﻤﻠﻴﺎﺗﻲ ﻧﺎﻇﺮ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎﻱ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ‬ ‫ﻫﺴـﺘﻨﺪ‪ .‬ﺍﺯ ﺟﻤﻠـﻪ ﺳـﺎﺧﺘﺎﺭﻫﺎﻱ ﺩﺍﺩﻩ ﺍﻱ ﺭﺍﻳـﺞ ﺑـﺮﺍﻱ ﺗﻌﺮﻳﻒ ﺷﻤﺎﻱ ﺍﺩﺭﺍﻛﻲ ﻣﻲ ﺗﻮﺍﻥ ﺑﻪ ﺳﺎﺧﺘﺎﺭﻫﺎﻳﻲ ﻧﻈﻴﺮ ﺭﺍﺑﻄﻪ ﺍﻱ‪ ،‬ﺳﻠﺴﻠﻪ‬ ‫ﻣﺮﺍﺗﺒﻲ‪ ،‬ﺷﺒﻜﻪ ﺍﻱ ﻭ ﻫﺎﻳﭙﺮﮔﺮﺍﻑ ﺍﺷﺎﺭﻩ ﻧﻤﻮﺩ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ (١‬ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺭﺍﺑﻄﻪ ﺑﻴﻦ ﻗﻄﻌﻪ ﻭ ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ ﺑﻪ ﻛﻤﻚ ﺍﺣﻜﺎﻡ ﺳﻠﺴﻠﻪ ﻣﺮﺍﺗﺒﻲ ﺩﻳﺪ ﺍﺩﺭﺍﻛﻲ ﭘﺎﻳﮕﺎﻩ ﺭﺍ ﺗﻌﺮﻳﻒ ﻛﻨﻴﺪ‪.‬‬ ‫‪N‬‬ ‫ﺷﻤﺎﺭﻩ‬

‫‪١‬‬

‫ﺷﻤﺎﺭﻩ‬

‫ﻧﺎﻡ‬

‫ﻧﺎﻡ‬

‫ﻗﻄﻌﻪ‬

‫ﺗﻬﻴﻪ ﻣﻲ ﻛﻨﺪ‬

‫ﺭﻧﮓ‬

‫ﻭﺯﻥ‬

‫ﺗﻬﻴﻪ ﻛﻨﻨﺪﻩ‬ ‫ﻭﺿﻌﻴﺖ‬

‫ﺗﻌﺪﺍﺩ‬

‫ﺷﻬﺮ‬

‫‪ DS‬ﺳﻠﺴـﻠﻪ ﻣﺮﺍﺗﺒـﻲ ﻧﻮﻋـﻲ ﺩﺭﺧﺘﻮﺍﺭﻩ ﺍﺳﺖ ﻛﻪ ﻳﻚ ﺭﻳﺸﻪ ﺩﺍﺭﺩ ﻭ ﺩﺭ ﺳﻄﻮﺡ ﻣﺨﺘﻠﻒ ﺩﺍﺭﺍﻱ ﺍﻋﻀﺎ ﻳﺎ ﻭﺍﺑﺴﺘﮕﺎﻧﻲ ﻣﻲ ﺑﺎﺷﺪ ﺑﻪ‬ ‫ﺩﻭ ﺻﻮﺭﺕ ﺁﻥ ﺭﺍ ﻣﺪﻝ ﻣﻲ ﻛﻨﻴﻢ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬ ‫‪S type Record‬‬

‫ﺍﻟﻒ‪:‬‬

‫‪……..‬‬

‫‪Sname‬‬

‫‪type Record‬‬

‫ﺏ‪:‬‬ ‫‪S#‬‬

‫‪P‬‬

‫…… ‪P# Pname Color‬‬

‫‪١:n‬‬

‫‪Qty‬‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠٢ /‬‬

‫‪١:n‬‬

‫‪….‬‬

‫‪P#‬‬

‫‪….‬‬

‫‪Qty‬‬

‫‪S#‬‬

‫ﺗﻮﺟﻪ‪ :‬ﻓﻴﻠﺪ ‪ Qty‬ﺩﺭ ﺳﻠﺴﻠﻪ ﻣﺮﺍﺗﺐ ‪ PS‬ﺩﺭ ‪ S‬ﻗﺮﺍﺭ ﺩﺍﺭﺩ ﻭ ﺩﺭ ﺳﻠﺴﻠﻪ ﻣﺮﺍﺗﺐ ‪ S P‬ﺩﺭ ‪.P‬‬ ‫ﻧﻤﺎﻳﺶ ﺩﻳﺪ ﺍﺩﺭﺍﻛﻲ ﺑﻪ ﻛﻤﻚ ‪ DS‬ﺳﻠﺴﻠﻪ ﻣﺮﺍﺗﺒﻲ ‪) :‬ﺷﻤﺎﻱ ﺍﺩﺭﺍﻛﻲ(‬ ‫ﺍﺯ ﺩﻳـﺪ ﻃﺮﺍﺣـﻲ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﺍﺭﺗﺒﺎﻃﺎﺕ ﺑﺼﻮﺭﺕ ﻳﻚ ﺩﺭﺧﺖ ﺩﻳﺪﻩ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﺭﻳﺸﻪ ﺁﻥ ﺣﺎﻭﻱ ﺍﻃﻼﻋﺎﺕ ﺩﺭ ﻣﻮﺭﺩ ﻗﻄﻌﺎﺕ ﻭ‬ ‫ﻭﺍﺑﺴﺘﻪ ﻳﺎ ﻓﺮﺯﻧﺪ ﺁﻥ ﺭﻳﺸﻪ ﺣﺎﻭﻱ ﺍﻃﻼﻋﺎﺗﻲ ﺩﺭ ﻣﻮﺭﺩ ﺗﻬﻴﻪ ﻛﻨﻨﺪﮔﺎﻥ‪ .‬ﺩﺭ ﺳﺎﺧﺘﺎﺭ ﺩﺍﺩﻩ ﺳﻠﺴﻠﻪ ﻣﺮﺍﺗﺒﻲ ﺗﻌﺪﺍﺩﻱ ﺩﺭﺧﺘﻮﺍﺭﻩ ﻭﺟﻮﺩ‬ ‫ﺩﺍﺭﺩ ﻛﻪ ﻃﺮﺍﺡ ﺍﻳﻦ ﺳﺎﺧﺘﺎﺭ ﺭﺍ ﺑﻪ ‪ DBMS‬ﺍﻱ ﻛﻪ ﺁﻥ ﺭﺍ ﻣﻲ ﭘﺬﻳﺮﺩ ﺧﻮﺍﻫﺪ ﺩﺍﺩ‪.‬‬ ‫ﻧﻤﻮﻧﻪ ﺳﺎﺯﻱ ﺍﺯ ﺷﻤﺎﻱ ﺍﺩﺭﺍﻛﻲ ﺑﺼﻮﺭﺕ ﻏﻴﺮ ﺻﻮﺭﻱ‪:‬‬ ‫‪ – ١‬ﻧﺎﻡ ﺳﻠﺴﻠﻪ ﻣﺮﺍﺗﺐ ‪ PS‬ﺍﺳﺖ‬ ‫‪ – ٢‬ﺭﻳﺸﻪ ﺭﻛﻮﺭﺩ ﻧﻮﻉ ‪ P‬ﺍﺳﺖ ﻭ ﻓﻴﻠﺪﻫﺎﻱ ‪ P# ) P‬ﻛﺎﺭﺍﻛﺘﺮ‪ Pname ، ١ .‬ﻛﺎﺭﺍﻛﺘﺮ ‪(… ٢ .‬‬ ‫ﻭ ﺷﻨﺎﺳﻪ ﺭﻳﺸﻪ ‪ P#‬ﺍﺳﺖ‪.‬‬ ‫‪ – ٣‬ﻭﺍﺑﺴﺘﻪ ﻳﺎ ﻓﺮﺯﻧﺪ ﺭﻛﻮﺭﺩ ﻧﻮﻉ ‪ S‬ﻣﻲ ﺑﺎﺷﺪ‪.‬‬ ‫ﻓﻴﻠﺪﻫﺎﻱ ‪ S# ) S‬ﻭ ……… ‪ ( Qty‬ﺍﺳﺖ‪ .‬ﻭ ﺷﻨﺎﺳﻪ ‪ S# S‬ﻣﻲ ﺑﺎﺷﺪ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ (٢‬ﭘﺎﻳﮕﺎﻩ ﺭﺍﺑﻄﻪ ﺍﻱ‪:‬‬ ‫ﻻ ﺑﺮﺍﻱ ﻫﺮ ﻣﻮﺟﻮﺩﻳﺖ ﻳﻚ ﺟﺪﻭﻝ ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺘﻪ ﻣﻲ ﺷﻮﺩ ﻭ ﺑﺮﺍﻱ ﻫﺮ ﺻﻔﺖ‬ ‫ﺩﺭ ﺍﻳﻦ ﺳﺎﺧﺘﺎﺭ ﺑﺮﺍﻱ ﻃﺮﺍﺣﻲ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻣﻌﻤﻮ ﹰ‬ ‫ﺧﺎﺻﻪ ﻳﻚ ﺳﺘﻮﻥ ﻭ ﻫﺮ ﺳﻄﺮ ﻛﻪ ﺑﻌﺪﹰﺍ ﭘﺮ ﻣﻲ ﺷﻮﺩ ﻳﻚ ﻧﻤﻮﻧﻪ ﻣﻮﺟﻮﺩﻳﺖ ﻣﻲ ﺑﺎﺷﺪ‪.‬‬ ‫‪S‬‬

‫‪P‬‬ ‫‪Weight‬‬

‫‪Color‬‬

‫‪Pname‬‬

‫‪P#‬‬

‫‪City‬‬

‫‪Status‬‬

‫‪Sname‬‬

‫‪S#‬‬

‫‪١٠‬‬

‫ﺁﺑﻲ‬

‫‪Pn1‬‬

‫‪P1‬‬

‫ﺗﻬﺮﺍﻥ‬

‫‪١٠‬‬

‫‪Sn1‬‬

‫‪S1‬‬

‫‪١٥‬‬

‫ﺯﺭﺩ‬

‫‪Pn2‬‬

‫‪P2‬‬

‫ﻗﺰﻭﻳﻦ‬

‫‪١٥‬‬

‫‪Sn2‬‬

‫‪S2‬‬

‫ﺷﻴﺮﺍﺯ‬

‫‪٧‬‬

‫‪SN3‬‬

‫‪S3‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫•‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠٣ /‬‬

‫ﺑـﺮﺍﻱ ﻧﻤـﺎﻳﺶ ﺍﺭﺗـﺒﺎﻃﺎﺕ ﺑـﻴﻦ ﺩﻭ ﻳـﺎ ﺑـﻴﺶ ﺍﺯ ﺩﻭ ﻣﻮﺟـﻮﺩﻳﺖ ﻳـﻚ ﺭﺍﻩ ﻭ ﺍﻟﺒـﺘﻪ ﺭﺍﻳﺞ ﺗﺮ ﺍﻳﻦ ﺍﺳﺖ ﻛﻪ ﺟﺪﻭﻟﻲ ﺩﻳﮕﺮ‬ ‫ﻃﺮﺍﺣـﻲ ﻣـﻲ ﺷـﻮﺩ ﻭ ﺍﺭﺗـﺒﺎﻃﺎﺕ ﺑـﻪ ﻛﻤـﻚ ﺁﻥ ﻧﻤـﺎﻳﺶ ﺩﺍﺩﻩ ﻣـﻲ ﺷـﻮﺩ‪ .‬ﺩﺭ ﺍﻳـﻦ ﺟـﺪﻭﻝ ﻧﺸـﺎﻥ ﺩﻫـﻨﺪﻩ ﺍﺭﺗـﺒﺎﻁ ﺑﻴﻦ ﺩﻭ‬ ‫ﻣﻮﺟﻮﺩﻳﺖ ﺷﻨﺎﺳﻪ ﻣﻮﺟﻮﺩﻳﺘﻬﺎﻱ ﻣﺮﺗﺒﻂ ﺁﻭﺭﺩﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬

‫•‬

‫‪ P1‬ﺗﻮﺳﻂ ‪ S1‬ﺗﻬﻴﻪ ﻣﻲ ﺷﻮﺩ‬

‫•‬

‫‪S1‬‬

‫‪ P1‬ﺭﺍ ﺑﻪ ﺗﻌﺪﺍﺩ ‪ ١٠٠‬ﺗﻬﻴﻪ ﻣﻲ ﻛﻨﺪ‪.‬‬ ‫‪SP‬‬

‫‪Qty‬‬

‫‪P#‬‬ ‫‪P1‬‬

‫‪S#‬‬ ‫‪S1‬‬

‫‪٥٠‬‬

‫‪P2‬‬

‫‪S2‬‬

‫‪٥٥‬‬

‫‪P3‬‬

‫‪S3‬‬

‫‪١٠٠‬‬

‫•‬

‫ﻫﺮ ﺳﻄﺮ ﺩﺭ ﻋﻴﻦ ﺣﺎﻝ ﻛﻪ ﻧﻤﺎﻳﺸﮕﺮ ﻳﻚ ﻣﻮﺟﻮﺩﻳﺖ ﺍﺳﺖ ﺩﺭ ﻋﻴﻦ ﺣﺎﻝ ﻧﻤﺎﻳﺸﮕﺮ ﻳﻚ ﻧﻤﻮﻧﻪ ﺍﺭﺗﺒﺎﻁ ﻧﻴﺰ ﻣﻲ ﺑﺎﺷﺪ‪.‬‬ ‫ﺷﻤﺎﻱ ﺳﺎﺩﻩ ﭘﺎﻳﮕﺎﻩ ﺟﺪﻭﻟﻲ‪:‬‬

‫‪ ( ١‬ﺍﺳﻢ ﺟﺪﻭﻝ ‪ S‬ﺍﺳﺖ‬

‫‪ ( ٢‬ﺍﺳﻢ ﺟﺪﻭﻝ‬

‫ﺳﺘﻮﻧﻬﺎﻳﺶ ‪ S #‬ﻛﺎﺭﺍﻛﺘﺮ‬

‫•‬

‫‪ P‬ﺍﺳﺖ‬

‫ﺳﺘﻮﻧﻬﺎﻳﺶ‬

‫‪ P #‬ﻛﺎﺭﺍﻛﺘﺮ‬

‫‪ Sname‬ﻛﺎﺭﺍﻛﺘﺮ‬

‫‪ Pname‬ﻛﺎﺭﺍﻛﺘﺮ‬

‫‪ Status‬ﻋﺪﺩ ﺻﺤﻴﺢ‬

‫‪ Weight‬ﻋﺪﺩ ﺍﻋﺸﺎﺭﻱ‬

‫‪ City‬ﻛﺎﺭﺍﻛﺘﺮ‬

‫‪ Color‬ﻛﺎﺭﺍﻛﺘﺮ‬

‫ﺷﻨﺎﺳﻪ ﺟﺪﻭﻝ ‪S‬‬

‫‪ S#‬ﺍﺳﺖ‪.‬‬

‫ﺷﻨﺎﺳﻪ ﺟﺪﻭﻝ ‪P‬‬

‫‪ P#‬ﺍﺳﺖ‬

‫‪ ( ٣‬ﺍﺳﻢ ﺟﺪﻭﻝ ‪ S P‬ﺍﺳﺖ‬ ‫ﺳﺘﻮﻧﻬﺎ‬

‫‪ S#‬ﺍﺳﺖ )ﻫﻤﺎﻥ ‪ S#‬ﻛﻪ ﺩﺭ ‪ S‬ﻣﻲ ﺑﺎﺷﺪ(‬ ‫‪ P #‬ﺍﺳﺖ )ﻫﻤﺎﻥ ‪ P#‬ﻛﻪ ﺩﺭ ‪ P‬ﺍﺳﺖ(‬ ‫‪ Q ty‬ﺍﺳﺖ‬

‫ﻧﻜﺘﻪ‪ :‬ﺷﻨﺎﺳﻪ ‪ (S# , P#) SP‬ﺑﺎ ﻫﻢ ﺍﺳﺖ‪.‬‬ ‫‪ – ٢-٣-٧‬ﺩﻳﺪ ﺧﺎﺭﺟﻲ‪:‬‬ ‫ﺩﻳﺪ ﻛﺎﺭﺑﺮ ﺧﺎﺹ ﻧﺴﺒﺖ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺩﺭ ﭘﺎﻳﮕﺎﻩ ﺍﺳﺖ ﺩﺭ ﻣﺤﺪﻭﺩﻩ ﻧﻴﺎﺯﻫﺎﻱ ﺍﻃﻼﻋﺎﺗﻲ ﻣﻮﺭﺩ ﻧﻈﺮﺵ ‪.‬‬ ‫ﺩﻳﺪ ﺧﺎﺭﺟﻲ ﺩﺭ ﺳﻄﺢ ﺧﺎﺭﺟﻲ ﻣﻌﻤﺎﺭﻱ ﺑﺎﻧﻚ ﻣﻄﺮﺡ ﻭ ﺍﺯ ﺳﻄﻮﺡ ﺍﻧﺘﺰﺍﻋﻲ ﺍﺳﺖ‪ .‬ﺩﻳﺪ ﺧﺎﺭﺟﻲ ﻣﺒﺘﻨﻲ ﺑﺮ ﺩﻳﺪ ﺍﺩﺭﺍﻛﻲ ﺍﺳﺖ‬ ‫ﻳﻌﻨـﻲ ﺑﺮ ﺍﺳﺎﺱ ﺩﻳﺪ ﺍﺩﺭﺍﻛﻲ ﺗﻌﺮﻳﻒ ﻣﻲ ﺷﻮﺩ‪ .‬ﺩﻳﺪ ﺧﺎﺭﺟﻲ ﻧﻴﺰ ﺑﺮﺍﻱ ﻣﻌﺮﻓﻲ ﺷﺪﻥ ﻧﻴﺎﺯ ﺑﻪ ﻳﻚ ﺳﺎﺧﺘﺎﺭ ﻳﺎ ﻣﺪﻝ ﺩﺍﺩﻩ ﺍﻱ ﺩﺍﺭﺩ‬ ‫ﻻ ﻫﻤﺎﻥ ﻣﺪﻟﻲ ﺍﺳﺖ ﻛﻪ ﺩﺭ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﺍﺳﺖ‪ .‬ﻳﻌﻨﻲ ﺍﮔﺮ ﻃﺮﺍﺡ ﭘﺎﻳﮕﺎﻩ ﺭﺍ ﺟﺪﻭﻟﻲ ﻣﻲ ﺑﻴﻨﺪ ﻛﺎﺭﺑﺮﺍﻥ ﻧﻴﺰ ﺑﺼﻮﺭﺕ‬ ‫ﻛـﻪ ﻣﻌﻤـﻮ ﹰ‬ ‫ﺟﺪﻭﻟﻲ ﻣﻲ ﺑﻴﻨﻨﺪ‪ .‬ﺩﻳﺪ ﺧﺎﺭﺟﻲ ﻧﻴﺰ ﺑﺎﻳﺪ ﺑﻪ ﻛﻤﻚ ﺍﺣﻜﺎﻣﻲ ﺗﻌﺮﻳﻒ ﺷﻮﺩ ﻛﻪ ﺑﻪ ﺗﻌﺮﻳﻒ ﺁﻥ ﺷﻤﺎﻱ ‪-‬ﺧﺎﺭﺟﻲ ﮔﻮﻳﻨﺪ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠٤ /‬‬

‫ﻣﺜﺎﻝ‪:‬‬ ‫‪Myv3‬‬ ‫‪Sname‬‬ ‫‪City‬‬ ‫‪S2‬‬ ‫ﻗﺰﻭﻳﻦ‬

‫‪Myv1‬‬ ‫‪STA‬‬

‫‪١٠‬‬ ‫‪١٥‬‬

‫‪S#‬‬ ‫‪S1‬‬ ‫‪S2‬‬

‫ﻧﻤﻮﻧﻪ ﺳﺎﺩﻩ ﺷﺪﻩ ﺍﺯ ﺷﻤﺎﻱ ﺧﺎﺭﺟﻲ‬ ‫‪ – ١‬ﺍﺳﻢ ﺩﻳﺪ ‪ myv1‬ﺍﺳﺖ‬ ‫‪ – ٢‬ﺍﻳﻦ ﺩﻳﺪ ﺭﻭﻱ ﺟﺪﻭﻝ ‪ S‬ﺗﻌﺮﻳﻒ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪ – ٣‬ﺳﺘﻮﻧﻬﺎﻳﺶ ‪ S#‬ﻭ ‪ STA‬ﺍﺳﺖ‪.‬‬ ‫‪ – ٤‬ﺳﺘﻮﻥ ‪ S#‬ﺍﺯ ﺳﺘﻮﻥ ‪ S#‬ﻣﺸﺘﻖ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪ – ٥‬ﺳﺘﻮﻥ ‪ STA‬ﺍﺯ ﺳﺘﻮﻥ ‪ Status‬ﻣﺸﺘﻖ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪ – ٦‬ﺷﺮﻁ ﻳﺎ ﺷﺮﺍﻳﻂ ﺩﻳﺪ ‪ C1‬ﻭ ‪ ، C2‬ﻭ …… ﺍﺳﺖ‪.‬‬ ‫ﻻ ﺑﺎﺯﻳﺎﺑﻲ ﺍﺳﺖ‪.‬‬ ‫ﻧﻜﺘﻪ‪ :‬ﻋﻤﺪﺗﹰﺎ ‪ View‬ﻫﺎ ﺗﻌﺮﻳﻒ ﻣﻲ ﺷﻮﻧﺪ ﺗﺎ ﺭﻭﻱ ﺁﻧﻬﺎ ﭘﺮﺱ ﻭ ﺟﻮ )‪ (Quary‬ﺍﻧﺠﺎﻡ ﺷﻮﺩ ﻭ ﭘﺮﺱ ﻭ ﺟﻮ ﻣﻌﻤﻮ ﹰ‬ ‫‪ –٣-٣-٧‬ﺩﻳﺪ ﻳﺎ ﺳﻄﺢ ﺩﺍﺧﻠﻲ‪:‬‬ ‫ﺍﻳـﻦ ﺩﻳـﺪ ﺩﺭ ﺳـﻄﺢ ﺩﺍﺧﻠـﻲ‪ ،‬ﭘﺎﻳـﻴﻦ ﺗﺮﻳﻦ ﺳﻄﺢ ﻣﻌﻤﺎﺭﻱ ﺑﺎﻧﻚ ﻣﻄﺮﺡ ﺍﺳﺖ‪ .‬ﺍﻳﻦ ﺳﻄﺢ‪ ،‬ﺳﻄﺤﻲ ﻭﺍﺳﻂ ﺑﻴﻦ ﻣﺤﻴﻂ ﻓﻴﺰﻳﻜﻲ‬ ‫ﭘﺎﻳﮕﺎﻩ ﻭ ﺳﻄﻮﺡ ﺍﻧﺘﺰﺍﻋﻲ ﺁﻥ ﻣﻲ ﺑﺎﺷﺪ ﻛﻪ ‪ DBMS‬ﺑﻪ ﻣﺴﺎﺋﻞ ﻭ ﺟﻨﺒﻪ ﻫﺎﻱ ﻣﺨﺘﻠﻒ ﻓﺎﻳﻠﻴﻨﮓ ﻣﻲ ﭘﺮﺩﺍﺯﺩ‪ .‬ﺍﻟﺒﺘﻪ ﺗﺎ ﺣﺪﻱ ﻧﻈﺎﺭﺕ‬ ‫ﻭ ﺩﺧﺎﻟـﺖ ‪ DBA‬ﻧﻴـﺰ ﺩﺭ ﺁﻥ ﻧﻘـﺶ ﺩﺍﺭﺩ‪ .‬ﻛـﻪ ﻣﻴـﺰﺍﻥ ﺩﺧﺎﻟﺖ ﻭ ﻣﺤﺪﻭﺩﻩ ﺍﺧﺘﻴﺎﺭﺍﺕ ‪ DBA‬ﺩﺭ ﺳﻴﺴﺘﻢ ﻫﺎﻱ ﻣﺨﺘﻠﻒ ﻣﺘﻔﺎﻭﺕ‬ ‫ﺍﺳـﺖ‪ .‬ﺩﻳـﺪ ﺩﺍﺧﻠـﻲ ﺑـﻪ ﻭﺳﻴﻠﻪ ﺷﻤﺎﻱ ﺩﺍﺧﻠﻲ ﺗﻮﺻﻴﻒ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﻧﻪ ﺗﻨﻬﺎ ﺍﻧﻮﺍﻉ ﻣﺨﺘﻠﻒ ﺭﻛﻮﺭﺩﻫﺎﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺭﺍ ﺗﻌﺮﻳﻒ‬ ‫ﻣﻲ ﻛﻨﺪ ﺑﻠﻜﻪ ﻣﺸﺨﺺ ﻣﻲ ﻛﻨﺪ ﭼﻪ ﺷﺎﺧﺼﻬﺎﻳﻲ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ﻭ ﻓﻴﻠﺪﻫﺎﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﭼﮕﻮﻧﻪ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬ ‫‪ HL – ٤-٣-٧‬ﺯﺑﺎﻥ ﻣﻴﺰﺑﺎﻥ‪:‬‬ ‫ﻳﻜـﻲ ﺍﺯ ﺯﺑﺎﻧﻬﺎﻱ ﻣﺘﻌﺎﺭﻑ ﺳﻄﺢ ﺑﺎﻻﺳﺖ‪ .‬ﺑﺮﺍﻱ ﺑﺮﻧﺎﻣﻪ ﻧﻮﻳﺴﺎﻥ ﻛﺎﺭﺑﺮﺩﻱ ﺍﻳﻦ ﺯﺑﺎﻥ ﻣﻲ ﺗﻮﺍﻧﺪ ﻳﻜﻲ ﺍﺯ ﺯﺑﺎﻧﻬﺎﻱ ‪ ، C ++‬ﺟﺎﻭﺍ ﻭ‬ ‫ﻳـﺎ ﺯﺑﺎﻥ ﺍﺧﺘﺼﺎﺻﻲ ﺑﺎﺷﺪ ﻛﻪ ﺑﻪ ﺯﺑﺎﻧﻬﺎﻱ ﺍﺧﺘﺼﺎﺻﻲ ﺍﻏﻠﺐ ﺯﺑﺎﻧﻬﺎﻱ ﻧﺴﻞ ﭼﻬﺎﺭﻡ ﻧﻴﺰ ﮔﻔﺘﻪ ﻣﻲ ﺷﻮﺩ‪ ،‬ﺯﺑﺎﻥ ﻣﻴﺰﺑﺎﻥ ﻣﺴﺌﻮﻝ ﺗﻬﻴﻪ ﻭ‬ ‫ﺗـﺪﺍﺭﻙ ﺍﻣﻜﺎﻧـﺎﺕ ﻣـﺘﻌﺪﺩ ﻏﻴـﺮ ﺑﺎﻧـﻚ ﺍﻃﻼﻋﺎﺗﻲ ﻧﻈﻴﺮ ﻣﺘﻐﻴﺮﻫﺎﻱ ﻣﺤﻠﻲ‪ ،‬ﻋﻤﻠﻴﺎﺕ ﻣﻔﻬﻮﻣﻲ ﻭ ﻣﻨﻄﻖ ﺗﺼﻤﻴﻢ ﮔﻴﺮﻱ ﻭ ﻏﻴﺮﻩ ﻣﻲ‬ ‫ﺑﺎﺷﺪ‪.‬‬ ‫‪ DSL –٥-٣-٧‬ﺯﺑﺎﻥ ﺩﺍﺩﻩ ﺍﻱ ﻓﺮﻋﻲ‪:‬‬ ‫ﻫـﺮ ‪ DBMS‬ﻳـﻚ ‪ DSL‬ﺩﺍﺭﺩ‪ DSL .‬ﻣﺠﻤﻮﻋﻪ ﺍﺣﻜﺎﻣﻲ ﺍﺳﺖ ﺑﺮﺍﻱ ﺗﻌﺮﻳﻒ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﻛﺎﺭ ﺑﺎ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﻛﻨﺘﺮﻝ ﺁﻧﻬﺎ‪ .‬ﻫﺮ ﺯﺑﺎﻥ‬ ‫ﻼ ﺗﺮﻛﻴﺒﻲ ﺍﺯ ﺍﺣﻜﺎﻡ ﺯﻳﺮ ﺍﺳﺖ‪:‬‬ ‫ﺩﺍﺩﻩ ﻓﺮﻋﻲ ﻣﺸﺨﺺ ﻋﻤ ﹰ‬ ‫‪ – ١‬ﺍﺣﻜﺎﻡ ﺗﻌﺮﻳﻒ ﺩﺍﺩﻩ ﻫﺎ )‪Data Definition Language (DDL‬‬ ‫‪ – ٢‬ﺍﺣﻜﺎﻡ ﺗﻌﺮﻳﻒ ﻛﺎﺭ ﺑﺎ ﺩﺍﺩﻩ ﻫﺎ )‪Data Manipulation Language (DML‬‬ ‫‪ – ٣‬ﺍﺣﻜﺎﻡ ﻛﻨﺘﺮﻝ ﻛﺎﺭ ﺑﺎ ﺩﺍﺩﻩ ﻫﺎ )‪Data Control Language (DCL‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠٥ /‬‬

‫ﻫـﺮ ﻳـﻚ ﺍﺯ ﺍﻳـﻦ ﺳـﻪ ﺩﺳـﺘﻪ ﺍﺣﻜﺎﻡ ﺑﺎﻳﺪ ﺑﺮﺍﻱ ﺳﻄﻮﺡ ﺳﻪ ﮔﺎﻧﻪ ﭘﺎﻳﮕﺎﻩ ﻧﻴﺰ ﻭﺟﻮﺩ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪ DSL .‬ﻫﺎ ﺭﺍ ﺍﺯ ﻧﻈﺮ ﻧﻴﺎﺯ ﻳﺎ ﻋﺪﻡ‬ ‫ﻧﻴﺎﺯ ﺑﻪ ﺯﺑﺎﻥ ﻣﻴﺰﺑﺎﻥ ﺑﻪ ﺩﻭ ﺩﺳﺘﻪ ﻣﺴﺘﻘﻞ ﻭ ﺍﺩﻏﺎﻡ ﺷﺪﻧﻲ ﺗﻘﺴﻴﻢ ﻣﻲ ﻛﻨﻨﺪ‪.‬‬ ‫ﺯﺑـﺎﻥ ﻓﺮﻋـﻲ ﺩﺍﺩﻩ ﺍﻱ ﻣﺴـﺘﻘﻞ‪ ،‬ﺯﺑﺎﻧـﻲ ﺍﺳـﺖ ﻛﻪ ﺑﻪ ﺯﺑﺎﻥ ﻣﻴﺰﺑﺎﻥ ﻧﻴﺎﺯ ﻧﺪﺍﺭﺩ ﻭ ﺯﺑﺎﻥ ﻓﺮﻋﻲ ﺩﺍﺩﻩ ﺍﻱ ﺍﺩﻏﺎﻡ ﺷﺪﻩ‪ ،‬ﺯﺑﺎﻧﻲ ﺍﺳﺖ ﻛﻪ‬ ‫ﻫﻤـﺮﺍﻩ ﺯﺑﺎﻥ ‪ HL‬ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﺩ‪ .‬ﺑﻪ ﺑﻴﺎﻥ ﺩﻳﮕﺮ ﺍﺣﻜﺎﻡ ﺁﻥ ﺑﺎﻳﺪ ﺑﻪ ﻧﺤﻮﻱ ﺩﺭ ﺍﺣﻜﺎﻡ ﺯﺑﺎﻥ ﺑﺮﻧﺎﻣﻪ ﺳﺎﺯﻱ ﺍﺩﻏﺎﻡ ﺷﻮﻧﺪ‪ .‬ﻣﻜﺎﻧﻴﺰﻡ‬ ‫ﺍﺩﻏﺎﻡ ﺩﺭ ﺳﻴﺴﺘﻢ ﻫﺎﻱ ﻣﺨﺘﻠﻒ ﻣﺘﻔﺎﻭﺕ ﻭ ﺑﻄﻮﺭ ﻛﻠﻲ ﺑﻪ ﺩﻭ ﺻﻮﺭﺕ ﺍﺩﻏﺎﻡ ﺻﺮﻳﺢ ﻭ ﺍﺩﻏﺎﻡ ﺿﻤﻨﻲ ﻭﺟﻮﺩ ﺩﺍﺭﺩ‪.‬‬ ‫ﺩﺭ ﺍﺩﻏـﺎﻡ ﺿـﻤﻨﻲ‪ ،‬ﺍﺣﻜـﺎﻡ ﺯﺑـﺎﻥ ﺩﺍﺩﻩ ﺍﻱ ﺑﻄـﻮﺭ ﺻـﺮﻳﺢ ﺩﺭ ﻣـﺘﻦ ﺯﺑـﺎﻥ ﻣﻴـﺰﺑﺎﻥ ﺟـﺎﻱ ﺩﺍﺩﻩ ﻧﻤـﻲ ﺷـﻮﻧﺪ ﺑﻠﻜﻪ ﺍﺯ ﻃﺮﻳﻖ ﺣﻜﻢ‬ ‫ﻓﺮﺍﺧﻮﺍﻧﻲ ﺑﻜﺎﺭ ﺑﺮﺩﻩ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬ ‫ﺑﺮﺧﻲ ﻧﻜﺎﺕ ﻣﻬﻢ ﺩﺭ ﻣﻮﺭﺩ ‪DSL‬‬

‫•‬

‫ﻫﺮ ‪ DBMS‬ﺩﺍﺭﺍﻱ ﻳﻚ ‪ DSL‬ﺍﺳﺖ‪.‬‬

‫•‬

‫ﻫـﺮ ‪ DSL‬ﺩﺭ ﻛـﺎﺩﺭ ﻣﻔﺎﻫـﻴﻢ ﻳـﻚ ﻣـﺪﻝ ﺩﺍﺩﻩ ﺍﻱ ﻣﺸـﺨﺺ ﻃﺮﺍﺣـﻲ ﻣـﻲ ﺷﻮﺩ ﻭ ﻋﻤﻠﮕﺮﻫﺎﻱ ﺁﻥ ﻧﻴﺰ ﺩﺭ ﻛﺎﺩﺭ ﻫﻤﺎﻥ‬ ‫ﻣﻔﺎﻫﻴﻢ ﻋﻤﻞ ﻣﻲ ﻛﻨﻨﺪ‪.‬‬

‫•‬

‫ﻼ ﺑﺮﺍﻱ ﺍﻧﺠﺎﻡ ﻋﻤﻞ ﺩﺭﺝ ﻛﻪ ﻣﻨﻄﻘﹰﺎ ﻳﻚ ﺣﻜﻢ ﻭﺍﺣﺪ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‬ ‫ﺍﺻـﻞ ﻭﺣـﺪﺕ ﺍﺣﻜﺎﻡ ﺩﺭ ﺁﻥ ﺭﻋﺎﻳﺖ ﺷﺪﻩ ﺑﺎﺷﺪ‪ .‬ﻣﺜ ﹰ‬ ‫ﻭ ﺗﺮﺟﻴﺤﹰﺎ ﻫﻤﺎﻥ ﺣﻜﻢ ﻭﺍﺣﺪ ﺩﺭ ﺳﻄﺢ ﺧﺎﺭﺟﻲ ﻭ ﻫﻢ ﺩﺭ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﻋﻤﻞ ﻧﻤﺎﻳﺪ‪.‬‬

‫‪ –٦-٣-٧‬ﻧﮕﺎﺷﺖ‪Mapping :‬‬

‫ﻋﻼﻭﻩ ﺑﺮ ﺳﻪ ﺳﻄﺢ ﺍﺯ ﻣﻌﻤﺎﺭﻱ‪ ،‬ﻣﻌﻤﺎﺭﻱ ﭘﺎﻳﮕﺎﻩ ﺍﺯ ﭼﻨﺪ ﻧﮕﺎﺷﺖ )ﺗﺒﺪﻳﻞ( ﻣﺨﺘﻠﻒ ﺗﺸﻜﻴﻞ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪-١–٦-٣-٧‬ﻧﮕﺎﺷﺖ ﻣﻔﻬﻮﻣﻲ‪ /‬ﺩﺍﺧﻠﻲ‪:‬‬ ‫ﺗﻨﺎﻇـﺮ ﺑـﻴﻦ ﺩﻳـﺪ ﺍﺩﺭﺍﻛـﻲ ﻭ ﺑﺎﻧـﻚ ﺍﻃﻼﻋﺎﺗـﻲ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺭﺍ ﺗﻌﺮﻳﻒ ﻭ ﻣﺸﺨﺺ ﻣﻲ ﻛﻨﺪ ﻛﻪ ﭼﮕﻮﻧﻪ ﺭﻛﻮﺭﺩﻫﺎﻱ ﺍﺩﺭﺍﻛﻲ ﻭ‬ ‫ﻓﻴﻠﺪﻫﺎ ﺩﺭ ﺳﻄﺢ ﺩﺍﺧﻠﻲ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﺷﻮﻧﺪ‪.‬‬ ‫‪-٢–٦-٣-٧‬ﻧﮕﺎﺷﺖ ﺧﺎﺭﺟﻲ‪ /‬ﺍﺩﺭﺍﻛﻲ‪:‬‬ ‫ﺗﻨﺎﻇـﺮ ﺑـﻴﻦ ﺩﻳـﺪ ﺧﺎﺭﺟـﻲ ﺧـﺎﺹ ﻭ ﺩﻳـﺪ ﻣﻔﻬﻮﻣـﻲ ﺭﺍ ﺗﻌـﺮﻳﻒ ﻣـﻲ ﻛﻨﺪ‪ .‬ﺩﺭ ﻭﺍﻗﻊ ﻣﻜﺎﻧﻴﺴﻤﻲ ﺍﺳﺖ ﺑﺮﺍﻱ ﺑﺮﻗﺮﺍﺭﻱ ﺗﻨﺎﻇﺮ ﺑﻴﻦ‬ ‫ﺩﻳﺪﻫﺎﻱ ﺧﺎﺭﺟﻲ ﻣﺨﺘﻠﻒ ﻭ ﺩﻳﺪ ﻭﺍﺣﺪ ﺍﺩﺭﺍﻛﻲ‪ DBMS .‬ﻫﺎﻱ ﻣﺘﻌﺎﺭﻑ ﺣﺪﺍﻗﻞ ﺩﻭ ﻣﺤﻮﺭ ﺗﺒﺪﻳﻞ ﺩﺍﺭﻧﺪ‪ :‬ﺗﺒﺪﻳﻞ ﺩﺍﺩﻩ ﻭ ﺗﺒﺪﻳﻞ‬ ‫ﺍﺣﻜﺎﻡ‪.‬‬ ‫•‬

‫ﺗـﺒﺪﻳﻞ ﺩﺍﺩﻩ ﻫﺎ ﻳﻌﻨﻲ ﺗﺒﺪﻳﻞ ﺩﺍﺩﻩ ﻫﺎﻱ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺩﺭ ﺳﻄﺢ ﺧﺎﺭﺟﻲ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎﻱ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺩﺭ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﻭ‬ ‫ﺑﺎﻻﺧﺮﻩ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎﻱ ﺗﻌﺮﻳﻒ ﺷﺪﻩ ﺩﺭ ﺳﻄﺢ ﺩﺍﺧﻠﻲ‪.‬‬

‫•‬

‫ﺗـﺒﺪﻳﻞ ﺍﺣﻜﺎﻡ ﻳﻌﻨﻲ ﺗﺒﺪﻳﻞ ﺣﻜﻢ ﻋﻤﻞ ﻛﻨﻨﺪﻩ ﺩﺭ ﺳﻄﺢ ﺧﺎﺭﺟﻲ ﺑﻪ ﺣﻜﻢ ﻋﻤﻞ ﻛﻨﻨﺪﻩ ﺩﺭ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﻭ ﺩﺭ ﻧﻬﺎﻳﺖ‬ ‫ﺑﻪ ﺣﻜﻢ ﻳﺎ ﺍﺣﻜﺎﻣﻲ ﺩﺭ ﺳﻄﺢ ﺩﺍﺧﻠﻲ‪ .‬ﺍﻳﻦ ﺗﺒﺪﻳﻞ ﺍﺯ ﺟﻤﻠﻪ ﻭﻇﺎﻳﻒ ﻣﻬﻢ ﻫﺮ ﺳﻴﺴﺘﻢ ﻣﺪﻳﺮﻳﺖ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺍﺳﺖ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠٦ /‬‬

‫‪ –٧-٣-٧‬ﺳﻴﺴﺘﻢ ﻣﺪﻳﺮﻳﺖ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ‪:‬‬ ‫ﺳﻴﺴـﺘﻢ ﻣﺪﻳـﺮﻳﺖ ﺑﺎﻧـﻚ ﺍﻃﻼﻋﺎﺗﻲ ﻧﺮﻡ ﺍﻓﺰﺍﺭﻱ ﺍﺳﺖ ﻛﻪ ﻣﺪﻳﺮﻳﺖ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺭﺍ ﻋﻬﺪﻩ ﺩﺍﺭ ﺍﺳﺖ ﻭ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺳﺖ‬ ‫ﺍﺯ ﺑـﺮﻧﺎﻣﻪ ﻫﺎ ﻛﻪ ﻭﺍﺳﻂ ﺑﻴﻦ ﻛﺎﺭﺑﺮﺍﻥ ﻭ ﻣﺤﻴﻂ ﻓﻴﺰﻳﻜﻲ ﺫﺧﻴﺮﻩ ﻭ ﺑﺎﺯﻳﺎﺑﻲ ﻣﻲ ﺑﺎﺷﻨﺪ‪ .‬ﺍﻳﻦ ﻧﺮﻡ ﺍﻓﺰﺍﺭ ﻭﺍﺳﻂ ﺑﻪ ﻛﺎﺭﺑﺮﺍﻥ ﺍﻣﻜﺎﻥ ﻣﻲ‬ ‫ﺩﻫﺪ ﺗﺎ ﺩﺍﺩﻩ ﻫﺎﻱ ﺧﻮﺩ ﺭﺍ ﺗﻌﺮﻳﻒ ﻛﻨﻨﺪ ﻭ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎﻱ ﺧﻮﺩ ﺩﺳﺘﻴﺎﺑﻲ ﺩﺍﺷﺘﻪ ﻭ ﺑﺎ ﺁﻧﻬﺎ ﻛﺎﺭ ﻛﻨﻨﺪ‪.‬‬ ‫•‬

‫ﺍﺟﺰﺍﺀ ﺗﺸﻜﻴﻞ ﺩﻫﻨﺪﻩ ‪:DBMS‬‬

‫ﺍﻟﻒ( ﺑﺨﺶ ﻫﺴﺘﻪ ﺍﻱ ‪ Kernel‬ﺷﺎﻣﻞ‪:‬‬ ‫‪ – ١‬ﭘﻴﺶ ﻛﺎﻣﭙﺎﻳﻠﺮ‬ ‫‪ – ٢‬ﭘﺮﺩﺍﺯﺷﮕﺮ ﭘﺮﺱ ﻭ ﺟﻮ‬ ‫‪ – ٣‬ﺑﻬﻴﻨﻪ ﺳﺎﺯ ﭘﺮﺱ ﻭ ﺟﻮ‬ ‫‪ – ٤‬ﻣﺪﻳﺮﻳﺖ ﻓﺎﻳﻠﻬﺎ )ﺑﺮﺍﻱ ﺳﻄﺢ ﺩﺍﺧﻠﻲ(‬ ‫‪ – ٥‬ﻭﺍﺣﺪ ﺩﺭﻳﺎﻓﺖ ﺩﺭﺧﻮﺍﺳﺖ ﻛﺎﺭﺑﺮ ﻭ ﺍﻧﺠﺎﻡ ﻣﻘﺪﻣﺎﺕ ﻛﺎﺭ‬ ‫‪ -٦‬ﻭﺍﺣﺪ ﻟﻮﺩ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ‬ ‫ﺏ( ﺑﺨﺶ ﻣﺪﻳﺮﻳﺘﻲ ﻣﺤﻴﻂ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ‪:‬‬ ‫‪ – ١‬ﻭﺍﺣﺪ ﻛﻨﺘﺮﻝ ﻫﻤﺰﻣﺎﻧﻲ ﻋﻤﻠﻴﺎﺕ‬ ‫‪ – ٢‬ﻭﺍﺣﺪ ﻛﻨﺘﺮﻝ ﺟﺎﻣﻌﻴﺖ ﭘﺎﻳﮕﺎﻩ‬ ‫‪ – ٣‬ﻭﺍﺣﺪ ﻛﻨﺘﺮﻝ ﺍﻳﻤﻨﻲ ﭘﺎﻳﮕﺎﻩ‬ ‫‪ – ٤‬ﻭﺍﺣﺪ ﻛﻨﺘﺮﻝ ﺗﺮﻣﻴﻢ ﭘﺎﻳﮕﺎﻩ‬ ‫‪ -٥‬ﻭﺍﺣﺪ ﺗﻮﻟﻴﺪ ﻧﺴﺨﻪ ﻫﺎﻱ ﭘﺸﺘﻴﺒﺎﻥ‬ ‫ﺝ( ﺑﺨﺶ ﺍﻣﻜﺎﻧﺎﺕ ﺟﺎﻧﺒﻲ‪:‬‬ ‫‪ -١‬ﺍﻣﻜﺎﻧﺎﺕ ﭘﺮﺱ ﻭ ﺟﻮ ﺑﻪ ﻛﻤﻚ ﻣﺜﺎﻝ ﻭ ﺑﻪ ﻛﻤﻚ ﻓﺮﻡ‬ ‫ﻻ ﻣﻮﺭﺩ ﺍﺳﺘﻔﺎﺩﻩ ‪ DBA‬ﻫﺴﺘﻨﺪ‬ ‫‪ – ٢‬ﺭﻭﺍﻟﻬﺎﻱ ﻣﺨﺼﻮﺹ ﺗﺠﺰﻳﻪ ﻭ ﺗﺤﻠﻴﻞ ﺁﻣﺎﺭﻱ ﻛﻪ ﻣﻌﻤﻮ ﹰ‬ ‫‪ – ٣‬ﺍﺑﺰﺍﺭ ﻫﺎﻱ ﺍﻳﺠﺎﺩ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ‬ ‫‪ – ٤‬ﻧﺮﻡ ﺍﻓﺰﺍﺭﻫﺎﻱ ﻣﺨﺼﻮﺹ ﻣﺤﻴﻂ ﺷﺒﻜﻪ ﺍﻱ‬ ‫‪ – ٥‬ﺍﻣﻜﺎﻧﺎﺕ ﮔﺮﺍﻓﻴﻜﻲ‬ ‫‪ – ٦‬ﺍﻣﻜﺎﻧﺎﺕ ﺩﺳﺘﻴﺎﺑﻲ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎﻱ ﺩﻭﺭ ‪.‬‬ ‫ﺍﻳـﻨﻜﻪ ﺳﻴﺴﺘﻢ ﻣﺪﻳﺮﻳﺖ ﺑﺎﻧﻚ ﭼﮕﻮﻧﻪ ﺩﺭﺧﻮﺍﺳﺘﻬﺎﻱ ﻛﺎﺭﺑﺮﺍﻥ ﺭﺍ ﻋﻤﻠﻲ ﻣﻲ ﺳﺎﺯﺩ ﺑﺴﺘﮕﻲ ﺑﻪ ﻧﻮﻉ ﺁﻥ ﺩﺍﺭﺩ‪ .‬ﺑﻄﻮﺭ ﺧﻼﺻﻪ ﻧﺤﻮﻩ‬ ‫ﺍﺟﺮﺍﻱ ﺩﺭﺧﻮﺍﺳﺖ ﻛﺎﺭﺑﺮ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﻣﻲ ﺑﺎﺷﺪ‪:‬‬ ‫‪ – ١‬ﺩﺭﻳﺎﻓﺖ ﺩﺭﺧﻮﺍﺳﺖ ﻛﺎﺭﺑﺮ ﻭ ﺍﻧﺠﺎﻡ ﺑﺮﺭﺳﻲ ﻫﺎﻱ ﺍﻭﻟﻴﻪ )ﻣﻌﺘﺒﺮ ﺑﻮﺩﻥ ﻛﺎﺭﺑﺮ(‬ ‫‪ - ٢‬ﺑﺮﺭﺳﻲ ﻭ ﺗﺤﻠﻴﻞ ﺩﺭﺧﻮﺍﺳﺖ ﻛﺎﺭﺑﺮ‬ ‫‪ – ٣‬ﺑﺮﺭﺳﻲ ﺷﻤﺎﻱ ﺧﺎﺭﺟﻲ ﻛﺎﺭﺑﺮ ﺑﺮﺍﻱ ﻣﺸﺨﺺ ﺷﺪﻥ ﻣﺤﺪﻭﺩﻩ ﺩﻳﺪ ﻛﺎﺭﺑﺮ ﺍﺯ ﭘﺎﻳﮕﺎﻩ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠٧ /‬‬

‫‪ – ٤‬ﺑﺮﺭﺳﻲ ﺷﻤﺎﻱ ﺍﺩﺭﺍﻛﻲ ﺑﺮﺍﻱ ﺗﻌﻴﻴﻦ ﻧﺤﻮﻩ ﻧﮕﺎﺷﺖ ﻋﻤﻠﻴﺎﺕ ﺳﻄﺢ ﺧﺎﺭﺟﻲ ﺑﻪ ﺍﺩﺭﺍﻛﻲ‬ ‫‪ – ٥‬ﺍﻧﺠﺎﻡ ﺗﺒﺪﻳﻼﺕ ﻻﺯﻡ‬ ‫‪ – ٦‬ﺑﺮﺭﺳﻲ ﺷﻤﺎﻱ ﺩﺍﺧﻠﻲ ﻭ ﺗﺒﺪﻳﻞ ﺍﺣﻜﺎﻡ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﺑﻪ ﺳﻄﺢ ﺩﺍﺧﻠﻲ‬ ‫‪ – ٧‬ﺩﺳﺘﻴﺎﺑﻲ ﺑﻪ ﻓﺎﻳﻠﻬﺎﻱ ﻓﻴﺰﻳﻜﻲ ﻭ ﺍﺟﺮﺍﻱ ﺩﺭﺧﻮﺍﺳﺖ ﻛﺎﺭﺑﺮ‬ ‫•‬

‫ﺍﺻﻄﻼﺡ ﺑﻪ ﻋﻴﻨﻴﺖ ﺩﺭﺁﻭﺭﺩﻥ )‪(materialized‬‬

‫ﺍﮔـﺮ ﺩﺭﺧﻮﺍﺳﺖ ﻛﺎﺭﺑﺮ ﺑﺎﺯﻳﺎﺑﻲ ﺑﺎﺷﺪ ﺍﺻﻄﻼﺣﹰﺎ ﮔﻮﻳﻨﺪ ‪ DBMS‬ﺩﺍﺩﻩ ﻫﺎﻱ ﻣﻮﺭﺩ ﻧﻈﺮ ﺭﺍ ﺑﻪ ﻋﻴﻨﻴﺖ ﺩﺭ ﻣﻲ ﺁﻭﺭﺩ ﻛﻪ ﺑﻪ ﺩﻭ ﻓﺮﻡ‬ ‫ﻭﺟﻮﺩ ﺩﺍﺭﺩ‪:‬‬ ‫‪ – ١‬ﺑـﻪ ﻋﻴﻨﻴﺖ ﺩﺭ ﺁﻭﺭﺩﻥ ﻣﺴﺘﻘﻴﻢ‪ :‬ﻣﻮﻗﻌﻴﺘﻲ ﻛﻪ ﺩﺍﺩﻩ ﻣﻮﺭﺩ ﻧﻈﺮ ﻛﺎﺭﺑﺮ ﺁﻧﭽﻪ ﺩﺭ ﺭﻛﻮﺭﺩ ﺧﺎﺭﺟﻲ ﺧﻮﺍﺳﺘﻪ ﻣﺘﻨﺎﻇﺮ ﺯﻳﺮﻳﻦ ﺩﺍﺷﺘﻪ‬ ‫ﺑﺎﺷﺪ ﻳﻌﻨﻲ ﻣﺸﺨﺼﹰﺎ ﺩﺭ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﻣﺘﻨﺎﻇﺮ ﺩﺍﺷﺘﻪ ﺑﺎﺷﺪ‪.‬‬ ‫ﺭﻛﻮﺭﺩ ﺧﺎﺭﺟﻲ‬ ‫‪M‬‬

‫‪A‬‬

‫‪D‬‬

‫ﺭﻛﻮﺭﺩ ﺍﺩﺭﺍﻛﻲ‬

‫‪ – ٢‬ﻏﻴﺮ ﻣﺴﺘﻘﻴﻢ‪:‬‬

‫‪A B C D E F G H K‬‬

‫ﻣﻮﻗﻌﻴﺘﻲ ﻛﻪ ﺩﺍﺩﻩ ﻣﻮﺭﺩ ﻧﻈﺮﻛﺎﺭﺑﺮ ﻓﻴﻠﺪ ﻳﺎ ﻓﻴﻠﺪﻫﺎﻱ ﻣﺘﻨﺎﻇﺮ ﺯﻳﺮﻳﻦ ﻧﺪﺍﺷﺘﻪ ﺑﺎﺷﺪ ﺑﻠﻜﻪ ﺣﺎﺻﻞ ﭘﺮﺩﺍﺯﺵ ﺑﺎﺷﺪ‬ ‫ﻣﺜﺎﻝ‪ :‬ﻓﻴﻠﺪ ﻣﻴﺎﻧﮕﻴﻦ ﻣﻘﺎﺩﻳﺮ ﻳﻚ ﻓﻴﻠﺪ )ﻓﻴﻠﺪ ﻫﺎﻱ ﻣﺠﺎﺯﻱ(‬ ‫‪ –٨-٣-٧‬ﻣﺪﻳﺮ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ‪: DBA‬‬ ‫ﻻ ﺩﺭ ﭘﺮﻭﮊﻩ ﻫﺎﻱ‬ ‫ﻓـﺮﺩﻱ ﺍﺳـﺖ ﺑـﺎ ﺗﺨﺼـﺺ ﺑـﺎﻻ ﺩﺭ ﺗﻜﻨﻮﻟﻮﮊﻱ ﺑﺎﻧﻜﻬﺎﻱ ﺍﻃﻼﻋﺎﺗﻲ ﻭ ﺩﺍﻧﺶ ﻭ ﻓﻦ ﻛﺎﻣﭙﻴﻮﺗﺮ‪ .‬ﺍﻳﻦ ﻓﺮﺩ ﻣﻌﻤﻮ ﹰ‬ ‫ﺑـﺰﺭﮒ ﺗﻴﻤـﻲ ﺍﺯ ﺍﻓـﺮﺍﺩ ﻣﺘﺨﺼـﺺ ﺩﺭ ﺍﺧﺘـﻴﺎﺭ ﺩﺍﺭﺩ ﻭ ﻭﻇـﻴﻔﻪ ﻛﻠﻲ ﺗﻴﻢ ﻃﺮﺍﺣﻲ‪ ،‬ﺍﻳﺠﺎﺩ‪ ،‬ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ‪ ،‬ﻧﮕﻬﺪﺍﺭﻱ ﻭ ﮔﺴﺘﺮﺵ ﻭ‬ ‫ﺍﺩﺍﺭﻩ ﺑﺎﻧـﻚ ﺑـﺮﺍﻱ ﻳـﻚ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﺍﺳﺖ‪ .‬ﺍﻣﺮﻭﺯ ﺑﻪ ﺳﺒﺐ ﺍﻫﻤﻴﺖ ﺑﺴﻴﺎﺭ ﺑﺎﻻﻱ ﺩﺍﺩﻩ ﺩﺭ ﺳﺎﺯﻣﺎﻧﻬﺎ‪ ،‬ﺩﺍﺩﻩ ﻫﺎﻱ ﻳﻚ ﺳﺎﺯﻣﺎﻥ‬ ‫ﻧﻴﺎﺯ ﺑﻪ ﺍﺩﺍﺭﻩ ﻛﻨﻨﺪﻩ ﺩﺍﺭﻧﺪ ﻳﻌﻨﻲ ﻓﺮﺩﻱ ﺑﺎ ﺳﻤﺖ ﺍﺩﺍﺭﻩ ﻛﻨﻨﺪﻩ ﺩﺍﺩﻩ ﻫﺎ ﻳﺎ ﺑﻪ ﺍﺧﺘﺼﺎﺭ )‪ . (DA‬ﺍﻳﻦ ﻓﺮﺩ ﻛﻪ ﻟﺰﻭﻣﹰﺎ ﻧﺒﺎﻳﺪ ﻣﺘﺨﺼﺺ‬ ‫ﺩﺭ ﻛﺎﻣﭙﻴﻮﺗـﺮ ﻭ ﻳﺎ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺑﺎﺷﺪ ﻣﺪﻳﺮﻳﺖ ﻛﻞ ﺩﺍﺩﻩ ﻫﺎﻱ ﺳﺎﺯﻣﺎﻥ ﺭﺍ ﺑﺮ ﻋﻬﺪﻩ ﺩﺍﺭﺩ ﻭ ﺑﺎ ﻫﻤﺎﻫﻨﮕﻲ ﺑﺎ ﻣﺪﻳﺮﻳﺖ ﺳﺎﺯﻣﺎﻥ‪،‬‬ ‫ﺧﻂ ﻣﺸﻲ ﻫﺎ ﻭ ﺗﺼﻤﻴﻤﺎﺗﻲ ﺩﺭ ﻣﻮﺭﺩ ﺩﺍﺩﻩ ﻫﺎﻱ ﻣﺆﺳﺴﻪ ﺧﻮﺩ ﺭﺍ ﺍﺗﺨﺎﺫ ﻣﻲ ﻛﻨﺪ‪.‬‬ ‫ﺩﺭ ﻣﺪﻳﺮﻳﺖ ﺳﺎﺯﻣﺎﻥ ﻭﻗﺘﻲ ﺍﺯ ﺳﺮﻣﺎﻳﻪ ﺳﺎﺯﻣﺎﻥ ﺑﺤﺚ ﻣﻲ ﻛﻨﻨﺪ ﻣﻲ ﮔﻮﻳﻨﺪ ﺍﺯ ﭘﻨﺞ ﺑﺨﺶ ﺗﺸﻜﻴﻞ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﻧﺮﻡ ﺍﻓﺰﺍﺭ‪ ،‬ﺳﺨﺖ ﺍﻓﺰﺍﺭ‪ ،‬ﻧﻴﺮﻭﻱ ﻣﺘﺨﺼﺺ‪ ،‬ﺑﻮﺩﺟﻪ ﻭ ﺩﺍﺩﻩ‪.‬‬ ‫ﻭ ﺍﻣـﺎ ﻭﻇﺎﻳﻒ ﺍﺩﺍﺭﻩ ﻛﻨﻨﺪﻩ ﺑﺎﻧﻚ ﺩﺭ ﻃﻴﻔﻲ ﺍﺯ ﻭﻇﺎﻳﻒ ﻣﺪﻳﺮﻳﺘﻲ ﺗﺎ ﻭﻇﺎﻳﻒ ﻓﻨﻲ ﻭ ﻋﻠﻤﻲ ﺟﺎﻱ ﺩﺍﺭﺩ‪ .‬ﺩﺭ ﻭﺍﻗﻊ ﻣﻲ ﺗﻮﺍﻥ ‪DBA‬‬

‫ﺭﺍ ﺑﻌـﻨﻮﺍﻥ ﺗﻴﻤـﻲ ﺗﺨﺼﺼـﻲ ﺑـﻪ ﺳﺮﭘﺮﺳـﺘﻲ ‪) DBA‬ﻣﺪﻳﺮ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ( ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺖ ﻛﻪ ﺑﺎ ﻣﺘﺨﺼﺺ ﻫﺎﻳﻲ ﻧﻈﻴﺮ ‪، DA‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠٨ /‬‬

‫ﻣﺴـﺌﻮﻝ ﻣﺴـﺘﻘﻴﻢ ﺗـﻴﻢ ﻫـﺎﻱ ﺑـﺮﻧﺎﻣﻪ ﺳـﺎﺯﻱ‪ ،‬ﻣﺪﻳـﺮ ﻛﻨﺘـﺮﻝ ﻛﻨـﻨﺪﻩ ﻋﻤﻠﻜـﺮﺩ ﺧﻮﺩ ﺳﻴﺴﺘﻢ ﻭ … ﺩﺭ ﺧﺼﻮﺹ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ‬ ‫ﻫﻤﻜﺎﺭﻱ ﺩﺍﺭﻧﺪ‪.‬‬ ‫ﺑﻄﻮﺭ ﻛﻠﻲ ﻣﻲ ﺗﻮﺍﻥ ﻭﻇﺎﻳﻒ ‪ DBA‬ﺭﺍ ﺑﻪ ﺷﺮﺡ ﺯﻳﺮ ﺑﻴﺎﻥ ﻧﻤﻮﺩ‪:‬‬ ‫‪ – ١‬ﻫﻤﻜﺎﺭﻱ ﺑﺎ ‪ DA‬ﺩﺭ ﺗﻔﻬﻴﻢ ﺍﻫﻤﻴﺖ ﻭ ﻧﻘﺶ ﺩﺍﺩﻩ ﺳﺎﺯﻣﺎﻥ‪.‬‬ ‫‪ – ٢‬ﻫﻤﻜﺎﺭﻱ ﺩﺭ ﻣﻌﺮﻓﻲ ﺗﻜﻨﻮﻟﻮﮊﻱ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﻭ ﺟﻨﺒﻪ ﻫﺎﻱ ﻣﺨﺘﻠﻒ ﺍﺭﺟﺤﻴﺖ ﺁﻥ ﺑﺮ ﺗﻜﻨﻮﻟﻮﮊﻱ ﻏﻴﺮ ﺑﺎﻧﻜﻲ‬ ‫‪ – ٣‬ﺗﻼﺵ ﺩﺭ ﻣﺠﺎﺏ ﻛﺮﺩﻥ ﺳﺎﺯﻣﺎﻥ ﺩﺭ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺗﻜﻨﻮﻟﻮﮊﻱ ﻛﺎﺭﺍ ﺗﺮ‬ ‫‪ – ٤‬ﻣﻄﺎﻟﻌﻪ ﺩﻗﻴﻖ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ ﻭ ﺗﺸﺨﻴﺺ ﻧﻴﺎﺯﻫﺎﻱ ﻛﺎﺭﺑﺮﺍﻥ ﻣﺨﺘﻠﻒ‬ ‫‪ – ٥‬ﺑﺎﺯﺷﻨﺎﺳﻲ ﻣﻮﺟﻮﺩﻳﺖ ﻫﺎ ﻭ ﺍﺭﺗﺒﺎﻃﺎﺕ ﺑﻴﻦ ﺁﻧﻬﺎ ﻭ ﺗﻌﻴﻴﻦ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻫﺮ ﻳﻚ ﺍﺯ ﺍﻧﻮﺍﻉ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ‬ ‫‪ – ٦‬ﺭﺳﻢ ﻧﻤﻮﺩﺍﺭ ‪E-R‬‬

‫‪ – ٧‬ﺗﺨﻤﻴﻦ ﺣﺠﻢ ﺍﻃﻼﻋﺎﺕ ﺫﺧﻴﺮﻩ ﺷﺪﻧﻲ ﺩﺭ ﺑﺎﻧﻚ‬ ‫‪ – ٨‬ﻣﺸﺎﺭﻛﺖ ﺩﺭ ﺗﻌﻴﻴﻦ ﺳﻴﺴﺘﻢ ﻣﺪﻳﺮﻳﺖ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺍﻣﻜﺎﻧﺎﺕ ﻛﺎﻣﭙﻴﻮﺗﺮﻱ ﻭ ﻣﺤﻴﻂ‬ ‫‪ – ٩‬ﻣﺸـﺎﻭﺭﻩ ﻭ ﻣﺸـﺎﺭﻛﺖ ﺩﺭ ﺗﻌﻴـﻴﻦ ﺳﻴﺴـﺘﻢ ﻛﺎﻣﭙﻴﻮﺗـﺮﻱ ﻭ ﭘﻴﻜـﺮﺑﻨﺪﻱ ﺁﻥ ﺍﺯ ﻟﺤـﺎﻅ ﻣﻠﺰﻭﻣﺎﺕ ﺳﺨﺖ ﺍﻓﺰﺍﺭﻱ ﻭ ﻧﺮﻡ ﺍﻓﺰﺍﺭﻱ‬ ‫ﺳﻴﺴﺘﻢ ﻋﺎﻣﻞ‬ ‫‪ – ١٠‬ﻃﺮﺍﺣﻲ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﺑﺎﻧﻚ ﻭ ﻧﻮﺷﺘﻦ ﺷﻤﺎﻱ ﺍﺩﺭﺍﻛﻲ‬ ‫‪ – ١١‬ﺍﻳﺠﺎﺩ ﭘﺎﻳﮕﺎﻩ ﺑﺎ ﺩﺍﺩﻩ ﻫﺎﻱ ﺗﺴﺘﻲ‬ ‫‪ – ١٢‬ﺗﻌﺮﻳﻒ ﺩﻳﺪﻫﺎﻱ ﺧﺎﺭﺟﻲ ﻛﺎﺭﺑﺮﺍﻥ ﺑﺮﻧﺎﻣﻪ ﺳﺎﺯ‬ ‫‪ – ١٣‬ﻧﻈﺎﺭﺕ ﺩﺭ ﻧﻮﺷﺘﻦ ﺷﻤﺎﻱ ﺧﺎﺭﺟﻲ‬ ‫‪ – ١٤‬ﻧﻈﺎﺭﺕ ﺩﺭ ﺟﻤﻊ ﺍﻭﺭﻱ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﻭﺭﻭﺩ ﺩﺍﺩﻩ ﻫﺎ‬ ‫‪ – ١٥‬ﺗﺴﺖ ﭘﺎﻳﮕﺎﻩ ﺑﺎ ﺩﺍﺩﻩ ﻫﺎﻱ ﻭﺍﻗﻌﻲ )ﺁﻏﺎﺯ ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ ﭘﺎﻳﮕﺎﻩ(‬ ‫‪ – ١٦‬ﺗﻌﻴﻴﻦ ﺿﻮﺍﺑﻂ ﺩﺳﺘﻴﺎﺑﻲ ﺑﻪ ﺑﺎﻧﻚ ﺑﺮﺍﻱ ﻛﺎﺭﺑﺮﺍﻥ ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﻧﻴﺎﺯﻫﺎﻱ ﺍﻃﻼﻋﺎﺗﻲ ﺁﻧﻬﺎ‬ ‫‪ – ١٧‬ﻧﻈﺎﺭﺕ ﻭ ﺩﺧﺎﻟﺖ ﺩﺭ ﺗﻬﻴﻪ ﻣﺴﺘﻨﺪﺍﺕ ﺳﻴﺴﺘﻢ‬ ‫‪ – ١٨‬ﺗﺄﻣﻴﻦ ﺟﺎﻣﻌﻴﺖ ﺑﺎﻧﻚ ﺍﺯ ﻃﺮﻳﻖ ﺣﻔﻆ ﻛﻴﻔﻴﺖ‪ ،‬ﻛﻨﺘﺮﻝ ﺩﺳﺘﻴﺎﺑﻲ ﻭ ﺣﻔﺎﻇﺖ ﺍﺯ ﻣﺤﺮﻣﺎﻧﮕﻲ ﻣﺤﺘﻮﺍﻱ ﺑﺎﻧﻚ‬ ‫‪ – ١٩‬ﻛﻤﻚ ﺑﻪ ﻛﺎﺭﺑﺮﺍﻥ ﻭ ﺁﻣﻮﺯﺵ ﺁﻧﺎﻥ ﺩﺭ ﺑﺮﻧﺎﻣﻪ ﺭﻳﺰﻱ ﺩﺭ ﺩﺳﺘﻴﺎﺑﻲ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﻛﺎﺭ ﺑﺎ ﺁﻧﻬﺎ‬ ‫‪ – ٢٠‬ﺣﻔﻆ ﺍﻳﻤﻨﻲ ﺑﺎﻧﻚ‬ ‫‪ – ٢١‬ﭘﻴﺶ ﺑﻴﻨﻲ ﺭﻭﺷﻬﺎﻱ ﺗﺮﻣﻴﻢ ﻭ ﺍﺳﺘﺮﺍﺗﮋﻱ ﻻﺯﻡ ﺑﺮﺍﻱ ﭘﺸﺘﻴﺒﺎﻧﻲ‬ ‫‪ – ٢٢‬ﻣﻌﺎﺻﺮ ﻧﮕﻪ ﺩﺍﺷﺘﻦ ﭘﺎﻳﮕﺎﻩ ﺑﺎ ﭘﻴﺸﺮﻓﺘﻬﺎﻱ ﺗﻜﻨﻮﻟﻮﮊﻳﻚ‬ ‫‪ – ٢٣‬ﺗﻼﺵ ﺩﺭ ﺟﻬﺖ ﺍﺭﺗﻘﺎﺀ ﺳﻄﺢ ﺗﺨﺼﺼﻲ ﺍﻓﺮﺍﺩ ﻭ ﻛﺎﺭﺑﺮﺍﻥ‬ ‫‪ – ٢٤‬ﻧﻈﺎﺭﺕ ﺑﻪ ﻛﺎﺭﺍﻳﻲ ﻭ ﭘﺎﺳﺦ ﺑﻪ ﺗﻐﻴﻴﺮ ﻧﻴﺎﺭﻫﺎ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫•‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٠٩ /‬‬

‫ﺩﻳﻜﺸﻨﺮﻱ ﺩﺍﺩﻩ ﻫﺎ )ﻛﺎﺗﺎﻟﻮﮒ ﺳﻴﺴﺘﻢ (‬

‫ﻳﻚ ‪ DBMS‬ﺑﺮﺍﻱ ﺍﻧﺘﺨﺎﺏ ﻧﺤﻮﻩ ﺍﺟﺮﺍﻱ ﻋﻤﻠﻴﺎﺕ ﺭﻭﻱ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺗﺤﺖ ﻛﻨﺘﺮﻝ ﺧﻮﺩ ﺍﻃﻼﻋﺎﺗﻲ ﺭﺍ ﺍﺯ ﺁﻥ ﺑﺎﻧﻚ ﺗﺤﺖ‬ ‫ﻋـﻨﻮﺍﻥ ﻛﺎﺗﺎﻟﻮﮒ ﺳﻴﺴﺘﻢ ﻧﮕﻬﺪﺍﺭﻱ ﻣﻲ ﻛﻨﺪ‪ .‬ﺩﺭ ﻭﺍﻗﻊ ﻛﺎﺗﺎﻟﻮﮒ ﺟﺎﺋﻲ ﺍﺳﺖ ﻛﻪ ﺗﻤﺎﻡ ﺷﻤﺎﻫﺎﻱ ﻣﺨﺘﻠﻒ ) ﺧﺎﺭﺟﻲ ‪ ،‬ﻣﻔﻬﻮﻣﻲ‬ ‫ﻭ ﺩﺍﺧﻠـﻲ ( ﻭ ﺗﻤـﺎﻡ ﻧﮕﺎﺷـﺘﻬﺎﻱ ﻣﺘﻨﺎﻇﺮ ﺑﺎ ﺁﻧﻬﺎ ﺩﺭ ﺁﻥ ﻧﮕﻬﺪﺍﺭﻱ ﻣﻲ ﺷﻮﻧﺪ‪ .‬ﺑﻪ ﺑﻴﺎﻥ ﺩﻳﮕﺮ ﻛﺎﺗﺎﻟﻮﮒ ﺷﺎﻣﻞ ﺍﻃﻼﻋﺎﺕ ﺗﻔﻀﻴﻠﻲ )‬ ‫ﻛﻪ ﮔﺎﻩ ﻓﺮﺍ ﺩﺍﺩﻩ ﻧﺎﻣﻴﺪﻩ ﻣﻲ ﺷﻮﻧﺪ ( ﻣﺮﺑﻮﻁ ﺑﻪ ﺍﺷﻴﺎﺀ ﻣﺘﻌﺪﺩﻱ ﺍﺳﺖ ﻛﻪ ﺩﺭ ﺧﻮﺩ ﺳﻴﺴﺘﻢ ﻗﺮﺍﺭ ﺩﺍﺭﻧﺪ ‪.‬‬ ‫ﺑﻄﻮﺭ ﻛﻠﻲ ﺍﻃﻼﻋﺎﺕ ﺯﻳﺮ ﺩﺭ ﺁﻥ ﻧﮕﻬﺪﺍﺭﻱ ﻣﻲ ﺷﻮﺩ ‪:‬‬ ‫ﻼ ﻧﺎﻡ ﺟﺪﺍﻭﻝ ﺩﺭ ﺑﺎﻧﻚ ﺭﺍﺑﻄﻪ ﺍﻱ‬ ‫ﻧﺎﻡ ﺳﺎﺧﺘﺎﺭﻫﺎﻱ ﺩﺍﺩﻩ ﺍﻱ ﺩﺭ ﭼﺎﺭﭼﻮﺏ ﻣﺪﻝ ﺩﺍﺩﻩ ﺍﻱ ﻣﺸﺨﺺ ﻣﺜ ﹰ‬ ‫ﻧﺎﻡ ﻣﻮﺟﻮﺩﻳﺘﻬﺎ ﻭ ﺍﺭﺗﺒﺎﻃﺎﺕ ﺑﻴﻦ ﺁﻧﻬﺎ‬ ‫ﻧﺎﻡ ﺻﻔﺎﺕ ﺧﺎﺻﻪ ﻫﺮ ﻣﻮﺟﻮﺩﻳﺖ‪ ،‬ﻧﻮﻉ ﻭ ﻃﻴﻒ ﻣﻘﺎﺩﻳﺮ‬ ‫ﺷﻤﺎﻫﺎﻱ ﺧﺎﺭﺟﻲ ﻛﺎﺭﺑﺮﺍﻥ‬ ‫ﺷﻤﺎﻱ ﺍﺩﺭﺍﻛﻲ‬ ‫ﻣﺸﺨﺼﺎﺕ ﻓﻨﻲ ﻛﺎﺭﺑﺮﺍﻥ ﻭ ﭼﮕﻮﻧﮕﻲ ﺣﻖ ﺩﺳﺘﻴﺎﺑﻲ ﺍﻧﻬﺎ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﻣﺤﺪﻭﺩﻩ ﻋﻤﻠﻴﺎﺕ ﻣﺠﺎﺯ ﺁﻧﻬﺎ‬ ‫ﺭﻭﻳﻪ ﻫﺎﻱ ﺗﺒﺪﻳﻞ ﺑﻴﻦ ﺳﻄﻮﺡ ﻣﺨﺘﻠﻒ‬ ‫ﺗﺎﺭﻳﺦ ﺍﻳﺠﺎﺩ ﺩﺍﺩﻩ ﻫﺎ‬ ‫‪ -٤-٧‬ﺩﻻﻳﻞ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ‪Why Database ? :‬‬

‫‪ -١-٤-٧‬ﻣﺰﺍﻳﺎﻱ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﭼﻨﺪ ﻛﺎﺭﺑﺮﻱ ‪:‬‬ ‫‪ – ١‬ﺍﻣﻜﺎﻥ ﻣﺪﻟﺴﺎﺯﻱ ﺩﺍﺩﻩ ﻫﺎﻱ ﻋﻤﻠﻴﺎﺗﻲ ﺑﺮ ﺍﺳﺎﺱ ﺳﻤﺎﻧﺘﻴﻚ ﺁﻧﻬﺎ‬ ‫‪ – ٢‬ﻭﺣﺪﺕ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﻛﻞ ﺩﺍﺩﻩ ﻫﺎﻱ ﻣﺤﻴﻂ ﻋﻤﻠﻴﺎﺗﻲ‬ ‫ﻭﺟـﻮﺩ ﺳـﻄﺢ ﺍﺩﺭﺍﻛﻲ ﺩﺭ ﻣﻌﻤﺎﺭﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﺍﻣﻜﺎﻥ ﻣﻲ ﺩﻫﺪ ﺗﺎ ﻛﻞ ﺩﺍﺩﻩ ﻫﺎﻱ ﻋﻤﻠﻴﺎﺗﻲ ﻳﻜﺒﺎﺭ ﺁﻧﮕﻮﻧﻪ ﻛﻪ ﻃﺮﺍﺡ ﻣﻲ ﺑﻴﻨﺪ‬ ‫ﺗﻌﺮﻳﻒ ﻭ ﺫﺧﻴﺮﻩ ﺷﻮﻧﺪ‪ .‬ﺍﻳﻦ ﻭﺣﺪﺕ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﺩﺭ ﻋﻴﻦ ﺗﻌﺪﺩ ﻧﺸﺎﻧﺪﻫﻨﺪﻩ ﺩﻳﺪﻫﺎﻱ ﻛﺎﺭﺑﺮﺍﻥ ﺍﺳﺖ‪.‬‬ ‫‪ – ٣‬ﺍﺷﺘﺮﺍﻛﻲ ﺷﺪﻥ ﺩﺍﺩﻩ ﻫﺎ‬ ‫ﺍﻣﻜﺎﻥ ﺍﺳﺘﻔﺎﺩﻩ ﻛﺎﺭﺑﺮﺍﻥ ﺍﺯ ﺩﺍﺩﻩ ﻭﺍﺣﺪ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺑﺼﻮﺭﺕ ﺍﺷﺘﺮﺍﻛﻲ‬ ‫‪ – ٤‬ﻛﺎﻫﺶ ﻣﻴﺰﺍﻥ ﺍﻓﺰﻭﻧﮕﻲ‬ ‫‪ – ٥‬ﺗﻀﻤﻴﻦ ﺟﺎﻣﻌﻴﺖ ﺩﺍﺩﻩ ﻫﺎ‬ ‫‪ – ٦‬ﺍﻣﻜﺎﻥ ﺍﻋﻤﺎﻝ ﺿﻮﺍﺑﻂ ﺩﻗﻴﻖ ﺍﻳﻤﻨﻲ‬ ‫ﺳﻴﺴﺘﻢ ﻣﺪﻳﺮﻳﺖ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺑﺎ ﺍﻋﻤﺎﻝ ﻛﻨﺘﺮﻝ ﻣﺘﻤﺮﻛﺰ ﺍﺯ ﻫﺮﮔﻮﻧﻪ ﺍﻗﺪﺍﻡ ﺑﺮﺍﻱ ﺩﺳﺘﻴﺎﺑﻲ ﻏﻴﺮ ﻣﺠﺎﺯ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎ ﺟﻠﻮﮔﻴﺮﻱ ﻣﻲ‬ ‫ﻛﻨﺪ‬ ‫‪ – ٧‬ﺍﻣﻜﺎﻥ ﺗﺮﻣﻴﻢ ﺩﺍﺩﻩ ﻫﺎ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١٠ /‬‬

‫ﺳﻴﺴـﺘﻢ ﻣﺪﻳـﺮﻳﺖ ﺑﺎﻧـﻚ ﺍﻃﻼﻋﺎﺗـﻲ ﺑـﺎ ﻣﻜﺎﻧﻴﺴﻢ ﻫﺎﻳﻲ ﺧﺴﺎﺭﺕ ﻧﺎﺷﻲ ﺍﺯ ﺑﺮﻭﺯ ﻧﻘﺺ ﻫﺎ ﻭ ﺍﺷﺘﺒﺎﻫﺎﺕ ﺭﺍ ﺟﺒﺮﺍﻥ ﻛﺮﺩﻩ ﻭ ﺩﺍﺩﻩ ‪-‬‬ ‫ﻫﺎﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺭﺍ ﺗﺮﻣﻴﻢ ﻣﻲ ﻛﻨﺪ ﺑﻨﺤﻮﻱ ﻛﻪ ﻣﺤﺘﻮﺍﻱ ﺑﺎﻧﻚ ﻭﺿﻌﻴﺖ ﺻﺤﻴﺢ ﺧﻮﺩ ﺭﺍ ﺑﺎﺯ ﻳﺎﺑﺪ‪.‬‬ ‫‪ – ٨‬ﺗﺄﻣﻴﻦ ﺍﺳﺘﻘﻼﻝ ﺩﺍﺩﻩ ﻫﺎ‬ ‫ﻫﻢ ﺩﻟﻴﻞ ﺍﻳﻦ ﺗﻜﻨﻮﻟﻮﮊﻱ ﻭ ﻫﻢ ﻫﺪﻑ ﺁﻥ ﻣﻲ ﺑﺎﺷﺪ‬ ‫ﺗﻌﺮﻳﻒ ﺍﺳﺘﻘﻼﻝ ﺩﺍﺩﻩ ﺍﻱ‪:‬‬ ‫ﻣﺼﻮﻧﻴﺖ ﺩﻳﺪﻫﺎﻱ ﻛﺎﺭﺑﺮﺍﻥ ﻭ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﺩﺭ ﻗﺒﺎﻝ ﺗﻐﻴﻴﺮﺍﺗﻲ ﻛﻪ ﺩﺭ ﺳﻄﻮﺡ ﻣﻌﻤﺎﺭﻱ ﭘﺎﻳﮕﺎﻩ ﭘﺪﻳﺪ ﻣﻲ ﺁﻳﻨﺪ‪.‬‬ ‫ﺍﺳﺘﻘﻼﻝ ﺩﺍﺩﻩ ﺍﻱ ﺩﻭ ﻭﺟﻪ ﺩﺍﺭﺩ‪ :‬ﺍﺳﺘﻘﻼﻝ ﺩﺍﺩﻩ ﺍﻱ ﻣﻨﻄﻘﻲ ﻭ ﻓﻴﺰﻳﻜﻲ‬ ‫ﺍﺳـﺘﻘﻼﻝ ﺩﺍﺩﻩ ﺍﻱ ﻓﻴﺰﻳﻜـﻲ ﻳﻌﻨـﻲ ﻣﺼـﻮﻧﻴﺖ ﺩﻳﺪﻫﺎﻱ ﻛﺎﺭﺑﺮﺍﻥ ﻭ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﺩﺭ ﻗﺒﺎﻝ ﺗﻐﻴﻴﺮﺍﺗﻲ ﻛﻪ ﺩﺭ ﺳﻄﺢ ﺩﺍﺧﻠﻲ‬ ‫ﭘﺎﻳﮕـﺎﻩ ﭘﺪﻳـﺪ ﻣﻲ ﺁﻳﻨﺪ‪ ،‬ﺩﺭ ‪ DBMS‬ﻫﺎﻱ ﻭﺍﻗﻌﻲ ﺍﺳﺘﻘﻼﻝ ﺩﺍﺩﻩ ﺍﻱ ﻓﻴﺰﻳﻜﻲ ﺗﻘﺮﻳﺒﹰﺎ ﺻﺪ ﺩﺭ ﺻﺪ ﺍﺳﺖ ﺯﻳﺮﺍ ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﻣﻌﻤﺎﺭﻱ‬ ‫ﭼﻨﺪ ﺳﻄﺤﻲ ﭘﺎﻳﮕﺎﻩ ﻛﺎﺭﺑﺮﺍﻥ ﺩﺭ ﺳﻄﺢ ﺧﺎﺭﺟﻲ ﺩﺭ ﻳﻚ ﻣﺤﻴﻂ ﺍﻧﺘﺰﺍﻋﻲ ﻭ ﻣﻨﻔﻚ ﺍﺯ ﻓﺎﻳﻠﻴﻨﮓ ﻋﻤﻞ ﻣﻲ ﻛﻨﻨﺪ‪.‬‬ ‫ﺍﺳﺘﻘﻼﻝ ﺩﺍﺩﻩ ﺍﻱ ﻣﻨﻄﻘﻲ‪:‬‬ ‫ﻳﻌﻨـﻲ ﻣﺼـﻮﻧﻴﺖ ﺑـﺮﻧﺎﻣﻪ ﺍﻱ ﻛﺎﺭﺑـﺮﺩﻱ ﻭ ﺩﻳﺪ ﻛﺎﺭﺑﺮﺍﻥ ﺩﺭ ﻗﺒﺎﻝ ﺗﻐﻴﻴﺮﺍﺗﻲ ﻛﻪ ﺩﺭ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ ﭘﺪﻳﺪ ﻣﻲ ﺁﻳﻨﺪ‪ .‬ﺗﻐﻴﻴﺮﺍﺕ ﺳﻄﺢ‬ ‫ﺍﺩﺭﺍﻛﻲ ﺍﺯ ﺩﻭ ﺟﻨﺒﻪ ﭘﺪﻳﺪ ﻣﻲ ﺁﻳﻨﺪ‪:‬‬ ‫‪ – ١‬ﺍﺯ ﺭﺷﺪ ﭘﺎﻳﮕﺎﻩ ﺩﺭ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ‬ ‫‪ – ٢‬ﺩﺭ ﺳﺎﺯﻣﺎﻧﺪﻫﻲ ﻣﺠﺪﺩ ﺳﻄﺢ ﺍﺩﺭﺍﻛﻲ‬ ‫ﺩﻻﻳﻞ ﺭﺷﺪ ﭘﺎﻳﮕﺎﻩ‪:‬‬ ‫ﻣﻄﺮﺡ ﺷﺪﻥ ﻧﻴﺎﺯﻫﺎﻱ ﺟﺪﻳﺪ ﺑﺮﺍﻱ ﻛﺎﺭﺑﺮﺍﻥ‬ ‫ﻣﻄﺮﺡ ﺷﺪﻥ ﻛﺎﺭ ﺑﺮﺍﻧﻲ ﺟﺪﻳﺪ ﺑﺎ ﻧﻴﺎﺯﻫﺎﻱ ﺍﻃﻼﻋﺎﺗﻲ ﺟﺪﻳﺪ‬ ‫ﺩﻻﻳﻞ ﺳﺎﺯﻣﺎﻧﺪﻫﻲ ﻣﺠﺪﺩ‪:‬‬ ‫ﺗﺄﻣﻴﻦ ﻣﺤﻴﻂ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ ﻛﺎﺭﺍﺗﺮ ﺑﺮﺍﻱ ﺑﺨﺸﻲ ﺍﺯ ﭘﺎﻳﮕﺎﻩ‬ ‫ﺗﺄﻣﻴﻦ ﺍﻳﻤﻨﻲ ﺑﻴﺸﺘﺮ ﺑﺮﺍﻱ ﭘﺎﻳﮕﺎﻩ‬ ‫ﺗﺄﻣﻴﻦ ﻛﺎﺭﺍﻳﻲ ﻋﻤﻠﻴﺎﺗﻲ ﺑﻴﺸﺘﺮ ﺑﺮﺍﻱ ‪ DBMS‬ﺍﺯ ﻃﺮﻳﻖ ﻛﺎﻫﺶ ﺁﻧﻮﻣﺎﻟﻲ ﻫﺎ‬ ‫‪ – ٩‬ﺗﺴﺮﻳﻊ ﺩﺭ ﺩﺭﻳﺎﻓﺖ ﭘﺎﺳﺦ ﭘﺮﺱ ﻭ ﺟﻮﻫﺎ‬ ‫‪ – ١٠‬ﺗﺴﻬﻴﻞ ﺩﺭ ﺩﺭﻳﺎﻓﺖ ﮔﺰﺍﺭﺷﻬﺎﻱ ﻣﺘﻨﻮﻉ ﺁﻣﺎﺭﻱ‬ ‫‪ – ١١‬ﺍﻣﻜﺎﻥ ﺍﻋﻤﺎﻝ ﺍﺳﺘﺎﻧﺪﺍﺭﺩﻫﺎ‬ ‫ﺑـﺎ ﻛﻨﺘـﺮﻝ ﻣﺘﻤﺮﻛـﺰ ﺭﻭﻱ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ‪ DBA ،‬ﻣﻲ ﺗﻮﺍﻧﺪ ﺍﻃﻤﻴﻨﺎﻥ ﺩﻫﺪ ﻛﻪ ﺗﻤﺎﻡ ﺍﺳﺘﺎﻧﺪﺍﺭﺩﻫﺎﻱ ﻣﻄﻠﻮﺏ ﺩﺭ ﻧﻤﺎﻳﺶ ﺩﺍﺩﻩ ﻫﺎ‬ ‫ﻣـﻮﺭﺩ ﺗـﻮﺟﻪ ﻗـﺮﺍﺭ ﮔـﺮﻓﺘﻪ ﺍﺳـﺖ‪ .‬ﺍﺳـﺘﺎﻧﺪﺍﺭﺩﻫﺎﻱ ﻣﻄﻠـﻮﺏ ﻣﻤﻜﻦ ﺍﺳﺖ ﺣﺎﻭﻱ ﻳﻚ ﻳﺎ ﺗﻤﺎﻡ ﻣﻮﺍﺭﺩ ﺯﻳﺮ ﺑﺎﺷﻨﺪ‪ :‬ﺍﺳﺘﺎﻧﺪﺍﺭﺩﻫﺎﻱ‬ ‫ﺑﺨﺶ‪ ،‬ﺗﺄﺳﻴﺴﺎﺕ‪ ،‬ﺷﺮﻛﺖ‪ ،‬ﺻﻨﻌﺖ‪ ،‬ﻣﻠﻲ ﻭ ﺑﻴﻦ ﺍﻟﻤﻠﻠﻲ‪.‬‬ ‫‪ -١٢‬ﺍﺳﺘﻔﺎﺩﻩ ﺑﻬﺘﺮ ﺍﺯ ﺳﺨﺖ ﺍﻓﺰﺍﺭ‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١١ /‬‬

‫‪ -٢-٤-٧‬ﻣﻌﺎﻳﺐ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ )ﭼﻨﺪ ﻛﺎﺭﺑﺮﻱ(‬ ‫‪ -١‬ﻫﺰﻳﻨﻪ ﺑﺎﻻﻱ ﻧﺮﻡ ﺍﻓﺰﺍﺭ‬ ‫‪ -٢‬ﻫﺰﻳﻨﻪ ﺑﺎﻻﻱ ﺳﺨﺖ ﺍﻓﺰﺍﺭ‬ ‫‪ -٣‬ﻫﺰﻳﻨﻪ ﺑﻴﺸﺘﺮ ﺑﺮﺍﻱ ﺑﺮﻧﺎﻣﻪ ﺳﺎﺯﻱ‬ ‫‪ -٤‬ﻫﺰﻳﻨﻪ ﺑﺎﻻ ﺑﺮﺍﻱ ﺍﻧﺠﺎﻡ ﻣﻬﻨﺪﺳﻲ ﻣﺠﺪﺩ ﺑﻪ ﻣﻨﻈﻮﺭ ﺗﺒﺪﻳﻞ ﺳﻴﺴﺘﻢ ﺍﺯ ﻣﺸﻲ ﻓﺎﻳﻞ ﭘﺮﺩﺍﺯﻱ ﺑﻪ ﻣﺸﻲ ﭘﺎﻳﮕﺎﻫﻲ‬ ‫‪ -٥‬ﭘﻴﭽﻴﺪﻩ ﺑﻮﺩﻥ ﺳﻴﺴﺘﻢ ﻭ ﻧﻴﺎﺯ ﺑﻪ ﺗﺨﺼﺺ ﺑﻴﺸﺘﺮ‬ ‫‪ -٥-٧‬ﻣﻌﻤﺎﺭﻱ ﺳﻴﺴﺘﻢ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ‬ ‫ﻣـﻨﻈﻮﺭ ﺍﺯ ﻣﻌﻤـﺎﺭﻱ ﺳﻴﺴـﺘﻢ ﭘﺎﻳﮕـﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ‪ ،‬ﻧﺤﻮﻩ ﭘﻴﻜﺮﺑﻨﺪﻱ ﺍﺟﺰﺍﻱ ﺳﻴﺴﺘﻤﻲ ﺍﺳﺖ ﻛﻪ ﺩﺭ ﺁﻥ ﺣﺪﺍﻗﻞ ﻳﻚ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ‪،‬‬ ‫ﻳـﻚ ﺳﻴﺴـﺘﻢ ﻣﺪﻳﺮﻳﺖ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ‪،‬ﻳﻚ ﺳﻴﺴﺘﻢ ﻋﺎﻣﻞ ‪ ،‬ﻳﻚ ﻛﺎﻣﭙﻴﻮﺗﺮ ﺑﺎ ﺩﺳﺘﮕﺎﻫﻬﺎﻱ ﺟﺎﻧﺒﻲ ﻭ ﺗﻌﺪﺍﺩﻱ ﻛﺎﺭﺑﺮ ﻭﺟﻮﺩ ﺩﺍﺭﺩﻭ‬ ‫ﺧـﺪﻣﺎﺕ ﭘﺎﻳﮕﺎﻫـﻲ ﺑـﻪ ﻛﺎﺭﺑﺮﺍﻥ ﺍﺭﺍﺋﻪ ﻣﻴﻜﻨﻨﺪ‪.‬ﺍﻳﻦ ﻣﻌﻤﺎﺭﻱ ﺑﺴﺘﮕﻲ ﺑﻪ ﺩﻭ ﻋﻨﺼﺮ ﺍﺻﻠﻲ ﻳﻌﻨﻲ ﺳﺨﺖ ﺍﻓﺰﺍﺭ ﻭ ﻧﺮﻡ ﺍﻓﺰﺍﺭ ﻣﺪﻳﺮﻳﺖ‬ ‫‪ DBMS‬ﺩﺍﺭﺩ‪ .‬ﺑﻄﻮﺭ ﻛﻠﻲ ﭼﻬﺎﺭ ﻣﻌﻤﺎﺭﻱ ﺑﺮﺍﻱ ﺳﻴﺴﺘﻢ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﻭﺟﻮﺩ ﺩﺍﺭﻧﺪ ‪:‬‬ ‫‪ -١‬ﻣﻌﻤﺎﺭﻱ ﻣﺘﻤﺮﻛﺰ‬ ‫‪ -٢‬ﻣﻌﻤﺎﺭﻱ ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ – ﺳﺮﻭﻳﺲ ﮔﻴﺮﻧﺪﻩ‬ ‫‪ -٣‬ﻣﻌﻤﺎﺭﻱ ﺗﻮﺯﻳﻊ ﺷﺪﻩ‬ ‫‪ -٤‬ﻣﻌﻤﺎﺭﻱ ﺑﺎ ﭘﺮﺩﺍﺯﺵ ﻣﻮﺍﺯﻱ‬ ‫‪ -١-٥-٧‬ﻣﻌﻤﺎﺭﻱ ﻣﺘﻤﺮﻛﺰ ‪Centeralized‬‬

‫ﺩﺭ ﺍﻳـﻦ ﻣﻌﻤـﺎﺭﻱ ﻳـﻚ ﭘﺎﻳﮕـﺎﻩ ﺩﺍﺩﻩ ﻫـﺎ ﺭﻭﻱ ﻳـﻚ ﺳﻴﺴـﺘﻢ ﻛﺎﻣﭙﻴﻮﺗـﺮﻱ ﻭ ﺑـﺪﻭﻥ ﺍﺭﺗﺒﺎﻁ ﺑﺎ ﺳﻴﺴﺘﻢ ﻛﺎﻣﭙﻴﻮﺗﺮﻱ ﺩﻳﮕﺮ ﺍﻳﺠﺎﺩ‬ ‫ﻣﻴﺸـﻮﺩ‪ .‬ﺳـﺨﺖ ﺍﻓـﺰﺍﺭ ﺍﻳـﻦ ﺳﻴﺴـﺘﻢ ﻣـﻲ ﺗـﻮﺍﻧﺪ ﻛﺎﻣﭙﻴﻮﺗﺮ ﺷﺨﺼﻲ ‪ ،‬ﻣﺘﻮﺳﻂ ﻭ ﻳﺎ ﺑﺰﺭﮒ ﺑﺎﺷﺪ‪.‬ﺳﻴﺴﺘﻤﻲ ﻛﻪ ﺑﺮ ﺭﻭﻱ ﻛﺎﻣﭙﻴﻮﺗﺮ‬ ‫ﺷﺨﺼﻲ ﺍﻳﺠﺎﺩ ﻣﻲ ﺷﻮﺩ ‪،‬ﺑﻴﺸﺘﺮ ﺑﺮﺍﻱ ﻛﺎﺭﺑﺮﺩﻫﺎﻱ ﻛﻮﭼﻚ ﻭ ﺑﺎ ﺍﻣﻜﺎﻧﺎﺕ ﻣﺤﺪﻭﺩ ﺍﺳﺖ ‪.‬‬ ‫‪ -٢-٥-٧‬ﻣﻌﻤﺎﺭﻱ ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ‪ /‬ﺳﺮﻭﻳﺲ ﮔﻴﺮﻧﺪﻩ ‪CLIENT/SERVER‬‬

‫ﻫـﺮ ﻣﻌﻤـﺎﺭﻱ ﻛـﻪ ﺩﺭ ﺁﻥ ﻗﺴـﻤﺘﻲ ﺍﺯ ﭘـﺮﺩﺍﺯﺵ ﺭﺍ ﻳـﻚ ﺑـﺮﻧﺎﻣﻪ ‪ ،‬ﺳﻴﺴـﺘﻢ ﻭ ﻳﺎ ﻣﺎﺷﻴﻦ ﺍﻧﺠﺎﻡ ﺩﻫﺪ ﻭ ﺍﻧﺠﺎﻡ ﻗﺴﻤﺖ ﺩﻳﮕﺮﻱ ﺍﺯ‬ ‫ﭘﺮﺩﺍﺯﺵ ﺭﺍ ﺍﺯ ﺑﺮﻧﺎﻣﻪ‪ ،‬ﺳﻴﺴﺘﻢ ﻭ ﻳﺎ ﻣﺎﺷﻴﻦ ﺩﻳﮕﺮ ﺑﺨﻮﺍﻫﺪ ﻣﻌﻤﺎﺭﻱ ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ﻭ ﺳﺮﻭﻳﺲ ﮔﻴﺮﻧﺪﻩ ﻧﺎﻣﻴﺪﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺩﺭ ﻭﺍﻗـﻊ ‪ ،‬ﺍﻳﻦ ﻣﻌﻤﺎﺭﻱ ﻳﻚ ﺳﻴﺴﺘﻢ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺭﺍ ﺑﺼﻮﺭﺕ ﻳﻚ ﺳﺎﺧﺘﺎﺭ ﺩﻭﻗﺴﻤﺘﻲ ﺩﺭ ﻧﻈﺮ ﻣﻲ ﮔﻴﺮﺩ ‪ :‬ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ‬ ‫ﻭ ﺳـﺮﻭﻳﺲ ﮔﻴـﺮﻧﺪﻩ‪.‬ﺗﻤـﺎﻡ ﺩﺍﺩﻩ ﻫـﺎ ﺩﺭ ﺑﺨـﺶ ﺳـﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﻭ ﺗﻤﺎﻡ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﺩﺭ ﺑﺨﺶ ﺳﺮﻭﻳﺲ‬ ‫ﮔﻴﺮﻧﺪﻩ ﻗﺮﺍﺭ ﻣﻴﮕﻴﺮﻧﺪ‪.‬‬ ‫ﺍﻟﻒ‪ -‬ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ‪:‬‬ ‫ﻳـﻚ ﺳﻴﺴﺘﻢ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺍﺳﺖ ﻛﻪ ﺍﺯ ﺗﻤﺎﻡ ﻋﻤﻠﻴﺎﺕ ﺍﺻﻠﻲ ﻳﻚ ‪ DBMS‬ﭘﺸﺘﻴﺒﺎﻧﻲ ﻣﻴﻜﻨﺪ‪.‬ﺩﺭ ﻭﺍﻗﻊ ﻣﻴﺘﻮﺍﻥ ﻧﺎﻡ ﺩﻳﮕﺮﻱ‬ ‫ﺑﺮﺍﻱ ‪ DBMS‬ﺭﺍ ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ﻧﻴﺰ ﺑﻄﻮﺭ ﺳﺎﺩﻩ ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺖ‪.‬‬ ‫ﺏ ‪-‬ﺳﺮﻭﻳﺲ ﮔﻴﺮﻧﺪﻩ ‪:‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١٢ /‬‬

‫ﺳـﺮﻭﻳﺲ ﮔﻴـﺮﻧﺪﻩ ﻫـﺎ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﻣﺨﺘﻠﻔﻲ ﻫﺴﺘﻨﺪ ﻛﻪ ﺑﺮ ﺭﻭﻱ ‪ DBMS‬ﻗﺮﺍﺭ ﺩﺍﺭﻧﺪ‪ .‬ﺍﺯ ﻗﺒﻴﻞ ‪ :‬ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ‬ ‫ﻧﻮﺷﺘﻪ ﺷﺪﻩ ﺗﻮﺳﻂ ﻛﺎﺭﺑﺮﺍﻥ ﻭ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ ﺗﻌﺒﻴﻪ ﺷﺪﻩ ﺩﺭ ﺳﻴﺴﺘﻢ‪.‬‬ ‫ﺷﻜﻞ ﺳﺎﺩﻩ ﺷﺪﻩ ﺍﻱ ﺍﺯ ﻣﻌﻤﺎﺭﻱ ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ‪/‬ﺳﺮﻭﻳﺲ ﮔﻴﺮﻧﺪﻩ ﺭﺍ ﺩﺭ ﺯﻳﺮ ﻣﻲ ﺑﻴﻨﻴﺪ ‪:‬‬

‫ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ ﻛﺎﺭﺑﺮﺩﻱ‬

‫‪DBMS‬‬

‫‪client‬‬

‫‪Server‬‬

‫‪DB‬‬

‫ﻣﻌﻤـﺎﺭﻱ ﺳـﺮﻭﻳﺲ ﺩﻫـﻨﺪﻩ ‪ ،‬ﺳـﺮﻭﻳﺲ ﮔﻴـﺮﻧﺪﻩ ﺑﺼـﻮﺭﺗﻬﺎﻱ ﭼـﻨﺪ ﺳﺮﻭﻳﺲ ﮔﻴﺮﻧﺪﻩ ‪ -‬ﻳﻚ ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ‪ ،‬ﻳﻚ ﺳﺮﻭﻳﺲ‬ ‫ﮔﻴﺮﻧﺪﻩ – ﭼﻨﺪ ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ﻭ ﭼﻨﺪ ﺳﺮﻭﻳﺲ ﮔﻴﺮﻧﺪﻩ ‪-‬ﭼﻨﺪ ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ﻧﻴﺰ ﻣﻄﺮﺡ ﺍﺳﺖ‪.‬‬ ‫ﻣﺰﺍﻳﺎﻱ ﺍﻳﻦ ﻣﻌﻤﺎﺭﻱ ﻧﺴﺒﺖ ﺑﻪ ﻣﻌﻤﺎﺭﻱ ﻣﺘﻤﺮﻛﺰ ‪:‬‬ ‫ﺗﻘﺴﻴﻢ ﭘﺮﺩﺍﺯﺵ‬ ‫ﻛﺎﻫﺶ ﺗﺮﺍﻓﻴﻚ ﺷﺒﻜﻪ ﺩﺭ ﻣﻌﻤﺎﺭﻱ ﺣﻮﻝ ﺷﺒﻜﻪ‬ ‫ﺍﺳﺘﻘﻼﻝ ﺍﻳﺴﺘﮕﺎﻩ ﻫﺎﻱ ﻛﺎﺭﻱ‬ ‫ﺍﺷﺘﺮﺍﻙ ﺩﺍﺩﻩ ﻫﺎ‬ ‫‪ -٣-٥-٧‬ﻣﻌﻤﺎﺭﻱ ﺗﻮﺯﻳﻊ ﺷﺪﻩ ‪:‬‬

‫‪Distributed‬‬

‫ﺍﻳـﻦ ﻣﻌﻤـﺎﺭﻱ ﺣﺎﺻـﻞ ﺗـﺮﻛﻴﺐ ﺩﻭ ﺗﻜـﻨﻮﻟﻮﮊﻱ ﺍﺳـﺖ ‪ :‬ﺗﻜـﻨﻮﻟﻮﮊﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﻭ ﺗﻜﻨﻮﻟﻮﮊﻱ ﺷﺒﻜﻪ ‪ .‬ﺩﺭ ﻳﻚ ﻧﮕﺎﻩ ﻛﻠﻲ‬ ‫ﻣﻴﺘﻮﺍﻥ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﺗﻮﺯﻳﻊ ﺷﺪﻩ ﺭﺍ ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺯ ﺩﺍﺩﻩ ﻫﺎﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﻛﻪ ﺍﺯ ﻧﻈﺮ ﻣﻨﻄﻘﻲ ﻣﺘﻌﻠﻖ ﺑﻪ ﻳﻚ ﺳﻴﺴﺘﻢ ﻣﻲ ﺑﺎﺷﻨﺪ‬ ‫ﻭ ﺭﻭﻱ ﺳﺎﻳﺖ ﻫﺎﻱ ﻣﺨﺘﻠﻒ ﻳﻚ ﻳﺎ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﺷﺒﻜﻪ ﺗﻮﺯﻳﻊ ﮔﺮﺩﻳﺪﻩ ﺍﻧﺪ ‪ ،‬ﺩﺭ ﻧﻈﺰ ﮔﺮﻓﺖ‪.‬‬ ‫ﺑﺮﺧﻲ ﻭﻳﮋﮔﻴﻬﺎﻱ ﺍﻳﻦ ﻣﻌﻤﺎﺭﻱ ﻋﺒﺎﺭﺗﻨﺪ ﺍﺯ ‪:‬‬ ‫ﻣﺠﻤﻮﻋﻪ ﺍﻱ ﺍﺳﺖ ﺍﺯ ﺩﺍﺩﻩ ﻫﺎﻱ ﻣﺮﺗﺒﻂ ﻭ ﻣﺸﺘﺮﻙ‬ ‫ﺩﺍﺩﻩ ﻫﺎ ﺑﻪ ﺑﺨﺸﻬﺎﻱ ﺗﻘﺴﻴﻢ ﻭ ﺩﺭ ﺳﺎﻳﺖ ﻫﺎ ﺗﻮﺯﻳﻊ ﺷﺪﻩ ﺍﻧﺪ‪.‬‬ ‫ﺑﻌﻀﻲ ﺍﺯ ﺑﺨﺸﻬﺎ ﻣﻤﻜﻦ ﺍﺳﺖ ﺩﺭ ﭼﻨﺪ ﻧﺴﺨﻪ )ﺑﻄﻮﺭ ﺗﻜﺮﺍﺭﻱ( ﺩﺭ ﺳﺎﻳﺘﻬﺎ ﺫﺧﻴﺮﻩ ﺷﻮﻧﺪ‪.‬‬ ‫ﺳﺎﻳﺘﻬﺎ ﺍﺯ ﻃﺮﻳﻖ ﻳﻚ ﺷﺒﻪ ﺑﺎ ﻫﻢ ﺍﺭﺗﺒﺎﻁ ﺩﺍﺭﻧﺪ‪.‬‬ ‫ﺩﺍﺩﻩ ﻫﺎﻱ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺩﺭ ﻫﺮ ﺳﺎﻳﺖ ﺗﺤﺖ ﻛﻨﺘﺮﻝ ﻳﻚ ‪ DBMS‬ﻣﻲ ﺑﺎﺷﻨﺪ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١٣ /‬‬

‫ﻣﻬﻤﺘـﺮﻳﻦ ﺍﺻـﻞ ﺩﺭ ﺳﻴﺴﺘﻢ ﭘﺎﻳﮕﺎﻫﻲ ﺗﻮﺯﻳﻊ ﺷﺪﻩ ﺍﻳﻦ ﺍﺳﺖ ﻛﻪ ﺳﻴﺴﺘﻢ ﺑﺎﻳﺪ ﭼﻨﺎﻥ ﻋﻤﻞ ﻛﻨﺪ ﻛﻪ ﺍﺯ ﻧﻈﺮ ﻛﺎﺭﺑﺮﺍﻥ ﻣﺸﺎﺑﻪ ﺑﺎ ﻳﻚ‬ ‫ﭘﺎﻳﮕـﺎﻩ ﺩﺍﺩﻩ ﻣﺘﻤﺮﻛﺰ ﺑﺎﺷﺪ‪.‬ﺍﻳﻦ ﻭﻳﮋﮔﻲ ﺗﺤﺖ ﻋﻨﻮﺍﻥ ﺷﻔﺎﻓﻴﺖ ﺩﺭ ﺳﻴﺴﺘﻤﻬـﺎﻱ ﺗﻮﺯﻳﻊ ﺷﺪﻩ ﻣﻄﺮﺡ ﺍﺳﺖ ﻭ ﺗﻔﺎﻭﺕ ﺳﻴﺴﺘﻤﻬﺎﻱ‬ ‫ﺗﻮﺯﻳﻌﻲ ﻭ ﺳﺮﻭﻳﺲ ﮔﻴﺮﻧﺪﻩ – ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ﻧﻴﺰ ﺩﺭ ﻫﻤﻴﻦ ﺍﺳﺖ‪.‬‬ ‫‪ -١ -٣-٥-٧‬ﻣﺰﺍﻳﺎﻱ ﺍﻳﻦ ﻣﻌﻤﺎﺭﻱ‬ ‫ﺳﺎﺯﮔﺎﺭﻱ ﻭ ﻫﻤﺎﻫﻨﮕﻲ ﺑﺎ ﻣﺎﻫﻴﺖ ﺳﺎﺯﻣﺎﻧﻬﺎﻱ ﻧﻮﻳﻦ‬ ‫ﻛﺎﺭﺍﻳﻲ ﺑﻴﺸﺘﺮ ﺩﺭ ﭘﺮﺩﺍﺯﺵ ﺩﺍﺩﻩ ﻫﺎ ﺑﻮﻳﮋﻩ ﺩﺭ ﺳﻴﺴﺘﻤﻬﺎﻱ ﺑﺴﻴﺎﺭ ﺑﺰﺭﮒ‬ ‫ﺩﺳﺘﻴﺎﺑﻲ ﺑﻬﺘﺮ ﺑﻪ ﺩﺍﺩﻩ ﻫﺎ‬ ‫‪-٢-٣-٥-٣‬‬

‫ﻣﻌﺎﻳﺐ‬

‫ﭘﻴﭽﻴﺪﮔﻲ ﻃﺮﺍﺣﻲ ﺳﻴﺴﺘﻢ‬ ‫ﭘﻴﭽﻴﺪﮔﻲ ﭘﻴﺎﺩﻩ ﺳﺎﺯﻱ‬ ‫ﻫﺰﻳﻨﻪ ﺑﻴﺸﺘﺮ‬ ‫‪ -٤-٥-٧‬ﻣﻌﻤﺎﺭﻱ ﺑﺎ ﭘﺮﺩﺍﺯﺵ ﻣﻮﺍﺯﻱ‪Parallel :‬‬

‫ﺍﻳﻦ ﻣﻌﻤﺎﺭﻱ ﺑﺎ ﺳﺎﺧﺖ ﻭ ﮔﺴﺘﺮﺵ ﻣﺎﺷﻴﻨﻬﺎﻱ ﻣﻮﺍﺯﻱ ‪ ،‬ﺑﺮﺍﻱ ﺍﻳﺠﺎﺩ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻫﺎﻱ ﺑﺴﻴﺎﺭ ﺑﺰﺭﮒ ﻣﻮﺭﺩ ﺗﻮﺟﻪ ﻗﺮﺍﺭ ﮔﺮﻓﺖ ‪ .‬ﺍﻳﻦ‬ ‫ﻣﻌﻤﺎﺭﻱ ﮔﺴﺘﺮﺵ ﻳﺎﻓﺘﻪ ﻣﻌﻤﺎﺭﻱ ﺗﻮﺯﻳﻊ ﺷﺪﻩ ﺍﺳﺖ ﻭ ﺑﺮﺍﻱ ﺗﺎﻣﻴﻦ ﻛﺎﺭﺍﻳﻲ ﻭ ﺩﺳﺘﻴﺎﺑﻲ ﺳﺮﻳﻊ ﻃﺮﺍﺣﻲ ﻣﻴﺸﻮﺩ‪ .‬ﺑﺮﺍﻱ ﺍﻳﺠﺎﺩ ﭘﺎﻳﮕﺎﻩ‬ ‫ﺩﺍﺩ ﻫـﺎ ﺑـﺎ ﻣﻌﻤـﺎﺭﻱ ﭘﺮﺩﺍﺯﺵ ﻣﻮﺍﺯﻱ ‪ ،‬ﺑﻄﻮﺭ ﻛﻠﻲ ﭼﻨﺪﻳﻦ ﻃﺮﺡ ﺍﺯ ﺍﻳﻦ ﻣﻌﻤﺎﺭﻱ ﻭﺟﻮﺩ ﺩﺍﺭﺩ ﻛﻪ ﻣﻄﺎﻟﻌﻪ ﺁﻧﻬﺎ ﺧﺎﺭﺝ ﺍﺯ ﻣﻄﺎﻟﺐ‬ ‫ﺍﻳﻦ ﺩﺭﺱ ﺍﺳﺖ‪:‬‬ ‫ﻣﻌﻤﺎﺭﻱ ﺑﺎ ﺣﺎﻓﻈﻪ ﻣﺸﺘﺮﻙ‬ ‫ﻣﻌﻤﺎﺭﻱ ﺑﺎ ﺩﻳﺴﻚ ﻣﺸﺘﺮﻙ‬ ‫ﻣﻌﻤﺎﺭﻱ ﺳﻠﺴﻠﻪ ﻣﺮﺍﺗﺒﻲ‬ ‫‪ -٦-٧‬ﺳﻴﺴﺘﻢ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎﻱ ﻫﻤﺮﺍﻩ ‪Mobile Database System‬‬

‫ﺑـﺎ ﺭﺷـﺪ ﺳـﺮﻳﻊ ﺗﻜـﻨﻮﻟﻮﮊﻱ ﺍﺭﺗـﺒﺎﻃﺎﺕ ‪ ،‬ﻧـﻮﻉ ﺟﺪﻳـﺪﻱ ﺍﺯ ﺳﻴﺴـﺘﻢ ﭘﺎﻳﮕـﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ﭘﺪﻳﺪ ﺁﻣﺪﻩ ﻭ ﺩﺭ ﺣﺎﻝ ﮔﺴﺘﺮﺵ ﺍﺳﺖ ﻛﻪ‬ ‫ﺳﻴﺴـﺘﻤﻬﺎﻱ ﭘﺎﻳﮕـﺎﻩ ﺩﺍﺩﻩ ﻫﻤـﺮﺍﻩ ﻧﺎﻣـﻴﺪﻩ ﻣﻴﺸـﻮﻧﺪ‪ .‬ﺩﺭ ﺍﻳـﻦ ﻣﻌﻤـﺎﺭﻱ ‪ ،‬ﻳـﻚ ﻳﺎ ﺑﻴﺶ ﺍﺯ ﻳﻚ ﻛﺎﻣﭙﻴﻮﺗﺮ ﻣﺘﻮﺳﻂ ﻳﺎ ﺑﺰﺭﮒ ﻧﻘﺶ‬ ‫ﺳـﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ﺭﺍ ﺍﻳﻔﺎ ﻣﻴﻜﻨﺪ‪ .‬ﻫﺮ ﻛﺎﺑﺮﺑﺮ ﻛﺎﻣﭙﻴﻮﺗﺮ ﻛﻮﭼﻚ ﻫﻤﺮﺍﻩ ﺧﻮﺩ ﺭﺍ ﺩﺍﺭﺩ ﻛﻪ ﺩﺭ ﺁﻥ ﺩﺍﺩﻩ ﻫﺎﻱ ﻋﻤﻠﻴﺎﺗﻲ ﻭ ﺑﺮﻧﺎﻣﻪ ﻫﺎﻱ‬ ‫ﻛﺎﺭﺑـﺮﺩﻱ ﻣـﻮﺭﺩ ﻧـﻴﺎﺯﺵ ﺫﺧﻴـﺮﻩ ﺷـﺪﻩ ﺍﻧﺪ‪.‬ﻛﺎﺭﺑﺮ ﻣﻴﺘﻮﺍﻧﺪ ﺍﺯ ﻫﺮ ﺟﺎﻳﻲ ﺑﺎ ﺳﻴﺴﺘﻢ ﺳﺮﻭﻳﺲ ﺩﻫﻨﺪﻩ ﻣﻮﺭﺩ ﻧﻈﺮﺵ ﻣﺮﺗﺒﻂ ﺑﻮﺩﻩ ﻭ‬ ‫ﭘﺮﺩﺍﺯﺵ ﻫﺎﻱ ﻣﻮﺭﺩ ﻧﻈﺮﺵ ﺭﺍ ﺍﻧﺠﺎﻡ ﺩﻫﺪ‪.‬‬ ‫ﻣﻮﺿﻮﻋﺎﺕ ﺗﺤﻘﻴﻘﺎﺗﻲ‪:‬‬ ‫‪ -١‬ﺑﻪ ﻧﻈﺮ ﺷﻤﺎ ﭼﻪ ﻋﻮﺍﻣﻠﻲ ﺩﺭ ﺍﻧﺘﺨﺎﺏ ﻳﻚ ‪ DBMS‬ﻧﻘﺶ ﺩﺍﺭﻧﺪ ؟‬ ‫‪ -٢‬ﻳﻚ ‪ DBMS‬ﺭﺍﺑﻄﻪ ﺍﻱ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﮔﺮﻓﺘﻪ ﻭ ﺍﺟﺰﺍﻱ ﺁﻥ ﺭﺍ ﺑﺮﺭﺳﻲ ﻧﻤﺎﻳﻴﺪ‪.‬‬ ‫‪ODBC -٣‬‬ ‫‪JDBC -٤‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﺗﻤﺮﻳﻨﺎﺕ ﺍﻳﻦ ﻓﺼﻞ‪:‬‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١٤ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١٥ /‬‬

‫ﻓﺼﻞ ﻫﺸﺘﻢ ‪ :‬ﺗﺮﻣﻴﻢ‬ ‫‪-١-٨‬ﺗﻌﺮﻳﻒ ﺗﺮﻣﻴﻢ‬ ‫ﺗـﺮﻣﻴﻢ ‪ :‬ﻳﻌﻨـﻲ ﺍﻣﻜـﺎﻥ ﺗﺸـﺨﻴﺺ ﺍﺷـﻜﺎﻻﺕ ﺍﺣﺘﻤﺎﻟـﻲ ﺍﻳﺠﺎﺩ ﺷﺪﻩ ﺩﺭ ﺣﻴﻦ ﺍﺟﺮﺍﻱ ﺑﺮﻧﺎﻣﻪ ﻭ ﺑﺎﺯﺳﺎﺯﻱ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﻛﻪ‬ ‫ﻻ ﺩﺭ ﺍﺛﺮ ﺑﺮﻭﺯ ﺍﺷﻜﺎﻝ ﺩﺭ ﺳﻴﺴﺘﻢ ﻧﺎﻗﺺ ﺷﺪﻩ ﺍﺳﺖ‪ .‬ﺑﺮﺍﻱ ﺗﺸﺨﻴﺺ ﺍﺷﻜﺎﻝ ﻭ ﺗﺮﻣﻴﻢ ﺑﺎﻧﻚ ﺩﻭ ﻛﺎﺭ ﺑﺎﻳﺴﺘﻲ ﺍﻧﺠﺎﻡ ﺷﻮﺩ‪:‬‬ ‫ﺍﺣﺘﻤﺎ ﹼ‬ ‫ﺍﻟﻒ ‪ :‬ﺍﻗﺪﺍﻣﺎﺕ ﻗﺒﻞ ﺍﺯ ﺑﺮﻭﺯ ﻣﺸﻜﻞ‬ ‫ﻭﻗﺘﻲ ﺑﺮﻧﺎﻣﻪ ﺍﺟﺮﺍﻱ ﻋﺎﺩﻱ ﺧﻮﺩ ﺭﺍ ﺍﻧﺠﺎﻡ ﻣﻲ ﺩﻫﺪ ﺑﺎﻳﺪ ‪ DBMS‬ﻳﻜﺴﺮﻱ ﺍﻃﻼﻋﺎﺕ ﺭﺍ ﺫﺧﻴﺮﻩ ﻛﻨﺪ ﺗﺎ ﺍﮔﺮ ﻣﺸﻜﻠﻲ ﭘﻴﺶ‬ ‫ﺁﻣـﺪ ﺑـﺘﻮﺍﻧﺪ ﺗـﺮﻣﻴﻢ ﻧﻤﺎﻳـﺪ ‪ .‬ﺩﺭ ﺍﻳـﻦ ﻣـﺮﺣﻠﻪ ﺑﻌـﻨﻮﺍﻥ ﭘـﻴﺶ ﺑﻴﻨـﻲ ﺑـﺮﻭﺯ ﻣﺸﻜﻞ ‪،‬ﺩﺭ ﺣﻴﻦ ﺍﺟﺮﺍﻱ ﺑﺮﻧﺎﻣﻪ ﺍﻗﺪﺍﻡ ﺑﻪ ﺫﺧﻴﺮﻩ ﺳﺎﺯﻱ‬ ‫ﺍﻃﻼﻋﺎﺗﻲ ﻣﻲ ﺷﻮﺩ ﺗﺎ ﺩﺭ ﺻﻮﺭﺕ ﺑﺮﻭﺯ ﻣﺸﻜﻞ ﺑﺘﻮﺍﻥ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺁﻧﻬﺎ ﺍﺛﺮ ﻧﺎﻣﻄﻠﻮﺏ ﺭﻭﻱ ﺍﻃﻼﻋﺎﺕ ﺭﺍ ﺧﻨﺜﻲ ﻧﻤﻮﺩ‪.‬‬ ‫ﺏ ‪:‬ﺍﻗﺪﺍﻣﺎﺕ ﺑﻌﺪﺍﺯ ﺑﺮﻭﺯ ﺍﺷﻜﺎﻝ‬ ‫ﺷﺎﻣﻞ ﺍﻗﺪﺍﻣﺎﺗﻲ ﺍﺳﺖ ﻛﻪ ‪ DBMS‬ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺍﻃﻼﻋﺎﺕ ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺩﺭ ﻣﺮﺣﻠﻪ ﻗﺒﻞ ﺍﻧﺠﺎﻡ ﻣﻲ ﺩﻫﺪ ﺗﺎ ﻧﺎﻫﻤﺎﻫﻨﮕﻲ ﻭ‬ ‫ﻧﺎﺳﺎﺯﮔﺎﺭﻱ ﺍﻳﺠﺎﺩ ﺷﺪﻩ ﺩﺭ ﺑﺎﻧﻚ ﺩﺭ ﺍﺛﺮ ﺑﺮﻭﺯ ﺍﺷﻜﺎﻝ ﺭﺍ ﺭﻓﻊ ﻧﻤﺎﻳﺪ‪.‬‬ ‫‪ -٢-٨‬ﻣﺪﻳﺮﻳﺖ ﺗﺮﻣﻴﻢ‪:‬‬ ‫ﻳﻜﻲ ﺍﺯ ﻗﺴﻤﺘﻬﺎﻱ ‪ DBMS‬ﻣﺪﻳﺮﻳﺖ ﺗﺮﻣﻴﻢ ﻣﻲ ﺑﺎﺷﺪ ﻛﻪ ﻣﺴﺌﻮﻟﻴﺖ ﺣﻔﻆ ﻳﻜﭙﺎﺭﭼﮕﻲ ﺍﻃﻼﻋﺎﺕ ﺩﺭ ﺣﻴﻦ ﺍﺟﺮﺍﻱ ﺑﺮﻧﺎﻣﻪ ﺑﻪ‬ ‫ﻋﻬﺪﻩ ﺁﻥ ﺍﺳﺖ ‪ .‬ﺍﻳﻦ ﻣﺴﺌﻮﻟﻴﺖ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﻧﺠﺎﻡ ﻣﻲ ﺷﻮﺩ‪:‬‬ ‫ﺍﻟﻒ‪ :‬ﺗﺸﺨﻴﺺ ﺍﺷﻜﺎﻝ ‪ :‬ﺍﮔﺮ ﺩﺭ ﺣﻴﻦ ﺍﺟﺮﺍﻱ ﺑﺮﻧﺎﻣﻪ ﻣﺸﻜﻠﻲ ﺩﺭ ﺳﻴﺴﺘﻢ ﺭﺥ ﺩﺍﺩﻩ ﺑﺎﺷﺪ ﺗﺸﺨﻴﺺ ﺩﺍﺩﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺏ‪ :‬ﺣﻔﻆ ﻳﻜﭙﺎﺭﭼﮕﻲ ‪ :‬ﺍﮔﺮ ﺑﺮﻧﺎﻣﻪ ﻧﻴﻤﻪ ﻛﺎﺭﻩ ﺭﻫﺎ ﺷﺪﻩ ﺑﺎﺷﺪ ﺑﺎﻋﺚ ﻋﺪﻡ ﻳﻜﭙﺎﺭﭼﮕﻲ ﺍﻃﻼﻋﺎﺕ ﺷﺪﻩ ﻭ ﺁﻥ ﺭﺍ ﺭﻓﻊ ﻣﻲ ﻛﻨﺪ‪.‬‬ ‫‪-١-٢-٨‬ﺩﺳﺘﻪ ﺑﻨﺪﻱ ﺧﻄﺎﻫﺎ ‪:‬‬ ‫‪-١‬ﺧﻄﺎﻫﺎﻱ ﺗﺮﺍﻛﻨﺶ ﻫﺎ‬ ‫ﺍﻟﻒ(ﺧﻄﺎﻫﺎﻱ ﻣﻨﻄﻘﻲ‪ :‬ﺩﺭ ﺻﻮﺭﺕ ﻛﺎﻣﻞ ﻧﺸﺪﻥ ﺗﺮﺍﻛﻨﺶ‬ ‫ﺏ(ﺧﻄﺎﻫـﺎﻱ ﺳﻴﺴـﺘﻤﻲ ‪ :‬ﺑﺎﻧـﻚ ﺍﻃﻼﻋﺎﺗـﻲ ﻣﻤﻜـﻦ ﺍﺳﺖ ﻳﻚ ﺗﺮﺍﻛﻨﺶ ﺩﺭ ﺣﺎﻝ ﺍﺟﺮﺍ ﺭﺍ ﻣﺘﻮﻗﻒ ﻛﻨﺪ ﻛﻪ ﺍﻳﻦ ﺍﻣﺮ ﻣﻤﻜﻦ‬ ‫ﺍﺳﺖ ﺩﺭ ﺍﺛﺮ ﺧﻄﺎ ﻭ ﻳﺎ ﻭﺟﻮﺩ ﺑﻦ ﺑﺴﺖ ﺻﻮﺭﺕ ﮔﻴﺮﺩ‪.‬‬ ‫‪-٢‬ﺧﻄﺎﻱ ﺧﺮﺍﺑﻲ ﺳﻴﺴﺘﻢ ‪:‬‬ ‫ﺧﻄﺎﻱ ﺳﺨﺖ ﺍﻓﺰﺍﺭ ﻭ ﻳﺎ ﺧﻄﺎﻱ ﻧﺮﻡ ﺍﻓﺰﺍﺭﻱ ﺑﺎﺷﺪ ﻛﻪ ﺑﺎﻋﺚ ﺧﺮﺍﺑﻲ ﺳﻴﺴﺘﻢ ﻣﻲ ﮔﺮﺩﺩ‪.‬‬ ‫‪-٣‬ﺧﻄﺎﻱ ﺩﻳﺴﻚ‪:‬‬ ‫ﺧﺮﺍﺑﻲ ﻫﺪ ﺩﻳﺴﻚ ﻭ ﻳﺎ ﺧﻄﺎﻫﺎﻱ ﻣﺸﺎﺑﻪ ﻛﻪ ﺑﺎﻋﺚ ﺍﺯ ﺑﻴﻦ ﺭﻓﺘﻦ ﺑﺨﺸﻲ ﺍﺯ ﻳﻚ ﺩﻳﺴﻚ ﻣﻲ ﮔﺮﺩﻧﺪ‪.‬‬ ‫‪ -٣-٨‬ﺗﺮﻣﻴﻢ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺛﺒﺖ ﻭﻗﺎﻳﻊ )‪(Log-Based Recovery‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١٦ /‬‬

‫ﺭﺍﻳﺠﺘـﺮﻳﻦ ﺷﻴﻮﻩ ﺭﻓﻊ ﺍﺷﻜﺎﻝ ‪ ،‬ﺛﺒﺖ ﻭﻗﺎﻳﻊ ﻣﻲ ﺑﺎﺷﺪ ﻛﻪ ﺩﺭ ﺣﻴﻦ ﺍﺟﺮﺍﻱ ﻋﺎﺩﻱ ﺗﺮﺍﻛﻨﺶ ﻳﻜﺴﺮﻱ ﺍﻃﻼﻋﺎﺕ ﺑﻨﺎﻡ‬

‫‪ log‬ﻛﻪ‬

‫ﻣﺒـﻴﻦ ﺗﻐﻴﻴـﺮﺍﺕ ﺍﻋﻤـﺎﻝ ﺷـﺪﻩ ﺩﺭ ﺍﻃﻼﻋـﺎﺕ ﺍﺳـﺖ ﺫﺧﻴـﺮﻩ ﺷـﺪﻩ ﺗـﺎ ﺩﺭ ﺻـﻮﺭﺕ ﻟـﺰﻭﻡ ﺍﺯ ﺁﻧﻬـﺎ ﺑﺮﺍﻱ ﺗﺮﻣﻴﻢ ﺍﻃﻼﻋﺎﺕ ﺍﺳﺘﻔﺎﺩﻩ‬ ‫ﮔﺮﺩﺩ‪.‬ﺩﺭ ﺣﻴﻦ ﺍﺟﺮﺍﻱ ﻫﺮ ﺗﺮﺍﻛﻨﺶ ﺍﻃﻼﻋﺖ ﺯﻳﺮ ﺩﺭ ‪ log‬ﺛﺒﺖ ﻣﻲ ﮔﺮﺩﻧﺪ‪:‬‬ ‫‪-‬ﺛـﺒﺖ ﺷـﺮﻭﻉ ﺗـﺮﺍﻛﻨﺶ ‪ :‬ﻭﻗﺘﻴﻜﻪ ﺗﺮﺍﻛﻨﺶ ‪ Ti‬ﺷﺮﻭﻉ ﻣﻲ ﺷﻮﺩ ﺍﻃﻼﻋﺖ >‪ <Ti,Start‬ﺑﺮ ﺭﻭﻱ ﺭﻛﻮﺭﺩ ‪ log‬ﺛﺒﺖ‬

‫ﻣﻲ‬

‫ﮔﺮﺩﺩ‪.‬‬ ‫ﺛـﺒﺖ ﻋﻤﻠـﻴﺎﺕ ﺗﺮﺍﻛﻨﺶ ﻛﻪ ﺩﺭ ﺍﺯﺍﻱ ﻫﺮ ﻋﻤﻞ ‪ Write‬ﺍﻧﺠﺎﻡ ﻣﻲ ﮔﻴﺮﺩ ‪ .‬ﺍﻃﻼﻋﺎﺕ >‪ <Ti,Xi,V1,V2‬ﺩﺭ ‪ log‬ﺛﺒﺖ ﻣﻲ‬‫ﺷﻮﺩ ﻛﻪ ‪V1‬ﻣﻘﺪﺍﺭ ‪ Xj‬ﻗﺒﻞ ﺍﺯ ﻋﻤﻞ ‪ Write‬ﻭ ‪ V2‬ﻣﻘﺪﺍﺭ ﻧﻮﺷﺘﻪ ﺷﺪﻩ ﺩﺭ ‪ X‬ﻣﻲ ﺑﺎﺷﺪ‪).‬ﺑﻌﺪ ﺍﺯ ﻋﻤﻞ ﭘﺮﺩﺍﺯﺵ(‬ ‫ﺛﺒﺖ ﭘﺎﻳﺎﻥ ﺗﺮﺍﻛﻨﺶ‬‫ﻭﻗﺘﻴﻜﻪ ﺗﺮﺍﻛﻨﺶ ﭘﺎﻳﺎﻥ ﻳﺎﻓﺖ ﺭﻛﻮﺭﺩ >‪ <Ti,Commit‬ﺩﺭ ‪ log‬ﻧﻮﺷﺘﻪ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺑﺮﺧﻲ ﻧﻜﺎﺕ ﻣﻬﻢ ‪:‬‬ ‫‪-١‬ﺯﻣﺎﻥ ﺛﺒﺖ ﺭﻛﻮﺭﺩ ‪:log‬‬ ‫ﻗﺒﻞ ﺍﺯ ﺍﺟﺮﺍﻱ ﻫﺮ ﺩﺳﺘﻮﺭ ‪ write‬ﺩﺭ ﻳﻚ ﺗﺮﺍﻛﻨﺶ ‪ ،‬ﺭﻛﻮﺭﺩ ﺷﺮﺡ ﻭﻗﺎﻳﻊ ﺁﻥ ﺑﺎﻳﺪ ﺍﻳﺠﺎﺩ ﺷﺪﻩ ﻭ ﺩﺭ ﺣﺎﻓﻈﻪ ﺛﺎﻧﻮﻳﻪ ﺫﺧﻴﺮﻩ ﺷﺪﻩ‬ ‫ﺑﺎﺷﺪ ﺗﺎ ﺩﺭ ﺻﻮﺭﺕ ﻟﺰﻭﻡ ﺑﺘﻮﺍﻥ ﺍﺯ ﺁﻥ ﺑﺮﺍﻱ ﺍﻋﻤﺎﻝ ﺗﺮﻣﻴﻢ ﺍﻃﻼﻋﺎﺕ ﺍﺳﺘﻔﺎﺩﻩ ﻛﺮﺩ‪.‬‬ ‫‪-٢‬ﻧﺤﻮﻩ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ‪: log‬‬ ‫ﺩﺭ ﺻﻮﺭﺕ ﺑﺮﻭﺯ ﻣﺸﻜﻞ ﺩﺭ ﺍﺟﺮﺍﻱ ﺗﺮﺍﻛﻨﺶ ﭘﺲ ﺍﺯ ﺭﺍﻩ ﺍﻧﺪﺍﺯﻱ ﻣﺠﺪﺩ ﺳﻴﺴﺘﻢ ﺍﻃﻼﻋﺎﺕ ‪ log‬ﺭﺍ ﺑﺮﺭﺳﻲ ﻛﺮﺩﻩ ﻭ ﺩﺭ ﺻﻮﺭﺕ‬ ‫ﻟﺰﻭﻡ ﺍﻗﺪﺍﻡ ﺑﻪ ﺗﺮﻣﻴﻢ ﺍﻃﻼﻋﺎﺕ ﻣﻲ ﻛﻨﺪ‪.‬‬ ‫‪-٣‬ﺩﺳﺘﻮﺭﺍﺕ ﻣﻮﺭﺩ ﺍﺳﺘﻔﺎﺩﻩ ﺩﺭ ﺗﺮﻣﻴﻢ‪:‬‬ ‫ﺩﺭ ﺷﻴﻮﻩ ‪ log‬ﺩﻭ ﺩﺳﺘﻮﺭ ﺯﻳﺮ ﺑﺮﺍﻱ ﺗﺮﻣﻴﻢ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺍﺳﺘﻔﺎﺩﻩ ﻣﻲ ﺷﻮﻧﺪ‪:‬‬ ‫ﺍﻟﻒ( ﺩﺳﺘﻮﺭ ‪Redo‬‬

‫ﺑﺎ ﺍﺟﺮﺍﻱ ﺍﻳﻦ ﺩﺳﺘﻮﺭ ‪ ،‬ﻋﻤﻠﻴﺎﺕ ﺍﺟﺮﺍ ﺷﺪﻩ ﺗﻮﺳﻂ ﺗﺮﺍﻛﻨﺶ ﺑﺮﺍﻱ ﺣﺼﻮﻝ ﻳﻜﭙﺎﺭﭼﮕﻲ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺍﻃﻼﻋﺎﺕ‬ ‫ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺩﺭ ‪ log‬ﺩﻭﺑﺎﺭﻩ ﺍﺟﺮﺍ ﻣﻲ ﺷﻮﻧﺪ‪ .‬ﺑﺎﻳﺴﺘﻲ ﺗﻮﺟﻪ ﺩﺍﺷﺖ ﺑﺎ ﺍﺟﺮﺍﻱ ﺩﺳﺘﻮﺭ ﻓﻮﻕ ﻋﻤﻠﻴﺎﺕ ﺗﺮﺍﻛﻨﺶ ﻣﻤﻜﻦ ﺍﺳﺖ ﺭﻭﻱ‬ ‫ﺑﻌﻀـﻲ ﺍﺯ ﺍﻃﻼﻋـﺎﺕ ﺩﻭﺑـﺎﺭ ﻭ ﺑﻌﻀـﻲ ﺩﻳﮕـﺮ ﻳﻜـﺒﺎﺭ ﺍﻋﻤـﺎﻝ ﺷـﻮﻧﺪ‪.‬ﺩﺭ ﺍﻳﻨﺼـﻮﺭﺕ ﺍﺟـﺮﺍﻱ ﺩﻭﺑـﺎﺭﻩ ﺗﺮﺍﻛﻨﺶ ﻧﺒﺎﻳﺪ ﺑﺎﻋﺚ ﻋﺪﻡ‬ ‫ﻳﻜﭙﺎﺭﭼﮕﻲ ﺍﻃﻼﻋﺎﺕ ﺷﻮﺩ ﻛﻪ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺭﻛﻮﺭﺩ ﺛﺒﺖ ﻭﻗﺎﻳﻊ ﺍﻧﺠﺎﻡ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺏ( ﺩﺳﺘﻮﺭ ‪Undo‬‬

‫ﺑـﺎ ﺍﺟـﺮﺍﻱ ﺍﻳـﻦ ﺩﺳﺘﻮﺭ ﻋﻤﻠﻴﺎﺕ ﺍﺟﺮﺍ ﺷﺪﻩ ﺗﻮﺳﻂ ﺗﺮﺍﻛﻨﺶ ﺑﺮﺍﻱ ﺣﺼﻮﻝ ﻳﻜﭙﺎﺭﭼﮕﻲ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺑﺎ ﺍﺳﺘﻔﺎﺩﻩ ﺍﺯ ﺍﻃﻼﻋﺎﺕ‬ ‫ﺫﺧﻴﺮﻩ ﺷﺪﻩ ﺩﺭ ‪ log‬ﺧﻨﺜﻲ ﻣﻲ ﮔﺮﺩﻧﺪ‪.‬‬ ‫‪-٤-٨‬ﻣﺘﺪﻫﺎﻱ ﺗﺮﻣﻴﻢ ﺑﻜﺎﺭ ﺭﻓﺘﻪ ﺩﺭ ﺭﻭﺵ ‪) log-based‬ﺛﺒﺖ ﻭﻗﺎﻳﻊ(‬ ‫ﻣﻲ ﺩﺍﻧﻴﻢ ﺑﺤﺚ ﺗﺮﻣﻴﻢ ﻣﻮﻗﻌﻲ ﻣﻄﺮﺡ ﺍﺳﺖ ﻛﻪ ﺣﺪﺍﻗﻞ ﻳﻚ ﻋﻤﻞ ﻧﻮﺷﺘﻦ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ ‪ .‬ﺩﺭ ﺭﺍﺑﻄﻪ ﺑﺎ ﺍﻋﻤﺎﻝ ﻧﺘﻴﺠﻪ ﻳﻚ‬ ‫ﺗﺮﺍﻛﻨﺶ ﺩﻭ ﺷﻴﻮﻩ ﻣﻄﺮﺡ ﻣﻲ ﺷﻮﺩ‪:‬‬ ‫‪-١‬ﺗﺎﺧﻴﺮ ﺍﻋﻤﺎﻝ ﺗﻐﻴﻴﺮﺍﺕ‪.‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١٧ /‬‬

‫‪-٢‬ﺍﻋﻤﺎﻝ ﺁﻧﻲ ﺗﺎﺛﻴﺮﺍﺕ‪.‬‬ ‫‪-١-٤-٨‬ﺭﻭﺵ ﺗﺎﺧﻴﺮ ﺍﻋﻤﺎﻝ ﺗﺎﺧﻴﺮﺍﺕ ‪Deferred Database Modification‬‬

‫ﺩﺭ ﺍﻳـﻦ ﺭﻭﺵ ﺗﻤﺎﻣـﻲ ﺍﻋﻤـﺎﻝ ﻧﻮﺷـﺘﻦ ﺗـﺎ ﺍﻧـﺘﻬﺎﻱ ﺗـﺮﺍﻛﻨﺶ ﺑـﻪ ﺗﺎﺧﻴـﺮ ﻣـﻲ ﺍﻓﺘـﻨﺪ‪ .‬ﺑﻌﺒﺎﺭﺗـﻲ ﺍﮔـﺮ ﺩﺭ ﻳﻚ ﺗﺮﺍﻛﻨﺶ ﺩﻭ ﺩﺳﺘﻮﺭ‬ ‫)‪write(A‬ﻭ )‪ write(B‬ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺩﺍﺷﺘﻪ ﺑﺎﺷﻴﻢ‪:‬‬ ‫)‪read(A‬‬ ‫)‪write(A‬‬ ‫)‪.read(B‬‬ ‫‪..‬‬ ‫)‪write(B‬‬

‫ﺩﺳﺘﻮﺭ )‪write(A‬ﻭ)‪ write(B‬ﺭﺍ ﺩﺭ ﺁﺧﺮ ﺗﺮﺍﻛﻨﺶ ﺍﻧﺠﺎﻡ ﻣﻲ ﺩﻫﺪ‪.‬‬ ‫ﺍﻃﻼﻋﺎﺗﻲ ﻛﻪ ﺩﺭ ﺍﻳﻦ ﺭﻭﺵ ﺑﺎﻳﺴﺘﻲ ﺩﺭ ‪ log‬ﺛﺒﺖ ﮔﺮﺩﺩ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﻣﻲ ﺑﺎﺷﺪ‪:‬‬ ‫ﺗﺮﺍﻛﻨﺶ ﺑﺎ ﻧﻮﺷﺘﻦ ﺩﺳﺘﻮﺭ >‪ <Ti,Start‬ﺩﺭ ‪ log‬ﺁﻏﺎﺯ ﻣﻲ ﺷﻮﺩ‪.‬‬‫ﺑـﺎ ﺗـﻮﺟﻪ ﺑـﻪ ﻋﻤﻠﻜـﺮﺩ ﻣﻜﺎﻧﻴـﺰﻡ ﺗـﺮﻣﻴﻢ ﻧـﻴﺎﺯﻱ ﺑـﻪ ﻧﮕﻬـﺪﺍﺭﻱ ‪ V1‬ﺩﺭ )‪ write(x‬ﻧﻤﻲ ﺑﺎﺷﺪ )ﭼﻮﻥ ﻋﻤﻞ ‪ Undo‬ﻧﺪﺍﺭﻳﻢ( ﻟﺬﺍ‬ ‫ﺍﻃﻼﻋـﺎﺕ >‪<Ti,X,V‬ﺩﺭ‪ log‬ﺛـﺒﺖ ﻣﻲ ﺷﻮﺩ ﻛﻪ ‪ V‬ﻣﻘﺪﺍﺭ ﺟﺪﻳﺪ ‪ X‬ﺍﺳﺖ‪.‬ﻋﻤﻞ ﻧﻮﺷﺘﻦ ﺩﺭ ﺍﻳﻦ ﻟﺤﻈﻪ ﺻﻮﺭﺕ ﻧﻤﻲ ﭘﺬﻳﺮﺩ‬ ‫ﺑﻠﻜﻪ ﺑﻪ ﺗﺎﺧﻴﺮ ﻣﻲ ﺍﻓﺘﺪ‪.‬‬ ‫ﻗـﺒﻞ ﺍﺯ ﺍﻳـﻨﻜﻪ ﺍﻭﻟـﻴﻦ ‪ write‬ﺍﺟـﺮﺍ ﺷـﻮﺩ ﺭﻛﻮﺭﺩ >‪ <Ti,Commit‬ﺭﺍ ﺩﺭ ‪ log‬ﺛﺒﺖ ﻣﻲ ﻛﻨﺪ‪ commit) .‬ﺳﻴﺴﺘﻢ ﺑﻌﺪ ﺍﺯ‬‫ﺁﺧﺮﻳﻦ ‪ write‬ﺍﺳﺖ ﺍﻣﺎ ﺩﺳﺘﻮﺭ ‪ commit‬ﺍﻱ ﻛﻪ ﺩﺭ ‪ log‬ﺛﺒﺖ ﻣﻲ ﺷﻮﺩ ﻗﺒﻞ ﺍﺯ ﺍﻭﻟﻴﻦ ‪ write‬ﻣﻲ ﺑﺎﺷﺪ(‪.‬‬ ‫•‬

‫ﺭﻭﺵ ﺗﺮﻣﻴﻢ‪:‬‬

‫ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺍﻳﻨﻜﻪ ﺩﺭ ﭼﻪ ﻣﺮﺣﻠﻪ ﺍﻱ ﺍﺯ ﺗﺮﺍﻛﻨﺶ ﺳﻴﺴﺘﻢ ﺩﭼﺎﺭ ﻣﺸﻜﻞ ﺷﺪﻩ ﺍﺳﺖ ﺗﺮﻣﻴﻢ ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﻧﺠﺎﻡ ﻣﻲ ﺷﻮﺩ‪:‬‬ ‫ﺍﻟﻒ(ﻗﺒﻞ ﺍﺯ ﭘﺎﻳﺎﻥ ﻋﻤﻠﻴﺎﺕ ﺗﺮﺍﻛﻨﺶ‪:‬‬ ‫ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﺍﻃﻼﻋﺎﺕ ﺩﺭﻭﻥ ‪ log‬ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﻣﻲ ﺑﺎﺷﺪ‪:‬‬ ‫>‪<Ti,Start‬‬ ‫>‪<Ti,X1,V1‬‬ ‫‪.‬‬ ‫>‪<Ti,Xi,Vi‬‬

‫ﻟـﺬﺍ ﺍﺯ ﻋﻤﻠـﻴﺎﺕ ﺍﻧﺠـﺎﻡ ﺷـﺪﻩ ﺻـﺮﻓﻨﻈﺮ ﻣـﻲ ﮔﺮﺩﺩ‪ .‬ﺯﻳﺮﺍ ﺍﺛﺮ ﺍﺟﺮﺍﻱ ﺗﺮﺍﻛﻨﺶ ﻗﺒﻞ ﺍﺯ ﺧﺮﺍﺑﻲ ﺳﻴﺴﺘﻢ ﺭﻭﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻣﻨﻌﻜﺲ‬ ‫ﻧﺸﺪﻩ ﺍﺳﺖ ﻟﺬﺍ ﺍﺟﺮﺍﻱ ﺁﻥ ﻧﺎﺩﻳﺪﻩ ﮔﺮﻓﺘﻪ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺏ( ﭘﺲ ﺍﺯ ﭘﺎﻳﺎﻥ ﻋﻤﻠﻴﺎﺕ ﺗﺮﺍﻛﻨﺶ ‪:‬‬ ‫ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﺍﻃﻼﻋﺎﺕ ‪ log‬ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ‪:‬‬ ‫>‪<Ti,Start‬‬ ‫>‪<Ti,X1,V2‬‬ ‫>‪<Ti,Xn,Vn2‬‬ ‫>‪<Ti,Commit‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١٨ /‬‬

‫ﻟـﺬﺍ ﭼـﻮﻥ ﻋﻤﻠـﻴﺎﺕ ﺗـﺮﺍﻛﻨﺶ ﻗـﺒﻞ ﺍﺯ ﺧﺮﺍﺑـﻲ ﺳﻴﺴـﺘﻢ ﭘﺎﻳﺎﻥ ﻳﺎﻓﺘﻪ ﺍﺳﺖ ﻭ ﺍﺯ ﻃﺮﻓﻲ ﻣﻤﻜﻦ ﺍﺳﺖ ﺛﺒﺖ ﺗﻤﺎﻣﻲ ﺁﻧﻬﺎ ﺍﻧﺠﺎﻡ ﻧﺸﺪﻩ‬ ‫ﺍﺳﺖ ﻟﺬﺍ ﺍﺟﺮﺍﻱ ﺩﻭﺑﺎﺭﻩ ﺗﺮﺍﻛﻨﺶ ﺻﻮﺭﺕ ﻣﻲ ﭘﺬﻳﺮﺩ ﻳﻌﻨﻲ ﺩﺳﺘﻮﺭ >‪ < redo,Ti‬ﺍﻧﺠﺎﻡ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﻣﺜﺎﻝ ‪:‬ﻓﺮﺽ ﻛﻨﻴﺪ ﺗﺮﺍﻛﻨﺶ ﻫﺎﻱ ‪T0‬ﻭ ‪T1‬ﺭﺍ ﺩﺍﺭﻳﻢ ﻭ ‪T0‬ﻗﺒﻞ ﺍﺯ ‪ T1‬ﺍﺟﺮﺍ ﻣﻲ ﺷﻮﺩ‪:‬‬ ‫)‪T1 :Read(C‬‬ ‫‪C:=C-100‬‬ ‫)‪write(C‬‬

‫)‪T0 :Read(A‬‬ ‫‪A:=A-50000‬‬ ‫)‪write(A‬‬ ‫)‪Read(B‬‬ ‫‪B:=B+50000‬‬ ‫)‪write(B‬‬

‫ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺍﻃﻼﻋﺎﺕ ﻣﻮﺟﻮﺩ ﺩﺭ ‪ LOG‬ﺧﻮﺍﻫﻴﻢ ﺩﺍﺷﺖ‪:‬‬ ‫>‪
‫ﺍﻟﻒ(‬

‫>‪‪< T0,B,2050000‬‬

‫ﺩﺭ ﺍﻳﻦ ﺣﺎﻟﺖ ﻫﻴﭻ ﻋﻤﻠﻲ ﺻﻮﺭﺕ ﻧﻤﻲ ﮔﻴﺮﺩ‪.‬‬ ‫ﺏ(‬

‫>‪
‫>‪‪< T0,B,2050000‬‬ ‫>‪
‫ﺝ(‬

‫>‪
‫>‪‪< T0,B,2050000‬‬ ‫>‪
‫ﺩﺭ ﺍﻳـﻦ ﺭﻭﺵ ﺣﺎﺻﻞ ﻫﺮ ﻋﻤﻠﻴﺎﺕ ‪ write‬ﺭﻭﻱ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺳﺮﻳﻌﺎ” ﺑﻪ ﺑﺎﻧﻚ ﻣﻨﻌﻜﺲ ﻣﻲ ﺷﻮﺩ ﺑﻌﺒﺎﺭﺕ ﺩﻳﮕﺮ ﻫﺮ ﺩﺳﺘﻮﺭ‬ ‫‪ write‬ﺩﺭ ﻣﺤـﻞ ﻇﻬـﻮﺭ ﺧﻮﺩ ﺍﺟﺮﺍ ﻣﻲ ﺷﻮﺩ‪ .‬ﺍﺯ ﺁﻧﺠﺎﺋﻴﻜﻪ ﺩﺭ ﺍﻳﻨﺠﺎ ﻋﻤﻞ ‪ undo‬ﻧﻴﺰ ﺩﺍﺭﻳﻢ ﻟﺬﺍ ﻣﻘﺪﺍﺭ ﻗﺒﻠﻲ ﻭ ﻣﻘﺪﺍﺭ ﺟﺪﻳﺪ ﻫﺮ‬ ‫ﻣﺘﻐﻴﻴﺮ ﻧﻴﺎﺯ ﺍﺳﺖ‪.‬‬ ‫ﺍﻃﻼﻋﺎﺗﻲ ﻛﻪ ﺩﺭ ‪ log‬ﺛﺒﺖ ﻣﻲ ﮔﺮﺩﻧﺪ ﺑﺘﺮﺗﻴﺐ ﺯﻳﺮ ﻣﻲ ﺑﺎﺷﺪ‪:‬‬ ‫‪-١‬ﺛﺒﺖ >‪ <Ti,Start‬ﻗﺒﻞ ﺍﺯ ﺷﺮﻭﻉ ﺗﺮﺍﻛﻨﺶ ﺍﻳﻦ ﺩﺳﺘﻮﺭ ﺩﺭ ‪ log‬ﺛﺒﺖ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫‪-٢‬ﺛﺒﺖ >‪ <Ti,X,V1,V2‬ﻗﺒﻞ ﺍﺯ ﺍﺟﺮﺍﻱ ﻫﺮ ‪write‬‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١١٩ /‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫‪-٣‬ﺛﺒﺖ >‪ <Ti,Commit‬ﭘﺲ ﺍﺯ ﺍﺟﺮﺍﻱ ﺁﺧﺮﻳﻦ ﺩﺳﺘﻮﺭ ﺗﺮﺍﻛﻨﺶ‬ ‫ﺷﻴﻮﻩ ﺗﺮﻣﻴﻢ ‪:‬‬ ‫ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺍﻃﻼﻋﺎﺕ ﻣﻮﺟﻮﺩ ﺩﺭ ‪ log‬ﺑﻪ ﻳﻜﻲ ﺍﺯ ﺣﺎﻻﺕ ﺯﻳﺮ ﻋﻤﻞ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺍﻟﻒ( ﺣﺬﻑ ﺍﺛﺮ ﺗﺮﺍﻛﻨﺶ )‪Undo(Ti‬‬

‫ﺍﻳـﻦ ﺣﺎﻟـﺖ ﻣﻮﻗﻌـﻲ ﺍﺟـﺮﺍ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﺍﺣﺘﻤﺎﻻ” ﺑﺨﺸﻲ ﺍﺯ ﭘﺎﻳﮕﺎﻩ ﺍﺻﻼﺡ ﺷﺪﻩ ﻭ ﺍﻃﻼﻋﺎﺕ ﻣﻮﺟﻮﺩ ﺩﺭ ‪ log‬ﺑﺮﺍﻱ ﺍﻋﻤﺎﻝ ﺑﻘﻴﻪ‬ ‫ﺍﺻﻼﺣﺎﺕ ﻧﻴﺰ ﻛﺎﻓﻲ ﻧﺒﺎﺷﺪ ‪ .‬ﺑﻌﺒﺎﺭﺕ ﺩﻳﮕﺮ ﻣﻮﻗﻌﻲ ﻛﻪ ﺩﺳﺘﻮﺭ >‪<Ti,Start‬ﺩﺭ ‪ log‬ﺑﺎﺷﺪ ﻭﻟﻲ >‪ <Ti,Commit‬ﻧﺒﺎﺷﺪ‪.‬‬ ‫ﺏ(ﺍﺟﺮﺍﻱ ﺩﻭﺑﺎﺭﻩ ﺗﺮﺍﻛﻨﺶ )‪redo(Ti‬‬

‫ﺍﻳﻦ ﺣﺎﻟﺖ ﻣﻮﻗﻌﻲ ﺍﺟﺮﺍ ﻣﻲ ﺷﻮﺩ ﻛﻪ ﺍﺣﺘﻤﺎﻻ” ﺑﺨﺸﻲ ﺍﺯ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺍﺻﻼﺡ ﺷﺪﻩ ﻭ ﺍﻃﻼﻋﺎﺕ ﻣﻮﺟﻮﺩ ﺩﺭ ‪ log‬ﺑﺮﺍﻱ‬ ‫ﺍﻋﻤﺎﻝ ﺑﻘﻴﻪ ﺍﺻﻼﺣﺎﺕ ﻧﻴﺰ ﻛﺎﻓﻲ ﺍﺳﺖ ‪ .‬ﺑﻌﺒﺎﺭﺕ ﺩﻳﮕﺮ ﺩﺭ ﺻﻮﺭﺗﻲ ﺻﺎﺩﺭ ﻣﻲ ﺷﻮﺩ ﻛﻪ >‪ <Ti,Start‬ﻭ>‪<Ti,Commit‬‬

‫ﺩﺭ ‪log‬ﺑﺎﺷﺪ‪.‬‬ ‫•‬

‫ﻣﺜﺎﻝ ﺍﺯ ﺣﺎﻟﺖ ﺍﻋﻤﺎﻝ ﺁﻧﻲ ﺗﻐﻴﻴﺮﺍﺕ‪:‬‬

‫ﻣﺜﺎﻝ ﻗﺒﻞ ﺭﺍ ﺩﺭ ﻧﻈﺮ ﺑﮕﻴﺮﻳﺪ ﻓﺮﺽ ﻛﻨﻴﺪ ﺩﺭ ‪ log‬ﺩﺭ ﺳﻪ ﺯﻣﺎﻥ ﻣﺨﺘﻠﻒ ﺩﺍﺩﻩ ﻫﺎﻱ ﺯﻳﺮ ﻗﺮﺍﺭ ﮔﺮﻓﺘﻪ ﺑﺎﺷﻨﺪ‪.‬‬ ‫>‪
‫>‪
‫ﺝ‬

‫ﺏ‬

‫ﺍﻟﻒ‬

‫ﻋﻤﻞ ﺗﺮﻣﻴﻢ ﺑﺮﺍﻱ ﻫﺮﻳﻚ ﺍﺯ ﺳﻪ ﺣﺎﻟﺖ ﺑﺎﻻ ﺑﻪ ﺻﻮﺭﺕ ﺯﻳﺮ ﺍﺳﺖ‪:‬‬ ‫ﺍﻟﻒ()‪ undo(T0‬ﺩﺭ‬

‫‪ B‬ﻣﻘﺪﺍﺭ ‪ ٢٠٠٠٠٠٠‬ﻭ ﺩﺭ ‪ A‬ﻣﻘﺪﺍﺭ ‪ ١٠٠٠٠٠٠‬ﺫﺧﻴﺮﻩ ﻣﻲ ﺷﻮﺩ‬

‫ﺏ()‪ undo(T1‬ﻭ )‪redo(T0‬‬ ‫ﺝ()‪ redo(T0‬ﻭ )‪redo(T1‬‬ ‫‪ -٥-٨‬ﻋﻤﻠﻴﺎﺕ ﻛﻨﺘﺮﻝ ﺯﻣﺎﻧﻲ )‪(Check Point‬‬

‫ﻫﻨﮕﺎﻣﻴﻜﻪ ﭘﺲ ﺍﺯ ﺭﻓﻊ ﺍﺷﻜﺎﻝ ﺳﻴﺴﺘﻢ ﻣﺠﺪﺩﺍ” ﺭﺍﻩ ﺍﻧﺪﺍﺯﻱ ﻣﻲ ﺷﻮﺩ ﺩﺭ ﺍﻭﻟﻴﻦ ﻣﺮﺣﻠﻪ ﺍﻃﻼﻋﺎﺕ ‪ log‬ﺭﺍ ﻛﻨﺘﺮﻝ ﻛﺮﺩﻩ ﻭ‬ ‫ﺑﺮﺍﺳﺎﺱ ﺁﻥ ﺩﺳﺘﻮﺭﺍﺕ ‪redo‬ﻭ ‪ undo‬ﺭﺍ ﺟﻬﺖ ﺗﺮﻣﻴﻢ ﺑﺎﻧﻚ ﺍﻃﻼﻋﺎﺗﻲ ﺍﻧﺠﺎﻡ ﻣﻲ ﺩﻫﺪ ﺍﻳﻦ ﻋﻤﻞ ﺍﮔﺮﭼﻪ ﺻﺤﺖ ﺑﺎﻧﻚ ﺭﺍ‬ ‫ﺑﻪ ﻫﻢ ﻧﻤﻲ ﺯﻧﺪ ﻭﻟﻴﻜﻦ ﺑﺎﻋﺚ ﺩﻭ ﺍﺷﻜﺎﻝ ﺯﻳﺮ ﻣﻲ ﮔﺮﺩﺩ‪:‬‬ ‫‪ -١‬ﺑﺮﺭﺳﻲ ﺗﻤﺎﻡ ﺭﻛﻮﺭﺩﻫﺎﻱ ‪ log‬ﺯﻣﺎﻧﮕﻴﺮ ﺍﺳﺖ‬ ‫‪ -٢‬ﺗﻌﺪﺍﺩ ﺯﻳﺎﺩﻱ ﺗﺮﺍﻛﻨﺶ ﺩﻭﺑﺎﺭﻩ ﺍﺟﺮﺍ ﻣﻲ ﺷﻮﻧﺪ ﺩﺭ ﺻﻮﺭﺗﻴﻜﻪ ﻭﺍﻗﻌﺎ” ﻧﻴﺎﺯﻱ ﺑﻪ ﺍﺟﺮﺍﻱ ﺁﻧﻬﺎ ﻧﻴﺴﺖ ﻭ ﻟﺬﺍ ﺑﺎﻋﺚ ﺍﺗﻼﻑ ﻭﻗﺖ‬ ‫ﻣﻲ ﮔﺮﺩﺩ‪.‬‬ ‫ﺑﺮ ﺍﺳﺎﺱ ﻋﻤﻞ ﺗﺮﻣﻴﻢ ﻣﻲ ﺗﻮﺍﻧﻨﺪ ﺩﺭ ﺯﻣﺎﻧﻬﺎﻱ ﻣﺨﺘﻠﻒ ﻛﻨﺘﺮﻝ ﺷﻮﺩ ﻭ ﺍﻳﻦ ﻛﺎﺭ ﻣﻲ ﺗﻮﺍﻧﺪ ﺑﻪ ﺻﻮﺭﺕ ﺯﻳﺮ ﺍﻧﺠﺎﻡ ﺷﻮﺩ‪:‬‬

‫ﺧﻼﺻﻪ درس ‪ :‬اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬

‫ﻣﺪﺭﺱ ‪ :‬ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ ‪١٢٠ /‬‬

‫ﺍﻟﻒ( ﺗﻤﺎﻣﻲ ﺭﻛﻮﺭﺩﻫﺎﻱ ‪ log‬ﺭﺍ ﺍﺯ ﺣﺎﻓﻈﻪ ﺍﺻﻠﻲ ﺑﻪ ﺣﺎﻓﻈﻪ ﺛﺎﻧﻮﻳﻪ ﻣﻨﺘﻘﻞ ﻛﺮﺩ‪.‬‬ ‫ﺏ( ﺗﻤﺎﻣﻲ ﺑﻠﻮﻛﻬﺎﻱ ﺣﺎﻭﻱ ﺭﻛﻮﺭﺩﻫﺎﻱ ﺍﺻﻼﺡ ﺷﺪﻩ ﺑﻪ ﺣﺎﻓﻈﻪ ﺛﺎﻧﻮﻳﻪ ﻣﻨﺘﻘﻞ ﺷﻮﺩ‪.‬‬ ‫ﺝ( ﻳﻚ ﺭﻛﻮﺭﺩ ﺗﺤﺖ ﻋﻨﻮﺍﻥ >‪ ‪ <Ti,Commit‬ﻧﺴﺒﺖ ﺑﻪ ﺭﻛﻮﺭﺩ>‪
‫ﺑﺼﻮﺭﺕ ﺯﻳﺮ ﻣﺸﺨﺺ ﻣﻲ ﺷﻮﺩ‪:‬‬ ‫)ﻓﺮﺽ ﻛﻨﻴﺪ ‪ Tc‬ﺁﺧﺮﻳﻦ ﺭﻛﻮﺭﺩ ‪ check point‬ﻭ ‪ Tf‬ﺯﻣﺎﻥ ﺧﺮﺍﺑﻲ ﺳﻴﺴﺘﻢ ﺑﺎﺷﺪ(‬ ‫ﺍﻟﻒ( >‪ <Ti,Commit‬ﻗﺒﻞ ﺍﺯ ﻋﻤﻞ ‪Tc‬ﺑﺎﺷﺪ‪:‬‬ ‫ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﺗﺮﺍﻛﻨﺶ ﻧﺎﺩﻳﺪﻩ ﮔﺮﻓﺘﻪ ﻣﻲ ﺷﻮﺩ ﺯﻳﺮﺍ ﻋﻤﻠﻴﺎﺕ ﺗﻤﺎﻡ ﺷﺪﻩ ﻭ ﺗﺮﺍﻛﻨﺶ ﺛﺒﺖ ﺷﺪﻩ ﺍﺳﺖ‪.‬‬ ‫ﺏ( >‪ <Ti,Commit‬ﺑﻌﺪ ﺍﺯ ‪ Tn‬ﻭ ﻗﺒﻞ ﺍﺯ ‪Tf‬ﺑﺎﺷﺪ‪:‬‬ ‫ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﺑﺎ ﺍﺟﺮﺍﻱ ﺩﺳﺘﻮﺭ ‪ redo‬ﺗﺮﺍﻛﻨﺶ ﺍﺟﺮﺍﻱ ﺩﻭﺑﺎﺭﻩ ﻣﻲ ﺷﻮﺩ‪.‬‬ ‫ﺝ(ﻋﺪﻡ ﺣﻀﻮﺭ >‪<Ti,Commit‬‬

‫ﺩﺭ ﺍﻳـﻦ ﺣﺎﻟـﺖ ﺗـﺮﺍﻛﻨﺶ ﻧـﻴﻤﻪ ﺗﻤـﺎﻡ ﺭﻫﺎ ﺷﺪﻩ ﻭ ﻟﺬﺍ ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺷﻴﻮﻩ ﺍﺟﺮﺍﻱ ﺗﺮﺍﻛﻨﺶ ﺑﻪ ﻳﻜﻲ ﺍﺯ ﺣﺎﻟﺘﻬﺎﻱ ﺯﻳﺮ ﻋﻤﻞ‬

‫ﻣﻲ‬

‫ﺷﻮﺩ‪:‬‬ ‫•‬

‫ﺍﻋﻤﺎﻝ ﺁﻧﻲ ﺗﻐﻴﻴﺮﺍﺕ‪:‬‬

‫ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﺍﺛﺮ ﺍﺣﺘﻤﺎﻟﻲ ﺗﺮﺍﻛﻨﺶ ﻫﺎﻳﻲ ﻛﻪ >‪ <Ti,Commit‬ﺁﻧﻬﺎ ﺩﺭ ‪ log‬ﻇﺎﻫﺮ ﻧﺸﺪﻩ ﺍﺳﺖ ﺑﺎ ﺍﺟﺮﺍﻱ ﺩﺳﺘﻮﺭ ‪undo‬‬

‫ﺭﻭﻱ ﺑﺎﻧﻚ ﺧﻨﺜﻲ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬ ‫•‬

‫ﺗﺎﺧﻴﺮ ﺍﻋﻤﺎﻝ ﺍﺻﻼﺣﺎﺕ‪:‬‬

‫ﺩﺭ ﺍﻳﻨﺼﻮﺭﺕ ﺗﺮﺍﻛﻨﺶ ﻫﺎﻳﻲ ﻛﻪ >‪ <Ti,Commit‬ﺁﻧﻬﺎ ﺩﺭ ‪ log‬ﻇﺎﻫﺮ ﻧﺸﺪﻩ ﺍﺳﺖ ﻧﺎﺩﻳﺪﻩ ﮔﺮﻓﺘﻪ ﻣﻲ ﺷﻮﻧﺪ‪.‬‬ ‫ﻣﺜﺎﻝ ‪ :‬ﻓﺮﺽ ﻛﻨﻴﺪ ﺩﺭ ﺯﻣﺎﻧﻬﺎﻱ ﻣﺨﺘﻠﻒ ﺗﺮﺍﻛﻨﺶ ﻫﺎﻱ ‪ T1‬ﻭ ‪ T4‬ﻫﻤﺮﺍﻩ ﺑﺎ ‪ Check point‬ﺑﺼﻮﺭﺕ ﻧﻤﻮﺩﺍﺭ ﺯﻳﺮ ﻇﺎﻫﺮ ﺷﺪﻩ‬ ‫ﺑﺎﺷﻨﺪ‪.‬‬ ‫‪Tf‬‬

‫‪system failure‬‬

‫ﺑﺎ ﺗﻮﺟﻪ ﺑﻪ ﺷﻜﻞ ﺩﺍﺭﻳﻢ ‪:‬‬ ‫• ‪ T1‬ﻣﻲ ﺗﻮﺍﻧﺪ ﻧﺎﺩﻳﺪﻩ ﮔﺮﻓﺘﻪ ﺷﻮﺩ‪.‬‬

‫‪Tc‬‬

‫‪Check point‬‬

‫‪TIME‬‬

١٢١ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

.‫ ﺩﻭﺑﺎﺭﻩ ﺍﺟﺮﺍ ﻣﻲ ﺷﻮﻧﺪ‬T3‫ﻭ‬T2 • .(‫ ﻧﺎﺩﻳﺪﻩ ﮔﺮﻓﺘﻪ ﻣﻲ ﺷﻮﺩ)ﻭ ﺍﺛﺮ ﺁﻥ ﺧﻨﺜﻲ ﻣﻲ ﮔﺮﺩﺩ‬T4 •

: ‫ﻳﻚ ﻣﺜﺎﻝ ﻋﻤﻠﻲ‬ LitSearch

• • • • • • •

As part of an introductory databases class at Stanford, I designed LitSearch, a database application which stores data on nearly 4000 titles and their authors as well as literary criticism related to these works. It also contains a full text index of about 100 of them. The project allows users to perform searches on the book metadata, as well as full-text searches on the bodies of the works. It also features a "motif search" which uses synonyms to find passages that are similar to a phrase that the user enters into the search box. It's very unrefined, but can produce some interesting results. The data was collected from a number of public-domain sources, including Project Gutenberg and The Internet Public Library. This page describes the various stages of my project, from the conceptual E/R diagram, to the Java Servlet-based front end. Additionally, I decided to port my database project to MySQL, which I also describe below. Entity-Relationship (E/R) Diagram Conversion to a Relational Schema SQL Schema Data Acquisition SQL Interaction MySQL Port Web Application

LitSearch: Entity/Relationship Diagram Description of Entity Sets Words: word stems that are used throughout all of the works that are cataloged in the database. It's a sort of lexicon containing every stem that the parser has ever come across. WordContexts: the full word that a particular instance of a stem corresponds to. Includes any punctuation/whitespace surrounding the word used. Criticism: online literary criticism of a particular work. Contains metadata for the criticism as well as the URL where the criticism may be found. Author: information about authors. Period: information about the various regions and eras used to classify works, such as "19th Century American" Works: information about works (books, collections, etc.) in the database. Pages: data on individual pages in a work. This is a weak entity set because the key here is the page number, so a work is required for uniqueness.

١٢٢ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

LitSearch: Conversion to a relational schema The following is the translation of the E/R Diagram into relations. Everything is in BCNF and 4NF. Conversion of Entity Sets Words(stem)

١٢٣ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

Criticism(publication, url, synopsis, title) Author(name, birth, death, description) Period(region, era) Works(id, title, year, length)

Conversion of Relationships Pages(work, pageNumber) WordContexts(work, pageNumber, position, actualText) Instance(word, work, pageNumber, position) Synonym(root, child) WrittenIn(work, region, era) Criticized(work, url) WroteCriticism(author, url) LivedIn(name, region, era) WrittenBy(author, work)

Functional Dependencies Criticism: Author: Works: WordContexts:

url -> publication, synopsis, title name -> birth, death, description id -> title, year, length work, pageNumber, position -> actualText

LitSearch: SQL Schema When translated into Oracle SQL, and after constraints and foreign keys are added, the schema becomes: CREATE TABLE Author ( name varchar(128) primary key, birth int, death int, description clob ); CREATE TABLE Criticism ( title varchar(255), critic varchar(128), url varchar(255) primary key, synopsis clob, publication varchar(255), unique (title, critic) ); CREATE TABLE Period ( region varchar(64), era varchar(32), primary key(region, era) ); CREATE TABLE Work ( id number(5) primary key, title varchar(255), year number(5), length number(8) check (length >= 0) ); CREATE TABLE Word (

١٢٤ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬ id word );

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

number(6) primary key, varchar(32)

CREATE TABLE WroteCriticism ( url varchar(255) references Criticism(url), name varchar(128) references Author(name), primary key (url, name) ); CREATE TABLE LivedIn ( region varchar(64), era varchar(32), name varchar(128) references Author(name), primary key (region, era, name), foreign key (region, era) references Period(region, era) ); CREATE TABLE WrittenIn ( region varchar(64), era varchar(32), work number(5) references Work(id), primary key (region, era, work), foreign key (region, era) references Period(region, era) ); CREATE TABLE Synonym ( root number(6) references Word(id), child number(6) references Word(id), primary key (root, child) ); CREATE TABLE Criticized ( url varchar(255) references Criticism(url), work number(5) references Work(id), primary key (url, work) ); CREATE TABLE WrittenBy ( work number(5) references Work(id), name varchar(128) references Author(name), primary key (work, name) ); CREATE TABLE Page ( work number(5), pageNumber number(5), primary key (work, pageNumber) ); CREATE TABLE Instance ( word number(6), work number(5), pageNumber number(5), position number(4), primary key (word, work, pageNumber) ); CREATE TABLE WordContext ( work number(5),

١٢٥ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

pageNumber number(5), position number(4), actualText varchar(128), primary key (word, pageNumber, position) );

LitSearch: Data Acquisition Creating the Synonym table The synonym table was generated from a comma-separated version of Roget's Thesaurus from the early 1900's (the copyright had expired). Each row in the table contains the root word (the thesaurus entry), and a number of child words (the words listed as synonyms of the word). CreateThesaurus.java is a simple Java program that handles this parsing. Parsing Author, Work, and Criticism Metadata The information about authors, works, and literary criticism was parsed from online resources at Project Gutenberg and the Internet Public Library. I wrote special-case parsers to handle these pages. The parsers for the author data are given below; the others are similar. Parsing Works Works are stored in Project Gutenberg as plain text. I wrote a script to download these texts and then parse their contents into the database. After downloading the text, the header and footer that Project Gutenberg places on the text were removed. Then the body was tokenized to find individual words. Words were then "stemmed", meaning that the suffixes were stripped off such that similar words like "falling", "fallen", and "falls" would all map to the same stem, "fall". This was done such that keyword searches would also return hits containing similar words. It had the additional benefit of keeping the vocabulary size smaller. The algorithm I used was the Porter Algorithm, for which there was a publicdomain implementation available. My source code for acquiring data is very unpolished, since we were not required to turn it in. • • • • • •

Creating the synonym table CreateThesaurus.java Parsing Authors getauthors.pl stripauthors.pl Parsing Works fetch.pl AddBook.java PorterStemmer.java

LitSearch: MySQL Port Why MySQL? The accounts we were given on the Oracle server had a 50MB quota. Unfortunately, the database I wanted to load consisted of about 100 works, at 2 to 5 MB each. Factoring in

١٢٦ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

indicies and such, the total disk space required to store this data was well over 1 GB. Figuring that the CS department might balk at a request for so much space for a class project, I decided to run the project on my own box. And not wanting to pay for an Oracle license, I decided to run an open-source alternative, MySQL and port my SQL code to work under MySQL. I originally thought that the task of porting to MySQL would be relatively simple. Unfortunately, MySQL does not support some essential functionality. Specifically related to this project, MySQL doesn't support subqueries, views, stored procedures, triggers, and foreign keys. Some workarounds are discussed in MySQL's list of missing functionality. Additionally, I was unable to find a way to hint the MySQL planner, so certain operations that should have used indicies apparently were not doing so, causing severe performance problems. As a result, I was forced to change the database schema slightly, and the MySQL schema I used for creating the web application was as follows: CREATE TABLE Author ( name varchar(128) NOT NULL PRIMARY KEY, birth integer NOT NULL, death integer NOT NULL, description text ); CREATE TABLE AuthorCriticized ( url varchar(255) NOT NULL, name varchar(128) NOT NULL, PRIMARY KEY (url, name) ); CREATE TABLE Criticism ( title varchar(255), critic varchar(128), url varchar(255) NOT NULL PRIMARY KEY, synopsis text, publication varchar(255), keywords varchar(255) ); CREATE TABLE PageContainsWord ( word mediumint NOT NULL, page mediumint NOT NULL, PRIMARY KEY (word, page) ); CREATE TABLE Period ( region varchar(64) NOT NULL, era varchar(32) NOT NULL, PRIMARY KEY (region, era) ); CREATE TABLE PeriodLived ( region varchar(64) NOT NULL, era varchar(32) NOT NULL, name varchar(128) NOT NULL, PRIMARY KEY (region, era, name) ); CREATE TABLE PeriodWritten ( region varchar(64) NOT NULL, era varchar(32) NOT NULL,

١٢٧ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

work integer NOT NULL, PRIMARY KEY (region, era, work) ); CREATE TABLE Syn ( root integer NOT NULL, child integer NOT NULL, PRIMARY KEY (root, child) ); CREATE TABLE id work page global_start global_end );

UniquePage ( mediumint NOT NULL PRIMARY KEY, smallint NOT NULL, smallint NOT NULL, integer NOT NULL, integer NOT NULL

CREATE UNIQUE INDEX uniquepage_idx1 ON UniquePage(global_start); CREATE TABLE Word ( id integer NOT NULL PRIMARY KEY, word varchar(32) NOT NULL ); CREATE INDEX word_idx1 ON Word(word); CREATE TABLE WordDetails ( gpos integer NOT NULL PRIMARY KEY, context char(24) ); CREATE TABLE WordInstance ( word mediumint NOT NULL, gpos integer NOT NULL, prev mediumint NOT NULL, PRIMARY KEY (word, gpos) ); CREATE TABLE id title year length gutenberg_id include );

Work ( integer NOT NULL PRIMARY KEY, varchar(255), integer, integer, varchar(20), integer

CREATE TABLE WorkCriticized ( url varchar(255) NOT NULL, work integer NOT NULL, PRIMARY KEY (url, work) ); CREATE TABLE WrittenBy ( work integer NOT NULL, name varchar(128) NOT NULL, PRIMARY KEY (work, name) );

١٢٨ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

In retrospect, I probably should have used PostgreSQL, which is also open-source, and supports subqueries and most of the functionality that Oracle supports. But I didn't know about it at the time, so I ended up doing the MySQL port.

LitSearch: Views & Triggers Views This section creates two views, one which displays a human-readable view of various information regarding a book including the title, year written, author, region written and era written. The second view displays the text of words which are synonyms. The "Synonym" table stores the id numbers of words that are synonyms -- the view shows what the text of those words are. CREATE VIEW ReadableBookInfo AS SELECT Work.title as title, Work.year as year_written, Author.name as author, WrittenIn.region as region, WrittenIn.era as era FROM Work, Author, WrittenIn, WrittenBy WHERE Work.id = WrittenBy.work and WrittenBy.name = Author.name and WrittenIn.work = Work.id; CREATE VIEW Synonyms AS SELECT w1.word as root, w2.word as child FROM Word w1, Word w2, Synonym syn WHERE w1.id = syn.root AND w2.id = syn.child;

Triggers This section creates two triggers on the database. The first causes a little fake review to be entered in to the databse every time a new work is added to the database. The second creates an entry in the synonym table with both entries as the same value (since every word is a synonym of iteself) every time a new word is added to the vocabulary. CREATE TRIGGER GoodReviewsTrig AFTER INSERT ON Work FOR EACH ROW WHEN (NEW.title LIKE '%computer%') BEGIN INSERT INTO Criticism VALUES (:NEW.title || ' is a great book', 'Keith Ito', 'http://www.stanford.edu/~keithito/' || :NEW.id || '.html', 'I thought that ' || :NEW.title || ' was the best book of the year', 'Keiths Reviews', 'great book'); END GoodReviewsTrig; . run; CREATE TRIGGER ReflexiveSynTrig AFTER INSERT ON Word FOR EACH ROW WHEN (NEW.id > 0)

١٢٩ / ‫ ﺑﻬﺮﻭﺯﻣﻌﺼﻮﻣﻲ‬: ‫ﻣﺪﺭﺱ‬

‫ اﺻﻮل ﻃﺮاﺣﯽ ﭘﺎﯾﮕﺎه داده ﻫﺎ‬: ‫ﺧﻼﺻﻪ درس‬

BEGIN INSERT INTO Syn VALUES (:NE W.id, :NEW.id); END ReflexiveSynTrig; . run;

:‫ﻓﻬﺮﺳﺖ ﻣﻨﺎﺑﻊ ﻭﻣﺮﺍﺟﻊ‬ ١- H.Korth and A.silberschatz ,Database System Concepts , Fourth Edition ,Mc Graw Hill ,2001.

٢- C.J.Date , Introduction To Database Systems ,7th Edition , Addison Wesley ,2000. ٣- Elmasri and Navathe, Fundamentals of Database Systems, third edition,Addison Wesley, 1999.

٤- M.kroenke , Database Processing fundementals,Design &Implementation ,8th Edition.2002.

٥- R.Stephens,Teach Yourself SQL In 21 Days. Second Ed. .١٣٧٨. ‫ﻣﻘﺪﻣﻪ ﺍﻱ ﺑﺮ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ ”ﭼﺎﭖ ﭼﻬﺎﺭﻡ “ ﺍﻧﺘﺸﺎﺭﺍﺕ ﺟﻠﻮﻩ‬. ‫ ﺳﻴﺪ ﻣﺤﻤﺪ ﺗﻘﻲ‬، ‫ ﺭﻭﺣﺎﻧﻲ ﺭﺍﻧﻜﻮﻫﻲ‬-٦ .١٣٨٠. ‫ﻣﻔﺎﻫﻴﻢ ﺑﻨﻴﺎﺩﻱ ﭘﺎﻳﮕﺎﻩ ﺩﺍﺩﻩ ﻫﺎ“ ﭼﺎﭖ ﺍﻭﻝ ” ﺍﻧﺘﺸﺎﺭﺍﺕ ﺟﻠﻮﻩ‬. ‫ ﺳﻴﺪ ﻣﺤﻤﺪ ﺗﻘﻲ‬، ‫ﺭﻭﺣﺎﻧﻲ ﺭﺍﻧﻜﻮﻫﻲ‬-٧

More Documents from "sara khaku"

May 2020 2
Final Re Jim
May 2020 1
Artiuclo.docx
October 2019 35
Binder Hw Log
May 2020 16