انتقل إلى المحتوى
أمين أبوزيد
درس مخطط لهJNR-034-L02

قيود Unique وCheck

  • الدرس 2 من 5
  • Junior
في هذا الدرس 4 موضوعات

هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

في هذا الدرس

write the main constraint types.

الموضوعات المخطط لها

  • not null: the value must exist.
  • unique: no two rows share the value (or combination).
  • foreign key: the referenced row must exist; choose the delete behavior on purpose.
  • check: a rule on the row (price >= 0).
  • Name constraints (ux_product_sku) so error messages and handlers are clear.
تفاصيل المخطط المبدئي

عرض عملي

sql
alter table product
  add constraint ux_product_sku unique (sku),
  add constraint ck_product_price check (price >= 0);
alter table order_line
  add constraint fk_line_order foreign key (order_id) references orders(id);

اختبر فهمك

Which constraint stops a negative price?

أظهر الإجابة

A check constraint.

التطبيق

طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.

المختبر والتمارين الاختبار

تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.

اكتب للبحث في المستويات والمراحل والوحدات والدروس.