Skip to main content

الجزء الثاني: أنشاء الجداول مع فهم قيود ال Primary key & Foreign Key

الجزء الثاني: أنشاء الجداول
 مع فهم قيود ال
Primary key & Foreign Key

الهدف من هذا الجزء هو كيفية انشاء جدولين: جدول للأشخاص(tblPerson) واخر لنوع الجنس (tblGender) وكيفية تأسيس قيود Constraints المفتاح الأولي او الرئيسي (Primary Key) مع مفتاح الخارجي  (Foreign Key)




في سيرفر الSQL , الجداول يمكن انشاءها اما بأستخدام الواجهة الرسومية عن طريق برنامج الSSMS SQL Server Management Studio او بأستخدام جمل الأستعلام Query Statements, وقيود المفتاح الخارجي Foreign Key Constraints  يمكن اضافتها اما بأستخدام الSSMS  او عن طريق الQuery statement
لأضافة قيد المرجع للمفتاح الخارجي Foreign Key Reference constraint بأستخدام الأمر التالي:
Alter table ForeignKeyTable add constraint ForeignKeyTable_ForeignKeyColumn_FK FOREIGN KEY (ForeignKeyColumn) references PrimaryKeyTable (PrimaryKeyColumn)

Use [test]
Go

Alter table tblPerson add constraint tblPerson_IDGender_FK
Foreign key (GenderID) references tblGender (ID)



المفتاح الخارجي Foreign Key يستخدم لفرض سلامة(integrity) قواعد البيانات من ادخال بيانات عشوائية,  بعبارة بسيطة يمكن القول ان المفتاح الخارجي في احد الجداول يشير الى المفتاح الرئيسي في جدول اخر, قيود المفتاح الخارجي Foreign Key constraints  تمنع ادخال بيانات غير صالحة في عامود الذي تنطبق عليه قيود المفتاح الخارجي, القيم التي يتم ادخالها في العامود الذي يحتوي على قيد المفتاح الخارجي يجب ان تكون احد القيم الموجودة في الجدول الذي يشار له عن طريق ظوابط هذا القيد. والمفتاح الرئيسي Primary Key وظيفته عدم وجود تكرار للقيم في العامود الذي ينطبق عليه شروط هذا القيد اي تعريف فريد للقيم , وكذلك لربط وتكوين العلاقات بين الجداول الأخرى.

شاهد الفديو التالي لمعرفة كيفية انشاء جدول في الSQL Server , مع كيفية اضافة القيود للجداول بطريقتين الطريقة الأولى بأستخدام الSSMS والطريقة الثانية بأستخدام الQuery:

Comments

Popular posts from this blog

How To Play .srt Subtitles File in Windows Media Player

How To Play .srt Subtitles File in Windows Media Player links: https://sourceforge.net/projects/wmpsub/ wmp,.srt Subtitles File in Windows Media Player,How To Play .srt Subtitles File in Windows Media Player,How To,Safaa Al-Hayali,saf3al2a,srt subtitle in WMP,Windows,Windows Media Player,media,.ass,local subtitles

How to fix the disk is write protected

in this video tutorial, I'll show you how to remove/solve/fix the disk is write protected from USB flash drive. To download the necessary 2 files: Download >  SAFAA_ALHAYALI.IMG  - 1.18 MB Download >  Win32DiskImager-0.9.5-install.exe - 11.7 MB write protection,remove write protection,write protected,How to fix the disk is write protected,how to solve the disk is write protected,how to remove the disk is write protected,USB write protected,fix USB write protected,fix HDD write protected,how to,windows,USB flash drive ERROR,fix USB flash drive write protected,USB flash drive write protected

Virtual Box : How to Increase Disk Size - Windows

How to increase disk size or disk storage in oracle virtual box the command you have to use: vboxmanage.exe modifymedium "[YourPathToVdiFileOfYourVirtualMachine]" --resize [NUMBER] virtual,box,vbox,oracle,partition,size,disk,increase,resize,windows,10,microsoft,vdi,vboxmanage,configuration,Safaa AL-Hayali,saf3al2a,Oracle,VirtualBox,How to,windows 10