Partial preview of the text
Download Relational Database Management System Notes Part - 2 and more Study notes Computer science in PDF only on Docsity!
Database Concepts Topics covered from the syllabus: Database Concepts: Introduction to data base concepts and its necd. Relational data model: Concept of domain, tuple, relation, attribute, key, primary key, alternate key, candidate Key, Foreign Key, degree and cardinality; Database A database may be defined as collection of interrelated data stored together. Purpose of database 1. Databases reduces redundancy. Redundancy means duplicacy. 2. Databases controls inconsistency. By controlling redundancy, the inconsistency is also reduced. 3. Databases facilitates sharing of data. 4. Databases ensures data security. Security refers to protection of data against accidental or intentional disclosure to unauthorized person, or unauthorized modification or destruction. 5. Databases facilitates Data Abstraction. Data abstraction means that the user is provided with that much of information which is required by them. The system does not disclose all the details of the data, rather it hides certain details like how the data is stored and maintained. Relational Data Model In relational Model the data is stored in the form of relations, ie. tables. Tables in turn consists or attributes(columns) and tuples(rows). Some related terms Relation: (Table) MySQL database table consists of rows and columns. Tuples: rows in a relation contain the actual data itself Attributes: Columns in a relation specify the type of data Domain: Pool of values from which a column extracts the data . Degree: Total number of attributes in a relation. Cardinality: Total number of tuples in a relation. Relation: student_details ADMNO | RNO | NAME ADDRESS 101 1. | ASIF ASASDA /102. |2 | ALOK KKIKI [103 | 3 _| CHAITANYA | KKJKJKJ | 104 4 | FAIZAN | LKLKJLK In the above example, the name of the relation is student_details, degree is (total cols, attribute) 4, and cardinality is (total rows, tuple) 4, RNO is a domain which contains the roll numbers of all the students in the relation. Key: specifies how rows ina relation are distinguished. / [ candidate Key: All attribute combinations inside a relation that can serve as primary key are termed as candidate keys as they are the candidates for the primary key position. primary Key:is a set of one or more attributes that can uniquely identify the tuples within the relation in some tables, combination of more than one attribute provides a unique value for each row. In guch cases, the primary key consists of more than one attribute, it is called composite- primary key. Alternate Key: a candidate key that is not a primary key is called alternate key. pedal ee al 7 In the above example, the name of the relation is stu det. The ADMNO - RNO | NAME ADDRESS keys ADMNO. we ae are the candidate keys. If ADMNO is the 101__ {2 ASIF ASASDA primary key the RNO becomes the alternate key. 102 2 ALOK KKJKJ 103 3 CHAITANYA | KKJKJKJ 104 _ _|4 FAIZAN LKLKJLK Foreign Key: A non-key attribute, whose values are derived from the primary key of some other table, is known as foreign key in this current table. The table in which this non-key attribute ie. the foreign key exists, is called a foreign tabl detail table, and the table that defines the primary key exists, which the foreign key of detail table refers to, is called primary table or master table. eor ee stil munis Het In the above example, the relation stu, det is ; ADMNO | Marks1 | Marks2 Marks3 the master relation in which ADMNNO is the | 202 100 29 54 primary key. The ADMNO is referred to asa _102 89 90 98 non-key attribute in another relation | 103 87 67 65 stu_marks_det, Thus ADMNO in the relation F104 34 45 56 stu_marks_det is known as foreign key. Cartesian Product: is the binary operation and is denoted by a cross(X). ie the cartesian product between 2 relation A and B can be denoted as AXB. The cartesian product yields a new relation which has a degree(cols) equal to the sum of number of degrees of the two relation. The number of tuples (cardinality) of the new relation is the product of the tuples of the two relations. All the tuples of the first relation is concatenated with all the tuples of the second relation to form the new relation. Relation: Stu_det | ADMNO_ RNO | NAME ADDRESS | Relation : stu_marks_det }101 [1 __(| ASIF ASASDA 102 2 ALOK KKJKJ ADMNO | Marks1 | Marks2__| Marks3 (1033 | CHAITANYA] KKJKJKJ_ || 101 100 | 29 54 [104 |4__—| FAIZAN LKLKILK || 102 89 90 98 The output of stu_det - stu_marks_det will be