كل المقررات

الرئيسية / مقرر قاعدة البيانات / الفصل 1 الجزء 2

الفصل 1 (الجزء 2): Introduction

Data models, design steps and views

على طول: أنواع نماذج الداتا، وخطوات تصميم قاعدة بيانات، والـ views.

فيديو المحاضرة

فيديو المحاضرة

بعد الفيديو: الأمثلة والاختبار والتمارين والمشروع الصغير تحت.

رسوم متحركة

خطوات تصميم قاعدة بيانات

أمثلة SQL

أمثلة قصيرة وبسيطة

الكود قصير والنتيجة اتجرّبت فعلاً. عدّل في المحرر واضغط شغّل.

المثال ١: جدولين مرتبطين

Sample output (press Run to produce your own):
name | dept 
-----+------
Mona | IT   
Omar | Sales
Nour | IT   
(3 rows)

المثال ٢: ثلاث أنواع من الأوامر

Sample output (press Run to produce your own):
id | price
---+------
1  | 21.0 
2  | 20.0 
(2 rows)

المثال ٣: view بيخفي عمود

Sample output (press Run to produce your own):
id | name
---+-----
1  | Mona
2  | Omar
(2 rows)

افتح الموضوع المقابل في صفحة LiU TDDD12

اختبار قصير

اختبر فهمك

1. A conceptual data model such as ER is:

2. Which step comes right after conceptual design?

3. The DBA is mainly responsible for:

4. A view is:

5. Why use a view for a salary table?

تمارين برمجة

جرّب بإيدك

التمرين 1

اعمل view اسمها it_staff بتعرض موظفي قسم IT بس.

Create a view called it_staff that shows only the IT employees.

(output appears here)

التمرين 2

بعد ما تعمل الـ view، ضيف موظف IT جديد واعرض الـ view تاني. هل ظهر؟

After creating the view, insert a new IT employee and show the view again. Does it appear?

(output appears here)

مشروع صغير في آخر المحاضرة

مكتبة صغيرة بجدولين وview

الداتا: Library sample data: 4 books and 3 members. Written for this course (our own data, free to reuse).

License / source: Our own sample data; SQLite is in the public domain. Dataset page

الخطوات

  1. اعمل جدول book (id, title, copies) وجدول member (id, name, email).
  2. ضيف الداتا اللي في الـ starter.
  3. اعمل view اسمها member_names بتعرض الاسم بس من غير الإيميل.
  4. اعرض الـ view واعرض الكتب اللي نسخها أكتر من 1. المتوقع: 3 أسماء وكتابين.
Expected output (press Run to produce your own):
name
----
Mona
Omar
Nour
(3 rows)
title      | copies
-----------+-------
SQL Basics | 3     
Indexing   | 2     
(2 rows)

مشروع نهاية الفصل

ملف المشروع العملي للفصل 1

ملف PDF فيه مشروع صغير بأسئلة عملية تطبّق بيها كل اللي اتعلمته في الفصل، مع حل نموذجي في الآخر.

افتح ملف المشروع (PDF)

Credits: the topic order follows the lecture list of the course TDDD12 Database Technology at Linköping University (https://www.ida.liu.se/~TDDD12/fo/), whose reading guide is based on the textbook Fundamentals of Database Systems by Elmasri and Navathe. We found no reuse licence on that page, so we link to it and copy nothing from it: the explanations, diagrams, data and code in this lecture are our own. Reference: Elmasri and Navathe, Fundamentals of Database Systems, introduction chapters.