كل المقررات

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

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

What a database system is and why we use one

على طول: يعني إيه DBMS وليه بنستخدمه بدل الملفات العادية.

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

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

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

رسوم متحركة

التطبيقات والـ DBMS والملفات

أمثلة SQL

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

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

المثال ١: أول جدول

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

المثال ٢: الـ schema والـ instance

Sample output (press Run to produce your own):
rows_now
--------
2       
(1 row)
rows_now
--------
3       
(1 row)
name | type   
-----+--------
id   | INTEGER
name | TEXT   
year | INTEGER
(3 rows)

المثال ٣: الـ DBMS بيحمي الداتا

Sample output (press Run to produce your own):
Error: UNIQUE constraint failed: student.id
Error: NOT NULL constraint failed: student.name
id | name
---+-----
1  | Mona
(1 row)

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

اختبار قصير

اختبر فهمك

1. Which is a problem of keeping data in separate plain files?

2. A DBMS is:

3. The data stored in a database right now is called:

4. In the three-schema architecture, which level describes files and indexes?

5. Data independence means we can:

تمارين برمجة

جرّب بإيدك

التمرين 1

اعمل جدول course فيه code و title، وضيف مادتين، واعرض كل الصفوف.

Create a table course(code, title), insert two courses and show all rows.

(output appears here)

التمرين 2

جرّب تضيف صف تاني بنفس الـ code. إيه اللي بيحصل وليه؟

Try to insert a second row with the same code. What happens and why?

(output appears here)

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

أول قاعدة بيانات: جامعة صغيرة

الداتا: University sample data: 5 students with program and year. Written for this course (our own data, free to reuse).

License / source: Our own sample data; the SQL runs on SQLite, which is in the public domain. Dataset page

الخطوات

  1. اعمل جدول student فيه id و name و program و year، والـ id يبقى primary key.
  2. ضيف الخمس طلاب اللي في الـ starter.
  3. اعرض الطلاب اللي في برنامج CS بس.
  4. عدّ كام طالب في كل برنامج. المتوقع: CS = 3 و Math = 2.
Expected output (press Run to produce your own):
name  | year
------+-----
Mona  | 2   
Omar  | 3   
Salma | 1   
(3 rows)
program | students
--------+---------
CS      | 3       
Math    | 2       
(2 rows)

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.