Why databases?#
File systems suffer from data redundancy, inconsistency, difficult access and poor security. A DBMS (MySQL, Oracle, SQLite) stores data centrally and lets many users access it safely.
Relational data model terms#
| Term | Meaning |
|---|---|
| Relation | a table |
| Attribute | a column |
| Tuple | a row |
| Domain | set of allowed values for an attribute |
| Degree | number of attributes (columns) |
| Cardinality | number of tuples (rows) |
संबंधात्मक मॉडल में डेटा तालिकाओं (relations) में रखा जाता है। कॉलम को attribute, पंक्ति को tuple कहते हैं। कॉलमों की संख्या को डिग्री और पंक्तियों की संख्या को कार्डिनैलिटी कहते हैं।
Keys#
- Candidate key: any attribute(s) that can uniquely identify a row.
- Primary key: the candidate key chosen to identify rows (unique and not NULL).
- Alternate key: candidate keys not chosen as primary key.
- Foreign key: attribute in one table that refers to the primary key of another table - links the tables.
STUDENT(AdmNo, RollNo, Name, Class). AdmNo and (Class, RollNo) are candidate keys. If AdmNo is the primary key, (Class, RollNo) is an alternate key. In FEES(AdmNo, Month, Amount), AdmNo is a foreign key referring to STUDENT.
प्राथमिक कुंजी (primary key) हर पंक्ति को अद्वितीय रूप से पहचानती है और NULL नहीं हो सकती। विदेशी कुंजी (foreign key) दूसरी तालिका की प्राथमिक कुंजी को संदर्भित करती है और तालिकाओं को जोड़ती है।
Exam tips#
- If a table has 5 columns and 8 rows: degree = 5, cardinality = 8.
- After a cartesian product of tables with degrees d₁, d₂ and cardinalities c₁, c₂: degree = d₁ + d₂, cardinality = c₁ × c₂.