Egypt › Secondary › First Secondary Grade › Programming and Artificial Intelligence › Unit ٩: Databases

Lesson ٢: Databases ٢

First Secondary GradeProgramming and Artificial IntelligenceSecond Termالدرس ٢٣٠ دقيقة

فيديو الشرح

الفيديو قيد الإنتاج، وسيظهر هنا فور اعتماده.

ماذا ستتعلم؟

اختبر استعدادك أولًا

١. In the question "What is a primary key?" the options are: ١) A field whose value is unique for every record in the table ٢) A field that can repeat ٣) A password for the computer ٤) The first column only. What is the number of the correct answer?
٢. In the question "Why must a primary key never repeat?" the options are: ١) So tables look bigger ٢) So every record can be identified exactly ٣) It may repeat freely ٤) To confuse users. What is the number of the correct answer?
٣. In the question "What is a good primary key for a students table?" the options are: ١) The student first name ٢) The city name ٣) A student ID number ٤) The birth year. What is the number of the correct answer?

الشرح خطوة بخطوة

Level ١: We explore together

Lesson topic: Databases ٢. In this second lesson about databases we go one step deeper into how tables stay correct and connected.

The story: Every table needs a special field that never repeats, called the primary key, like a national ID number for each record. Tables can be connected: a students table and a grades table can be linked by the student ID. We ask a database questions using queries, and a common language for queries is called SQL. Good database design avoids repeating data, so each fact is stored once and updated in one place. In this lesson we learn about primary keys, linking tables, queries and SQL.

أخطاء شائعة وتصحيحها

أمثلة محلولة متدرجة

Easy · مثال ١

What is a primary key?

  1. نقرأ السؤال معًا بهدوء.
  2. Unique per record.
الإجابة: A field whose value is unique for every record in the table
Easy · مثال ٢

Why is a first name a bad primary key?

  1. نقرأ السؤال معًا بهدوء.
  2. Can two students share one?
الإجابة: Because many students can share the same first name, so it does not identify a record uniquely
Easy · مثال ٣

What language do we commonly use to query databases?

  1. نقرأ السؤال معًا بهدوء.
  2. Three letters, starts with S.
الإجابة: SQL
Medium · مثال ٤

A school has a students table and a payments table. Explain how to connect them.

  1. نقرأ السؤال معًا بهدوء.
  2. One shared field.
الإجابة: Store the student ID in both tables so each payment record is linked to exactly one student record
Medium · مثال ٥

Explain why storing each fact once keeps a database consistent.

  1. نقرأ السؤال معًا بهدوء.
  2. One place to update.
الإجابة: Because updates happen in one place, so no old copies of the fact can contradict the new value
Medium · مثال ٦

Write in words a query a librarian might ask about books.

  1. نقرأ السؤال معًا بهدوء.
  2. A question about data.
الإجابة: Example: show all books written by Taha Hussein, or show all books borrowed this month
Medium · مثال ٧

A table uses phone number as a primary key. Give one risk and one fix.

  1. نقرأ السؤال معًا بهدوء.
  2. Numbers change.
الإجابة: Risk: a person can change their phone number, breaking the link; fix: use a fixed ID number that never changes
Advanced · مثال ٨

Design two linked tables for a school clinic: name the tables, the primary keys, and the linking field.

  1. نقرأ السؤال معًا بهدوء.
  2. Students and visits.
الإجابة: Table Students with primary key StudentID; table Visits with its own VisitID and a StudentID field linking each visit to one student
Error analysis · مثال ٩

Your friend says: "Repeating data in many tables makes a database safer." Is this correct?

  1. نقرأ السؤال معًا بهدوء.
  2. Copies can disagree.
الإجابة: Wrong, repetition creates inconsistent copies; good design stores each fact once

الخريطة الذهنية

Databases ٢Unit ٩: Databases
▼
A field whose value is unique for every record in the tableWhat is a primary key?
So every record can be identified exactlyWhy must a primary key never repeat?
A student ID numberFrom the lesson questions
By a shared field such as the student IDHow are two tables connected?

إنفوجرافيك: Lesson map: words of the day

Lesson map: words of the day
اضغط على أي صف لترى الفكرة.
The key ideas of the lesson in order
We review the questions after one day, then after three days

تدريبات متنوعة مع الإجابات والتفسير

اكتب الإجابة أو اختر ثم اضغط. بعد كل سؤال يظهر الحل مع التفسير.

A) I choose the answer

١. The answer "To confuse users" to the question "Why must a primary key never repeat?" is correct.
٢. From the lesson explanation: If a student ID is ١٠٢٤ in the students table, what links it to the grades table?
٣. The answer "The first column only" to the question "What is a primary key?" is correct.
٤. The answer "A virus" to the question "What is a query?" is correct.
٥. From the lesson explanation: Tables can be connected: a students table and a grades table can be linked by the student ID.
٦. From the lesson explanation: In this lesson we learn about primary keys, linking tables, queries and SQL.
٧. Which question has the answer "The same student ID stored in the grades table"?
٨. The answer "To make tables longer" to the question "Why do we avoid repeating data in database design?" is correct.

B) I practice and answer

١. The answer "A common language for writing database queries" to the question "What is SQL?" is correct.
٢. The answer "A screen type" to the question "What is SQL?" is correct.
٣. The answer "A field whose value is unique for every record in the table" to the question "What is a primary key?" is correct.
٤. From the lesson explanation: Why do we avoid repeating data in database design?
٥. The answer "A drawing program" to the question "What is SQL?" is correct.
٦. Which question has the answer "So every record can be identified exactly"?
٧. The answer "So tables look bigger" to the question "Why must a primary key never repeat?" is correct.
٨. From the lesson explanation: What does consistency mean in a database?

C) I review and play

١. From the lesson explanation: What is SQL?
٢. The answer "To hide data" to the question "Why do we avoid repeating data in database design?" is correct.
٣. From the lesson explanation: Why must a primary key never repeat?
٤. The answer "The font" to the question "If a student ID is ١٠٢٤ in the students table, what links it to the grades table?" is correct.
٥. From the lesson explanation: Good database design avoids repeating data, so each fact is stored once and updated in one place.
٦. The answer "The city name" to the question "What is a good primary key for a students table?" is correct.
٧. Which question has the answer "A field whose value is unique for every record in the table"?
٨. From the lesson explanation: How are two tables connected?

ملخص صوتي وقارئ الدرس

قارئ تجريبي يعمل بصوت جهازك (مجاني). ليس تسجيلًا احترافيًا، وجودة الصوت العربي تختلف من جهاز لآخر. التسجيل الصوتي الاحترافي لم يُنتج بعد.

Lesson topic: Databases ٢. In this second lesson about databases we go one step deeper into how tables stay correct and connected.

We review the key points of the lesson: What is a primary key? -> A field whose value is unique for every record in the table; Why must a primary key never repeat? -> So every record can be identified exactly.

We apply what we learned by answering these questions: What is a primary key? -> A field whose value is unique for every record in the table; Why must a primary key never repeat? -> So every record can be identified exactly; What is a good primary key for a students table? -> A student ID number.

مسار المراجعة للامتحان

  1. Day one (١٠ minutes): We read levels ١ to ٣ together, then solve exercises (A).
  2. Day two (١٠ minutes): We play the level ٤ games and solve exercises (B).
  3. Day three (١٠ minutes): Exercises (C), then the Level One test.
  4. Before the school exam: We repeat the Level Three test and look at the common mistakes.

اختبارات بثلاثة مستويات

Level One Test: The Basics

٨ أسئلة. اجب ثم اضغط «أنهِ الاختبار» لترى درجتك.

١. From the lesson explanation: What is a primary key?
٢. The answer "It may repeat freely" to the question "Why must a primary key never repeat?" is correct.
٣. From the lesson explanation: In this second lesson about databases we go one step deeper into how tables stay correct and connected.
٤. The answer "A cable type" to the question "What is a query?" is correct.
٥. From the lesson explanation: Which question is a query: "Show all students in class ١-A" or "Buy paper"?
٦. The answer "The birth year" to the question "What is a good primary key for a students table?" is correct.
٧. Which question has the answer "Show all students in class ١-A"?
٨. The answer "They cannot connect" to the question "How are two tables connected?" is correct.

المصادر والحقوق

رمز QR هذه الصفحة. يفتح درس «Lesson ٢: Databases ٢» نفسه.