Chapterبەش 3 · Lectureوانە 3.1
Database Systems, Abstraction and Data Modelsسیستەمەکانی بنکەدراوە، ڕووتکردنەوەی دراوە و مۆدێلەکانی دراوە
What a database system is, the three levels at which data is seen (physical, logical and view), the mappings between them and data independence, schema versus instance, and the two kinds of data model, one-, two- and three-tier architectures, the parts inside a DBMS and the data dictionary.
چییە، ئەو سێ ئاستەی لێیانەوە دەبینرێت (فیزیکی، لۆجیکی و دیمەن)، لە نێوانیاندا و ، جیاوازیی و و دوو جۆرەکەی ، تەلارسازیی یەک، دوو و سێ چینی، بەشەکانی ناوەوەی و .
What you will learnچی فێر دەبیت
- Define a database system and say why it gives users an abstract view of data.
- Describe the physical, logical and view levels and give an example of each.
- Explain the two mappings and tell physical from logical data independence.
- Tell a schema from an instance.
- Sort data models into implementation models and conceptual models.
- Describe one-, two- and three-tier database architectures and the main parts inside a DBMS.
- Explain why a database is self-describing: its schema is stored in the data dictionary.
- پێناسە بکەیت و بڵێیت بۆچی وێنەیەکی ڕووتکراوەی دەداتە .
- ، و وەسف بکەیت و بۆ هەر یەکێکیان وێنەیەک بهێنیتەوە.
- هەردوو ڕوون بکەیتەوە و لە جیا بکەیتەوە.
- لە جیا بکەیتەوە.
- بەسەر و دابەش بکەیت.
- تەلارسازیی یەک، دوو و سێ چینیی و بەشە سەرەکییەکانی ناوەوەی وەسف بکە.
- ڕوون بکەرەوە بۆچی خۆی وەسف دەکات: لە هەڵدەگیرێت.
Levels, schemas and modelsئاست، سکیما و مۆدێل
This lesson and the next one form the second part of the course: database systems and E-R modelling. Here you learn what a database system is, the three levels at which the same data can be seen, the difference between a schema and an instance, what data independence means, and the two kinds of data model. The next lesson, E-R modelling, ends with the E-R diagram: the drawing that designers make before a single table is built.
ئەم وانەیە و وانەی داهاتوو بەشی دووەمی کۆرسەکە پێک دەهێنن: و . لێرەدا فێر دەبیت چییە، ئەو سێ ئاستەی کە هەمان لێیانەوە دەبینرێت، جیاوازیی نێوان و ، بە چ مانایەکە و دوو جۆرەکەی . وانەی داهاتوو، مۆدێلی قەوارە و پەیوەندی، بە کۆتایی دێت: ئەو وێنەیەی دیزاینەرەکان پێش دروستکردنی تەنانەت یەک دەیکێشن.
- Database system
- Where the DBMS runs (one, two or three tiers) and what is inside it
- View of data (the three levels of abstraction)
- Instances and schemas, and data independence
- Data models: implementation and conceptual
- Entity-Relationship (E-R) model and E-R diagram – next lesson
- لە کوێ کار دەکات (یەک، دوو یان سێ چین) و چی لە ناوەوەیدایە
- بینینی (سێ ئاستەکەی )
- و ، لەگەڵ
- : و
- و – وانەی داهاتوو
What a database system isسیستەمی بنکەدراوە چییە
A together with the and the programs that let users reach and change its data. Its main job is to give users a simple picture of the data and hide how it is stored.
لەگەڵ و ئەو بەرنامانەی ڕێگە بە دەدەن دراوەکانی بخوێننەوە و بیانگۆڕن. ئەرکی سەرەکیی ئەوەیە وێنەیەکی سادەی دراوە بداتە بەکارهێنەران و چۆنیەتی خەزنکردنەکەی بشارێتەوە.
The course defines a database system as a collection of interrelated data together with a set of programs that let users reach that data and change it. Interrelated means the pieces of data are linked: a mark belongs to a student and to a course.
کۆرسەکە بەم شێوەیە پێناسە دەکات: کۆمەڵێک بەیەکەوە پەیوەست، لەگەڵ کۆمەڵێک بەرنامە کە ڕێگە بە دەدەن دەستیان بە ڕابگات و بیانگۆڕن. بەیەکەوە پەیوەست واتە پارچەکانی بە یەکترەوە بەستراون: نمرەیەک سەر بە قوتابییەک و وانەیەکە.
For instance, a university's registration system is a database system. Its data are the students, courses, lecturers and marks, all linked together. Its programs are the DBMS itself, the registration screen, the page where lecturers enter marks and the program that prints transcripts.
بۆ وێنە، سیستەمی ناونووسینی زانکۆیەک . بریتین لە قوتابیان، وانەکان، مامۆستایان و نمرەکان، کە هەموویان بەیەکەوە بەستراون. بەرنامەکانی بریتین لە خودی ، شاشەی ناونووسین، ئەو لاپەڕەیەی مامۆستایان نمرەی تێدا دەنووسن و ئەو بەرنامەیەی بەڵگەنامەی نمرەکان چاپ دەکات.
The main purpose of a database system is to give users an abstract view of data: a simple picture of the data that hides how and where it is really kept.
ئامانجی سەرەکیی ئەوەیە وێنەیەکی ڕووتکراوەی بداتە : وێنەیەکی سادەی کە دەیشارێتەوە بە ڕاستی چۆن و لە کوێ هەڵگیراوە.
Where the DBMS runs: one, two or three tiersسیستەمی بەڕێوەبردنی بنکەدراوە لە کوێ کار دەکات: یەک، دوو یان سێ چین
A database system can be arranged in different ways. The question is: on which computers do the screens, the program and the DBMS run?
دەکرێت بە چەند شێوەیەک ڕێک بخرێت. پرسیارەکە ئەمەیە: شاشەکان، و لەسەر کام کار دەکەن؟
- One tier (centralised): the screens, the program, the DBMS and the data are on one computer, such as an Access or SQLite file on one laptop.
- Two tiers: a program on the user's PC (the ) shows the screens and sends queries over the network, through a driver such as ODBC or JDBC, to the DBMS server, which runs the queries and transactions.
- Three tiers: the browser or phone app (presentation) talks to a web server with the program and its rules (the application tier: Apache with PHP in XAMPP), and only that tier talks to the database server: the five steps of PHP and a database.
- یەک چین (ناوەندی): شاشەکان، ، و لەسەر یەک ، وەک Access یان SQLite لەسەر یەک لاپتۆپ.
- دوو چین (): لەسەر () شاشەکان پیشان دەدات و بە ناو ، لە ڕێگەی درایڤەرێکی وەک ODBC یان JDBCـەوە، دەنێرێت بۆ کە و جێبەجێ دەکات.
- سێ چین (): یان ئەپی مۆبایل (پیشاندان) قسە لەگەڵ دەکات کە و ڕێساکانی لەسەرە (چینی : Apache لەگەڵ PHP لە XAMPPدا) و تەنها ئەو چینە قسە لەگەڵ دەکات: پێنج هەنگاوەکەی PHP و بنکەدراوە.
Where the DBMS runs: one, two or three tiersسیستەمی بەڕێوەبردنی بنکەدراوە لە کوێ کار دەکات: یەک، دوو یان سێ چین
Inside the DBMSناوەوەی سیستەمی بەڕێوەبردنی بنکەدراوە
Inside, a DBMS is built from parts. A statement travels down through them to the disk:
لە ناوەوە لە چەند بەشێک دروست کراوە. ڕستەیەک بە ناویاندا دەچێتە خوارەوە تا دەگاتە دیسک:
- : the DDL compiler stores every definition in the . Other statements are checked, the picks the fastest plan, and the plan is run.
- : checks rights and integrity rules, keeps pages of data in memory (buffer manager) and reads and writes the files (file manager).
- : lets many users work at once and recovers after a crash, using the log.
- On disk: the data, the indexes, the data dictionary and statistics that help the optimizer.
- : هەموو پێناسەیەک لە هەڵدەگرێت. ڕستەکانی تر دەپشکنرێن، خێراترین پلان هەڵدەبژێرێت و پلانەکە جێبەجێ دەکرێت.
- : و دەپشکنێت، لاپەڕەکانی لە بیرگەدا ڕادەگرێت (بەڕێوەبەری ) و دەخوێنێتەوە و دەنووسێت (بەڕێوەبەری ).
- : ڕێگە بە چەندین دەدات پێکەوە کار بکەن و دوای تێکچوون، بە یارمەتیی ، دەگەڕێنێتەوە.
- لەسەر دیسک: ، ، و ئامار کە یارمەتیی دەدات.
The core that stores the data and runs the queries is the ; MySQL's default is InnoDB. SQLite's own layers are in SQLite basics.
ئەو ناوکەی هەڵدەگرێت و جێبەجێ دەکات ؛ بنەڕەتییەکەی MySQL InnoDBـە. چینەکانی خودی SQLite لە بنەماکانی SQLiteدان.
Where the DBMS runs: one, two or three tiersسیستەمی بەڕێوەبردنی بنکەدراوە لە کوێ کار دەکات: یەک، دوو یان سێ چین
Utilities and tools around the DBMSبەرنامەکانی خزمەتگوزاری و ئامرازەکانی دەوری سیستەمی بەڕێوەبردنی بنکەدراوە
Around the DBMS, the DBA uses :
لە دەوری ، DBA بەکاردەهێنێت:
- Load and import: bring in data from files, such as a CSV file exported from a spreadsheet.
- Backup: copy the database regularly: Backup and recovery.
- Reorganise storage: rebuild indexes and compact files so they stay fast.
- Monitor performance: for example MySQL's slow query log lists the queries that take too long.
- بارکردن و هاوردەکردن: هێنانی لە ، وەک CSV کە لە دەرهێنراوە.
- : کۆپیکردنی بە شێوەی ڕێکوپێک: باکئەپ و گەڕاندنەوەی دراوە.
- ڕێکخستنەوەی خەزنکردن: دووبارە دروستکردنەوەی و پچووککردنەوەی بۆ ئەوەی خێرا بمێننەوە.
- چاودێریکردنی ئەدا: بۆ نموونە پرسە خاوەکانی MySQL (slow query log) ئەو لیست دەکات کە زۆر کات دەبەن.
Designers and programmers add tools: design (CASE) tools that draw E-R diagrams and create the tables from them, such as MySQL Workbench, pgAdmin or DBeaver, and development environments for building the applications. Communication software joins clients and servers over the network.
دیزاینەر و ئامراز زیاد دەکەن: ئامرازی دیزاین (CASE) کە دەکێشن و لێ دروست دەکەن، وەک MySQL Workbench، pgAdmin یان DBeaver؛ هەروەها ژینگەی گەشەپێدان بۆ دروستکردنی . پەیوەندی و بە ناو بەیەکەوە دەبەستێت.
Data abstraction: hide what users do not needڕووتکردنەوەی دراوە: شاردنەوەی ئەوەی بەکارهێنەرەکان پێویستیان پێی نییە
Hiding the complex details of how data is stored, so each user sees only the simple level they need. Databases use three levels: the , the and the .
شاردنەوەی وردەکارییە ئاڵۆزەکانی چۆنیەتی خەزنکردنی دراوەیە، بۆ ئەوەی هەر بەکارهێنەرێک تەنها ئەو ئاستە سادەیە ببینێت کە پێویستیەتی. سێ ئاست بەکاردەهێنن: ، و .
Many users of a database system are not trained in computers. So the developers hide the complexity from them through several levels of abstraction, to make their work with the system simpler. Abstraction means showing only what is needed and hiding the rest.
زۆرێک لە ڕاهێنانیان لەسەر نەکردووە. بۆیە گەشەپێدەران ئاڵۆزییەکە لە ڕێگەی چەند ئاستێکی ڕووتکردنەوەوە لێیان دەشارنەوە، بۆ ئەوەی کارکردنیان لەگەڵ سیستەمەکە سادەتر بێت. ڕووتکردنەوە واتە تەنها ئەوەی پێویستە پیشان بدرێت و ئەوانی تر بشاردرێنەوە.
There are three levels of data abstraction:
سێ ئاستی هەیە:
- Physical level – the lowest
- Logical level – the middle
- View level – the highest
- – نزمترینیان
- – ناوەڕاست
- – بەرزترینیان
Think of a busy restaurant in the bazaar. A customer sees only the menu: a few dishes with their prices. The cook works from the full list of dishes and recipes – every dish and which ingredients belong to it. The storekeeper knows where everything is kept: which sack is on which shelf, what is in the fridge. It is one kitchen seen at three depths: the menu is the view level, the recipe list is the logical level, and the storeroom is the physical level.
چێشتخانەیەکی قەرەباڵغ لە بازاڕدا بهێنە بەرچاوت. کڕیار تەنها مینیوەکە دەبینێت: چەند خواردنێک لەگەڵ نرخەکانیان. چێشتلێنەر لە لیستی تەواوی خواردن و ڕێچێشتەکانەوە کار دەکات – هەموو خواردنێک و ئەوەی چ کەرەستەیەکی تێدەچێت. کۆگاوان دەزانێت هەموو شتێک لە کوێ هەڵگیراوە: کام گوونیە لەسەر کام ڕەفە و چی لە سەلاجەکەدایە. ئەمە یەک چێشتخانەیە کە لە سێ قووڵاییدا دەبینرێت: مینیوەکە ، لیستی ڕێچێشتەکان و کۆگاکە .
Where the analogy stops workingسنووری ئەم نموونەیە
In a restaurant each level is kept by a different person. In a database the DBMS keeps all three levels in step by itself: when the data changes, every level shows the change at once.
لە چێشتخانەدا هەر ئاستێک کەسێکی جیاواز ئاگای لێیەتی. لە خۆی هەر سێ ئاستەکە هاوکات ڕادەگرێت: کاتێک دەگۆڕێت، هەموو ئاستەکان یەکسەر گۆڕانەکە پیشان دەدەن.
Why a DBMS hides detail from users, and the three levels of data abstraction: physical, logical and view, each with an example.
بۆچی وردەکارییەکان لە دەشارێتەوە و سێ ئاستەکەی : ، و ، هەریەکەیان بە نموونەیەک.
From 0:31 to the end: data abstraction and the physical, logical and view levels.
لە 0:31 تا کۆتایی سەیر بکە: و هەر سێ ئاستەکەی (، و ).
The three levels of dataسێ ئاستەکەی دراوە
The picture shows the three levels, which textbooks call the three-schema architecture. Each level has its own description, or schema: one internal schema at the bottom, one conceptual schema in the middle and many external schemas (views) at the top.
وێنەکە سێ ئاستەکە پیشان دەدات، کە کتێبەکان پێی دەڵێن تەلارسازیی سێ . هەر ئاستێک وەسفی تایبەتی خۆی هەیە، واتە خۆی: یەک ناوەکی لە خوارەوە، یەک چەمکی لە ناوەڕاستدا و چەندین دەرەکی () لە سەرەوە.
The idea comes from the ANSI/SPARC committee of the American National Standards Institute, whose reports of 1975 to 1978 proposed it to give programs independence from the data and many user views. It explains and guides DBMS design: real products do not keep three separate schemas for everything, but all of them offer views (external) and storage choices (internal). A view need not look like the tables: it can be one flat list joined from two tables, or a nested list, each department with its students, like the JSON an app receives.
ئەم بیرۆکەیە لە لیژنەی ANSI/SPARCـی دامەزراوەی ستانداردە نیشتمانییەکانی ئەمریکاوە هاتووە، کە ڕاپۆرتەکانی 1975 تا 1978 پێشنیاریان کرد بۆ ئەوەی لە سەربەخۆ بن و جیاوازیان هەبێت. ڕێنمایی دیزاینی دەکات و ڕوونی دەکاتەوە: بەرهەمە ڕاستەقینەکان سێ جیا بۆ هەموو شتێک ناهێڵنەوە، بەڵام هەموویان (دەرەکی) و هەڵبژاردەی خەزنکردن (ناوەکی) دەدەن. پێویست ناکات لە بچێت: دەکرێت یەک لیستی ڕێک بێت کە لە دوو پێکەوە لکێنراوە، یان لیستێکی ناوەکی، هەر بەشێک لەگەڵ قوتابیانەکەی، وەک ئەو ئەپێک وەریدەگرێت.
The three levels of dataسێ ئاستەکەی دراوە
Each level in detailهەر ئاستێک بە وردی
| Levelئاست | What it describesچی وەسف دەکات | University exampleلە زانکۆدا |
|---|---|---|
| Physical (internal) – the lowest (ناوەکی) – نزمترین | How the data is actually stored in physical form. Its internal schema describes the storage structure: files, blocks on the disk, indexes. بە ڕاستی چۆن بە شێوەی فیزیکی هەڵگیراوە. ناوەکی پێکهاتەی خەزنکردنەکە وەسف دەکات: ، بلۆکەکانی سەر دیسک و . | “Student rows are kept in the file student.ibd, in order of student_id, with an index on name.”« قوتابی لە student.ibdـدا، بە ڕیزبەندیی student_id هەڵگیراون و لەسەر name هەیە.» |
| Logical (conceptual) – the middle (چەمکی) – ناوەڕاست | What data is stored in the database and what relationships exist among these data – for the whole database. Its description is the conceptual schema.چ لە هەڵگیراوە و چ لە نێوان ئەو هەیە – بۆ هەموو . وەسفەکەی پێی دەوترێت چەمکی. | “Every student has an id, a name and a birth date, and can take many courses.”«هەر قوتابییەک id، ناو و ڕێکەوتی لەدایکبوونی هەیە و دەتوانێت چەندین وانە بخوێنێت.» |
| View (external) – the highest (دەرەکی) – بەرزترین | Only part of the entire database. It has an external schema, or user view: how one group of users sees the data.تەنها بەشێک لە هەموو . دەرەکی، واتە هەیە: کۆمەڵێک چۆن دەبینن. | “The library screen shows a student's name and borrowed books, but never her marks.”«شاشەی کتێبخانە ناوی قوتابییەک و ئەو کتێبانەی خواستوونی پیشان دەدات، بەڵام هەرگیز نمرەکانی نا.» |
Who works at each level? The DBA and the designers work mainly at the logical level, where the whole design lives; the DBA also decides physical matters such as indexes. Application programs and end users work at the view level. The physical level is handled mostly by the DBMS itself.
کێ لە هەر ئاستێکدا کار دەکات؟ و دیزاینەرەکان زیاتر لە کار دەکەن، کە هەموو دیزاینەکەی تێدایە؛ بڕیار لەسەر کاروباری فیزیکیش دەدات، وەک . و بەکارهێنەرانی کۆتایی لە کار دەکەن. زیاتر خودی بەڕێوەی دەبات.
Mappings and data independenceهاوتاکردنەکانی سکیما و سەربەخۆیی دراوە
Look again at the arrows between the levels in the picture. The DBMS keeps two mappings – rules that connect one level to the next:
جارێکی تر سەیری تیرەکانی نێوان ئاستەکان بکە لە وێنەکەدا. دوو ڕادەگرێت – ئەو ڕێسایانەی هەر ئاستێک بە ئاستی دواترەوە دەبەستنەوە:
- External/conceptual mapping: how each view is built from the conceptual schema – which tables and columns it takes and what it calls them.
- Conceptual/internal mapping: how each table of the conceptual schema is really stored – in which file, in what order, with which indexes.
- هاوتاکردنی دەرەکی/چەمکی: هەر چۆن لە چەمکییەوە دروست دەکرێت – کام و وەردەگرێت و چ ناوێکیان لێ دەنێت.
- هاوتاکردنی چەمکی/ناوەکی: هەر چەمکی بە ڕاستی چۆن هەڵدەگیرێت – لە کام ، بە چ ڕیزبەندییەک و چ هەیە.
Because of these mappings, a change at one level can be absorbed by changing only the mapping, so the level above does not notice it. This is data independence: the ability to change the schema at one level of a database system without having to change the schema at the next higher level.
بەهۆی ئەم دوو هاوتاکردنەوە، دەکرێت گۆڕانکارییەک لە ئاستێکدا تەنها بە گۆڕینی هاوتاکردنەکە وەربگیرێت، بۆیە ئاستەکەی سەرەوە هەستی پێ ناکات. ئەمە : توانای گۆڕینی لە ئاستێکی بەبێ ئەوەی پێویست بکات لە ئاستی سەرووتردا بگۆڕدرێت.
Being able to change the at one level of a database without changing the schema at the next higher level, or the programs that use it.
توانای گۆڕینی لە ئاستێکی بەبێ ئەوەی سکیمای ئاستی سەرووتر، یان ئەو بەرنامانەی بەکاری دەهێنن، بگۆڕدرێن.
The internal, conceptual and external schemas, and how logical and physical data independence let one level change without breaking the level above.
ناوەکی، چەمکی و دەرەکی، هەروەها چۆن و ڕێگە دەدەن ئاستێک بگۆڕێت بێ ئەوەی ئاستەکەی سەرەوەی تێک بچێت.
From 0:35 to the end: the three schemas, then logical and physical data independence.
لە 0:35 تا کۆتایی سەیر بکە: سێ ، پاشان و .
Mappings and data independenceهاوتاکردنەکانی سکیما و سەربەخۆیی دراوە
Logical and physical data independenceسەربەخۆیی لۆجیکیی دراوە و سەربەخۆیی فیزیکیی دراوە
| Kindجۆر | You can change…دەتوانیت بگۆڕیت… | …without changing…بەبێ گۆڕینی | Exampleبۆ وێنە |
|---|---|---|---|
| Physical data independence | the internal schema (physical level) ناوەکی () | the conceptual schema چەمکی | The DBA moves the database to faster SSD disks, or adds an index on name. The tables and the programs stay the same; only the conceptual/internal mapping changes. دەگوازێتەوە بۆ دیسکی SSDـی خێراتر، یان لەسەر name زیاد دەکات. و بەرنامەکان وەک خۆیان دەمێننەوە؛ تەنها هاوتاکردنی چەمکی/ناوەکی دەگۆڕێت. |
| Logical data independence | the conceptual schema (logical level) چەمکی () | the external schemas and their application programs دەرەکی و | The designer adds a phone column to student. The library's view and the program that uses it keep working; only the external/conceptual mapping changes.دیزاینەر بە ناوی phone بۆ student زیاد دەکات. کتێبخانە و ئەو بەرنامەیەی بەکاری دەهێنێت بەردەوام کار دەکەن؛ تەنها هاوتاکردنی دەرەکی/چەمکی دەگۆڕێت. |
Schema and instanceسکیما و نموونە
The schema is the overall design of the database: which tables there are, which columns they have, their types and the keys that link them. It is planned once and changes rarely.
دیزاینە گشتییەکەی : چ هەیە، هەر چ هەیە، جۆرەکانیان و ئەو بەیەکەوەیان دەبەستنەوە. یەکجار پلان دەکرێت و کەم دەگۆڕێت.
A database changes over time, as information is inserted or deleted. The collection of information stored in the database at one particular moment is called an instance of the database.
بە تێپەڕبوونی کات دەگۆڕێت، چونکە زیاد دەکرێت یان دەسڕدرێتەوە. ئەو کۆمەڵە لە ساتێکی دیاریکراودا لە هەڵگیراوە پێی دەوترێت .
student_id | name | city |
|---|---|---|
| 101 | Aram | Erbil |
| 102 | Shilan | Sulaymaniyah |
| 103 | Rezan | Duhok |
At 09:05 a new student, Karwan from Halabja, registers. Now the instance has four rows – but the schema is exactly the same: still three columns with the same names and types. Every insert, update or delete creates a new instance; only a design change (such as adding a column) changes the schema.
لە کاتژمێر 09:05دا قوتابییەکی نوێ، کاروان لە هەڵەبجە، ناوی تۆمار دەکات. ئێستا چوار هەیە – بەڵام ڕێک وەک خۆیەتی: هێشتا سێ بە هەمان ناو و جۆر. هەر زیادکردن، نوێکردنەوە یان سڕینەوەیەک نوێ دروست دەکات؛ تەنها گۆڕینی دیزاین (وەک زیادکردنی ) دەگۆڕێت.
A teacher prints an attendance sheet with three columns: No., Name and Signature. The empty printed sheet is like the schema. Today's sheet, signed by the students who came, is an instance; tomorrow's signed sheet is another instance of the same schema. Programmers know the same idea: a variable's type is like the schema, and its value at one moment is like an instance.
مامۆستایەک پەڕەیەکی ئامادەبوون چاپ دەکات کە سێ هەیە: ژمارە، ناو و واژۆ. پەڕە چاپکراوە بەتاڵەکە وەک وایە. پەڕەکەی ئەمڕۆ، کە ئەو قوتابیانەی هاتوون واژۆیان کردووە، ؛ پەڕە واژۆکراوەکەی سبەی ترە لە هەمان . هەمان بیرۆکە دەناسن: جۆری وەک وایە و لە ساتێکدا وەک .
Where the analogy stops workingسنووری ئەم نموونەیە
A paper sheet is replaced once a day. A database instance changes continuously, row by row, every time someone saves a change.
پەڕەی کاغەز ڕۆژی جارێک دەگۆڕدرێت. بەردەوام دەگۆڕێت، بە ، هەر جارێک کەسێک گۆڕانکارییەک پاشەکەوت بکات.
The schema is the design of a database and rarely changes; an instance is the data stored at one moment, which changes all the time.
دیزاینی و بە دەگمەن دەگۆڕێت؛ واتە ناو لە یەک ساتدا، کە هەمیشە دەگۆڕێن.
Watch 0:00-8:29: schema versus instance, with an example.
لە 0:00 تا 8:29 سەیر بکە: بەرامبەر ، بە میساڵێکی سادە.
Schema and instanceسکیما و نموونە
The database describes itselfبنکەدراوە خۆی وەسف دەکات
Where is the schema kept? Inside the database itself. When a table is created, the DDL compiler stores its description (names, types, keys, rules, users and their rights) in the , also called the system catalog. This description is metadata: data about data. So a database is self-describing: any program can find out what tables and columns it has.
لە کوێ هەڵدەگیرێت؟ لەناو خودی . کاتێک دروست دەکرێت، وەسفەکەی (ناو، جۆر، ، ڕێسا، و مافەکانیان) لە هەڵدەگرێت، کە پێی دەوترێت کاتالۆگی سیستەمیش. ئەم وەسفە مێتاداتایە: دەربارەی . بۆیە خۆی وەسف دەکات: هەر دەتوانێت بزانێت چ و هەیە.
The catalog is active: the DBMS reads it on every query, for example to check that a column exists and that you may read it. A passive dictionary is only documentation for people. You have met one already: in phpMyAdmin, information_schema is MySQL's catalog shown as a read-only database (phpMyAdmin). SQLite keeps its catalog in a table called sqlite_schema.
کاتالۆگەکە چالاکە: لە هەموو دەیخوێنێتەوە، بۆ نموونە بۆ ئەوەی بپشکنێت هەیە و تۆ بۆت هەیە بیخوێنیتەوە. فەرهەنگێکی ناچالاک تەنها بەڵگەنامەیە بۆ خەڵک. پێشتر یەکێکت بینیوە: لە ، information_schema کاتالۆگی MySQLـە کە وەک تەنها-خوێندنەوە پیشان دەدرێت (phpMyAdmin). SQLite کاتالۆگەکەی لە بە ناوی sqlite_schema هەڵدەگرێت.
Schema and instanceسکیما و نموونە
More words: state, snapshot and schema diagramوشەی زیاتر: دۆخ، وێنەی ساتێک و هێڵکاریی سکیما
Textbooks have more names for these ideas. The instance is also called the database state or a snapshot. The state right after the data is first loaded is the initial state. A valid state obeys every rule of the schema: the DBMS refuses any change that would make the state invalid, such as a mark of 150. The schema is also called the intension and the state the extension.
کتێبەکان ناوی تریشیان بۆ ئەم بیرۆکانە هەیە. پێی دەوترێت دۆخی (database state) یان وێنەی ساتێکیش (snapshot). دۆخەکە ڕاست دوای یەکەم بارکردنی دۆخی سەرەتایە. دۆخی دروست هەموو ڕێساکانی ڕەچاو دەکات: هەر گۆڕانکارییەک ڕەت دەکاتەوە کە دۆخەکە نادروست بکات، وەک نمرەی 150. پێی دەوترێت intension و دۆخەکەش extension.
A schema diagram draws the schema without any data: one box per table with its columns, the keys underlined, and arrows from each foreign key to the key it points to. Each object in it, such as the student table, is a schema construct. The keys lesson draws one for a university: our example.
هێڵکاریی بەبێ هیچ دەکێشێت: بۆ هەر چوارگۆشەیەک بە ، هێڵ بەژێرداکێشراو و تیر لە هەر بۆ ئەو ئاماژەی پێ دەکات. هەر شتێکی ناوی، وەک قوتابیان، پێی دەوترێت schema construct. وانەی یەکێک بۆ زانکۆیەک دەکێشێت: نموونەکەمان.
Data modelsمۆدێلەکانی دراوە
A way of describing the structure of data and the relationships between data in a database. There are two kinds: , such as the , and , such as the relational model.
شێوازێکی وەسفکردنی پێکهاتەی دراوە و پەیوەندییەکانی نێوانیانە لە . دوو جۆری هەیە: (وەک ) و (وەک مۆدێلی پەیوەندیدار).
A data model is a model used to represent the data structure and the data relationships within the database. In other words, it is a way of describing what the data looks like and how its parts fit together.
مۆدێلێکە کە بۆ نیشاندانی پێکهاتەی و نێوان لەناو بەکار دێت. بە واتایەکی تر، شێوازێکە بۆ وەسفکردنی ئەوەی چۆنە و بەشەکانی چۆن لەگەڵ یەکتر دەگونجێن.
Data models can be grouped into two categories:
لە دوو پۆلدا کۆدەکرێنەوە:
- Implementation models focus on how the data is represented in the database. They include the hierarchical, network, relational and object-oriented data models.
- Conceptual models are concerned with what is represented in the database, rather than with how it is represented. They include the Entity-Relationship (E-R) model.
- جەخت لەسەر ئەوە دەکەنەوە کە چۆن لە دەردەبڕدرێت. مۆدێلی هەرەمی، ڕایەڵەیی، پەیوەندیدار و تەنخواز دەگرنەوە.
- گرنگی بەوە دەدەن کە چی لە دەردەبڕدرێت، نەک چۆن دەردەبڕدرێت. دەگرنەوە.
Data modelsمۆدێلەکانی دراوە
What a data model contains, and three kindsمۆدێلی دراوە چی لەخۆ دەگرێت و سێ جۆرەکەی
Textbooks define a data model by three parts: structures (data types, groups of data such as records or tables, and the links between them); operations that read and change the data, both basic ones (insert, delete, update) and user-defined ones (work out a student's average); and constraints that valid data must always obey. For the relational model: tables, SQL's operations, and keys and rules.
کتێبەکان بە سێ بەش پێناسە دەکەن: پێکهاتەکان (، کۆمەڵە وەک یان و بەستەرەکانی نێوانیان)؛ ئەو کارانەی دەخوێننەوە و دەیگۆڕن، هەم بنەڕەتییەکان (زیادکردن، سڕینەوە، نوێکردنەوە) و هەم ئەوانەی پێناسەیان دەکات (دۆزینەوەی تێکڕای نمرەی قوتابییەک)؛ و : ئەو ڕێسایانەی دروست هەمیشە دەبێت ڕەچاویان بکات. بۆ مۆدێلی پەیوەندیدار: ، کارەکانی و و ڕێساکان.
Books also sort models into three kinds: conceptual (close to how users see the data, such as the E-R model), representational or implementation (used by DBMS products: relational, network, hierarchical, object) and physical (files, record formats and indexes on disk). The course's two kinds leave out the physical one, which matches the physical level.
کتێبەکان مۆدێلەکان دەکەن بە سێ جۆریش: چەمکی (نزیک لەوەی دەبینن، وەک )، نوێنەرایەتی (representational) یان (کە بەرهەمەکانی بەکاری دەهێنن: پەیوەندیدار، ڕایەڵەیی، هەرەمی، تەنخواز) و فیزیکی (، شێوەی و لەسەر دیسک). دوو جۆرەکەی کۆرسەکە جۆری فیزیکی ناهێنن، کە لەگەڵ ئاستی فیزیکی دەگونجێت.
A data model is the tool that makes data abstraction possible. Some books call the high-level model that names no product an information model; detailed data models for one DBMS are made from it.
ئەو ئامرازەیە کە ڕووتکردنەوەی دراوە دەکاتە شتێکی گونجاو. هەندێک کتێب بە مۆدێلی ئاستبەرز کە ناوی هیچ بەرهەمێک ناهێنێت دەڵێن مۆدێلی (information model)؛ وردەکاری بۆ یەک لێیەوە دروست دەکرێن.
Data modelsمۆدێلەکانی دراوە
The four implementation modelsچوار جۆری مۆدێلی جێبەجێکردن
- Hierarchical model – records are arranged in a tree. Each record has one parent and may have many children, like a family tree. You met it in The DBMS.
- Network model – records are linked like a net (a graph), so one record can have several parents. For instance, one course record can be linked to two teacher records and to a room record. It is an older model and is not the same as a database spread over a computer network.
- Relational model – data is kept in tables, and the tables are linked by keys. It is the most used model today: MySQL, SQL Server, Oracle, PostgreSQL and SQLite are relational.
- Object-oriented model – data is stored as objects, which keep their data and their behaviour together, as in object-oriented programming.
- مۆدێلی هەرەمی () – وەک دارێک ڕێکدەخرێن. هەر یەک باوانی هەیە و دەکرێت چەندین منداڵی هەبێت، وەک داری بنەماڵە. لە وانەی سیستەمی بەڕێوەبردنی بنکەدراوە ناسیت.
- مۆدێلی ڕایەڵەیی () – وەک تۆڕێک (گراف) بەیەکەوە دەبەسترێن، بۆیە یەک دەکرێت چەند باوانێکی هەبێت. بۆ وێنە، یەک وانە دەکرێت بە دوو مامۆستا و ژوورەوە ببەسترێت. مۆدێلێکی کۆنترە و هەمان شت نییە لەگەڵ کە بەسەر تۆڕێکی کۆمپیوتەریدا بڵاو بووبێتەوە.
- مۆدێلی پەیوەندیدار () – لە هەڵدەگیرێت و بە بەیەکەوە دەبەسترێن. ئەمڕۆ زۆرترین بەکارهێنراوە: MySQL، SQL Server، Oracle، PostgreSQL و SQLite پەیوەندیدارن.
- مۆدێلی تەنخواز () – وەک هەڵدەگیرێت، کە و ڕەفتاریان پێکەوە هەڵدەگرن، وەک لە .
Flat files and network setsفایلی ڕێک و کۆمەڵەکانی مۆدێلی ڕایەڵەیی
The first step was the flat file: one big table. It cannot hold several kinds of thing with links between them: an airline needs flights, crews and passengers, and the link passenger is booked on flight. The hierarchical, network and relational models all solve this.
یەکەم هەنگاو ڕێک (flat file) بوو: یەک گەورە. ناتوانێت چەند جۆرە شتێک لەگەڵ بەستەری نێوانیان هەڵبگرێت: کۆمپانیایەکی فڕۆکەوانی پێویستی بە گەشت، دەستەی کارمەندان و گەشتیار و بەستەری گەشتیار لەسەر گەشتێک حیجز کراوە هەیە. مۆدێلی هەرەمی، ڕایەڵەیی و پەیوەندیدار هەموویان ئەمە چارەسەر دەکەن.
In the network model (CODASYL), record types are joined by named sets. Each set has an owner type and a member type. In a hospital, a doctor owns many patients and a ward owns many patients, so one patient is a member of two sets, with owners of two different types. Two rules: a record cannot have two owners of the same type (one doctor, one ward), and records of the same type cannot be linked.
لە مۆدێلی ڕایەڵەیی (CODASYL)دا، جۆرەکانی بە کۆمەڵەی ناودار (sets) بەیەکەوە دەبەسترێن. هەر کۆمەڵەیەک جۆرێکی خاوەن (owner) و جۆرێکی ئەندام (member)ی هەیە. لە نەخۆشخانەیەکدا، دکتۆرێک خاوەنی چەندین نەخۆشە و قاوشێک خاوەنی چەندین نەخۆشە، بۆیە یەک نەخۆش ئەندامی دوو کۆمەڵەیە، بە دوو خاوەنی دوو جۆری جیاواز. دوو ڕێسا: ناتوانێت دوو خاوەنی هەمان جۆری هەبێت (یەک دکتۆر، یەک قاوش) و هەمان جۆر ناتوانن بەیەکەوە ببەسترێن.
Programs reach this data by following the links one record at a time. Why that made the navigational models lose to the relational one is told in A short history.
بە گرتنی بەستەرەکان، هەر جارە یەک ، دەگەنە ئەم . بۆچی ئەمە وای کرد مۆدێلە ڕێگادۆزەکان لە بەرامبەر مۆدێلی پەیوەندیدار بدۆڕێن، لە مێژوویەکی کورتدا گێڕدراوەتەوە.
Objects, and where tables are awkwardئۆبجێکتەکان و ئەو شوێنانەی خشتە تێیاندا نالەبارە
Object databases follow four ideas: complex objects (an object can hold other objects and lists); encapsulation (data and kept together); object identity (an object stays itself even when all its values change); and (a new class is built from an old one).
چوار بیرۆکە دەگرنە بەر: ئاڵۆز ( دەتوانێت و لیستی تر لەناو خۆیدا هەڵبگرێت)؛ پێکەوەداخستن (encapsulation: و پێکەوە ڕادەگیرێن)؛ ناسنامەی (object identity: هەر خۆی دەمێنێتەوە تەنانەت ئەگەر هەموو بگۆڕێن)؛ و ( نوێ لە کۆنەوە دروست دەکرێت).
Tables work best for many rows with simple operations on a few tables. They are awkward for parts made of parts (a car, its engine, the engine's pistons…: all parts at any depth needs a query that repeats itself), for drawings in CAD, and for graph-like data such as friends of friends. That is why object, graph and document models exist.
بۆ زۆر لەگەڵ کاری سادە لەسەر چەند باشترین کار دەکەن. بۆ پارچەی پێکهاتوو لە پارچە نالەبارن (ئۆتۆمبێلێک، بزوێنەرەکەی، پستۆنەکانی بزوێنەرەکە…: هەموو پارچەکان لە هەر قووڵاییەکدا پێویستی بە هەیە کە خۆی دووبارە بکاتەوە)، بۆ وێنەکێشان بە CAD و بۆ کە شێوەی هەیە، وەک هاوڕێی هاوڕێکان. بۆیە مۆدێلی تەنخواز، گراف و بەڵگەنامە هەن.
Common mistakesهەڵە باوەکان
| Mistakeهەڵە | What is rightڕاستییەکە |
|---|---|
| “The three levels are three copies of the data.”«سێ ئاستەکە سێ کۆپیی .» | They are three descriptions of the same data. Only the physical level is really stored.سێ وەسفی هەمان . تەنها بە ڕاستی هەڵگیراوە. |
| “The logical level is what the user sees.”« ئەوەیە کە دەیبینێت.» | What one user sees is the view level. The logical level is the design of the whole database.ئەوەی یەک دەیبینێت . دیزاینی هەموو . |
| “Schema and instance mean the same.”« و یەک مانایان هەیە.» | Schema = the design (rarely changes). Instance = the data at one moment (changes all the time). = دیزاینەکە (کەم دەگۆڕێت). = لە ساتێکدا (هەمیشە دەگۆڕێت). |
| “Physical data independence means the data is stored separately.”« واتە بە جیا هەڵدەگیرێت.» | It means you can change the internal schema (disks, files, indexes) without changing the conceptual schema.واتە دەتوانیت ناوەکی (دیسک، ، ) بگۆڕیت بەبێ گۆڕینی چەمکی. |
| “The E-R model is an implementation model.”« .» | It is a conceptual model: it says what is stored, not how.: دەڵێت چی هەڵدەگیرێت، نەک چۆن. |
| “The network model means a database on a computer network.”«مۆدێلی ڕایەڵەیی واتە لەسەر تۆڕێکی کۆمپیوتەری.» | No: it means records linked like a net. A database spread over several computers is a distributed database.نەخێر: واتە وەک تۆڕ بەیەکەوە بەستراون. کە بەسەر چەند بڵاو بووبێتەوە . |
Exercises and quick checkڕاهێنان و پشکنینی خێرا
Name the level (physical, logical or view) that each sentence describes: (a) “The marks table is stored in three files on disk D.” (b) “The parents' app shows only their child's marks and attendance.” (c) “Each student belongs to one class; each class has many students.” (d) “An index on the student's name speeds up searches.”
ئاستی هەر ڕستەیەک دیاری بکە (فیزیکی، لۆجیکی یان دیمەن): (أ) « نمرەکان لە سێ لەسەر دیسکی D هەڵگیراوە.» (ب) «بەرنامەکەی دایک و باوکان تەنها نمرە و ئامادەبوونی منداڵەکەیان پیشان دەدات.» (ج) «هەر قوتابییەک سەر بە یەک پۆلە؛ هەر پۆلێک چەندین قوتابیی هەیە.» (د) « لەسەر ناوی قوتابی گەڕان خێراتر دەکات.»
Show answerوەڵامەکە پیشان بدە
- (a) physical – it is about files on a disk.
- (b) view – one group of users sees only part of the data.
- (c) logical – what is stored and how it is related.
- (d) physical – indexes are part of the storage structure.
- (أ) فیزیکی – دەربارەی سەر دیسکە.
- (ب) دیمەن – کۆمەڵێک تەنها بەشێک لە دەبینن.
- (ج) لۆجیکی – چی هەڵگیراوە و چۆن پەیوەندییان بەیەکەوە هەیە.
- (د) فیزیکی – بەشێکن لە پێکهاتەی خەزنکردن.
Say whether each change uses physical or logical data independence: (a) the database is moved to a new server with SSD disks; (b) an email column is added to the teacher table, and the old reports still work; (c) the rows of a table are stored in a different order on the disk.
بڵێ هەر گۆڕانکارییەک بەکار دەهێنێت یان : (أ) دەگوازرێتەوە بۆ نوێ کە دیسکی SSDـی هەیە؛ (ب) بە ناوی email بۆ teacher زیاد دەکرێت و کۆنەکان هێشتا کار دەکەن؛ (ج) بە ڕیزبەندییەکی جیاواز لەسەر دیسک هەڵدەگیرێن.
Show answerوەڵامەکە پیشان بدە
- (a) physical – only the storage changed.
- (b) logical – the conceptual schema changed, the external views did not.
- (c) physical – the file organisation is part of the internal schema.
- (أ) فیزیکی – تەنها خەزنکردنەکە گۆڕا.
- (ب) لۆجیکی – چەمکی گۆڕا، دیمەنە دەرەکییەکان نەگۆڕان.
- (ج) فیزیکی – ڕێکخستنی بەشێکە لە ناوەکی.
Which sentences are about the schema and which about an instance? (a) “The table course has the columns code, title and credits.” (b) “Right now there are 42 courses.” (c) “Course CSC1234 got a new title this morning.” (d) “A credits column must be a whole number.”
کام ڕستانە دەربارەی و کامیان دەربارەی ؟ (أ) « course code، title و credits هەیە.» (ب) «ئێستا 42 وانە هەیە.» (ج) «وانەی CSC1234 ئەمڕۆ بەیانی ناونیشانێکی نوێی وەرگرت.» (د) « credits دەبێت بێت.»
Show answerوەڵامەکە پیشان بدە
- (a) and (d) are about the schema – the design and its rules.
- (b) and (c) are about the instance – the data at a moment. Changing a title changes the data, not the design.
- (أ) و (د) دەربارەی – دیزاینەکە و یاساکانی.
- (ب) و (ج) دەربارەی – لە ساتێکدا. گۆڕینی ناونیشان دەگۆڕێت، نەک دیزاین.
Summary and reviewکورتە و پێداچوونەوە
- A database system = interrelated data + programs to access and modify it. Its main purpose is an abstract view of data.
- Architecture: one tier (all on one computer), two tiers (client program + DBMS server) or three tiers (browser → application server → database server). Inside a DBMS: the query processor (with the optimizer), the storage manager, the transaction manager and the data dictionary.
- Three levels of abstraction: physical (how it is stored), logical (what is stored and how it is related) and view (the part one group of users sees).
- Two mappings join the levels and make data independence possible: physical (change storage, keep the design) and logical (change the design, keep the views).
- Schema = the overall design; instance = the data at one moment.
- Data models: implementation models (hierarchical, network, relational, object-oriented) say HOW; the conceptual E-R model says WHAT.
- The schema is stored as metadata in the data dictionary, so a database describes itself. Instance = state = snapshot; schema = intension, state = extension.
- A data model = structures + operations + constraints. Textbooks name three kinds: conceptual, representational (implementation) and physical.
- = بەیەکەوە پەیوەست + بەرنامە بۆ گەیشتن پێی و گۆڕینی. ئامانجی سەرەکیی وێنەیەکی ڕووتکراوەی .
- تەلارسازی: یەک چین (هەمووی لەسەر یەک )، دوو چین ( + ) یان سێ چین ( ← ← ). ناوەوەی : (لەگەڵ )، ، و .
- سێ ئاستی ڕووتکردنەوە: فیزیکی (چۆن هەڵگیراوە)، لۆجیکی (چی هەڵگیراوە و چۆن پەیوەندییان هەیە) و دیمەن (ئەو بەشەی کۆمەڵێک دەیبینن).
- دوو ئاستەکان دەبەستنەوە و ڕێگە بۆ خۆش دەکەن: فیزیکی (خەزنکردن بگۆڕە، دیزاین بهێڵەوە) و لۆجیکی (دیزاین بگۆڕە، دیمەنەکان بهێڵەوە).
- = دیزاینە گشتییەکە؛ = لە ساتێکدا.
- : (هەرەمی، ڕایەڵەیی، پەیوەندیدار، تەنخواز) دەڵێن چۆن؛ چەمکی دەڵێت چی.
- وەک لە هەڵدەگیرێت، بۆیە خۆی وەسف دەکات. = دۆخ = وێنەی ساتێک؛ = intension، دۆخ = extension.
- = پێکهاتەکان + کارەکان + . کتێبەکان سێ جۆر ناو دەبەن: چەمکی، نوێنەرایەتی () و فیزیکی.
Name the three levels of data abstraction.ناوی سێ ئاستەکەی ڕووتکردنەوەی دراوە بهێنە.
Physical (internal), logical (conceptual) and view (external).
فیزیکی (ناوەکی)، لۆجیکی (چەمکی) و دیمەن (دەرەکی).
What is the difference between an instance and a schema?جیاوازیی نێوان نموونە و سکیما چییە؟
An instance is the data at one moment; the schema is the overall design.
لە ساتێکدا؛ دیزاینە گشتییەکەیە.
What is data independence, and what are its two kinds?سەربەخۆیی دراوە چییە و دوو جۆرەکەی چین؟
The ability to change the schema at one level without changing the schema at the next higher level. Physical data independence: change the internal schema without changing the conceptual schema. Logical data independence: change the conceptual schema without changing the external schemas and their programs.
توانای گۆڕینی لە ئاستێکدا بەبێ گۆڕینی لە ئاستی سەرووتردا. : گۆڕینی ناوەکی بەبێ گۆڕینی چەمکی. : گۆڕینی چەمکی بەبێ گۆڕینی دەرەکی و بەرنامەکانیان.
What is the difference between an implementation model and a conceptual model?جیاوازیی نێوان مۆدێلی جێبەجێکردن و مۆدێلی چەمکی چییە؟
An implementation model focuses on how data is represented in the database (hierarchical, network, relational, object-oriented); a conceptual model is concerned with what is represented (the E-R model).
جەخت لەسەر ئەوە دەکاتەوە کە چۆن لە دەردەبڕدرێت (هەرەمی، ڕایەڵەیی، پەیوەندیدار، تەنخواز)؛ گرنگی بەوە دەدات کە چی دەردەبڕدرێت ().
Lesson complete!وانەکە تەواو بوو!
Well done. Review the key terms, then go on to the next lesson.دەستخۆش. سەیرێکی زاراوە سەرەکییەکان بکەرەوە، پاشان بڕۆ بۆ وانەی داهاتوو.
Key termsزاراوە سەرەکییەکان
Entity-Relationship Modellingمۆدێلی قەوارە و پەیوەندی
Related lecturesوانە پەیوەندیدارەکان
References and further readingسەرچاوەکان و خوێندنەوەی زیاتر
- Silberschatz, Korth and Sudarshan: Database System Concepts, 7th ed., Chapter 1 slides (view of data, instances and schemas, physical data independence, data models)
- Microsoft Learn: Views (SQL Server)
- Wikipedia: ANSI-SPARC Architecture
- SQLite: The Schema Table (sqlite_schema)
- MySQL 8.4 Reference Manual: INFORMATION_SCHEMA tables
- MySQL 8.4 Reference Manual: The InnoDB storage engine (default engine)
- MySQL 8.4 Reference Manual: The slow query log
This lecture is a first edition. The Kurdish text and terminology are waiting for review by Kurdish IT teachers.ئەم وانەیە چاپی یەکەمە. دەقە کوردییەکە و زاراوەکانی چاوەڕێی پێداچوونەوەی مامۆستایانی کوردی بواری IT ن.