Unit 6 Relational Algebra Structure 6.1 Introduction Objectives Self Assessment Question(s) (SAQs) 6.2 Relational Model Constraints Self Assessment Question(s) (SAQs) 6.3 Update Operation on Relations Self Assessment Question(s) (SAQs) 6.4 The Relational Algebra: 6.4.1 The Select Operation 6.4.2 Project operation: 6.4.3 Set Theoretic Operations 6.4.4 The Join Operation Self Assessment Question(s) (SAQs) 6.5 Summary 6.6 Terminal Questions (TQs) 6.7 Multiple Choice Questions (MCQs) 6.8 Answers to SAQs, TQs and MCQs 6.8.1 Answers to Self Assessment Question(s) (SAQs) 6.8.2 Answers to Terminal Question(s) (TQs) 6.8.3 Answers to Multiple Choice Question(s) (MCQs) 6.1 Introduction Relational model has established itself as the primary data model for commercial data processing application. The relational model represents the database as a collection of relations having a set of rows and columns, each of which is assigned a unique Database Management Systems Unit 6 Sikkim Manipal University Page No.: 96 name. Relation consists of a relational schema [structure of table] and relational instance [data in a table at the particular time]; there is a close correspondence between the concept of table and the mathematical concept of relation. In relational model we use certain conventions. For instance, a row is called a tuple and a column is termed as an attribute. The domain of a relational schema is a pool of legal values. Student [Reg. No, name, Addr, Phone, Dbirth, GPA] In this example, Student is a relation and the attributes [columns] are RegNo, Name, Addr, Phone, Dbirth. A possible tuple for the Student relation is [1BL02CS023', 'Vinod Babu', '115, 1-main, Ist cross, Dinnur Main Road, R.T. Nagar, Bangalore-32', 23438553, 11-Jan-1986]. The domain of each attribute is as follows: RegNo. : 10 alphanumeric characters Name : characters Addr : Alphanumeric characters Phone : 7 digits Dbirth : Date Characteristics of a relation: - The tuples in the relation need not be ordered. - Each tuple in the relation is an entity. Domain: A domain D is a set of atomic values. For each attribute there is a set of permitted values called the domain of that attribute. For e.g.: For the attribute empname, the domain is the set of all empnames. Let D1 denotes the attributes of empnames. D2 - > Set of all empnames. Database Management Systems Unit 6 Sikkim Manipal University Page No.: 97 D3 - > Set of all addr. D4 - > set of al phone D5 - > set of all salary. In general a table of 'n' columns must be subset of D1X D2X D3DD4X Dn-1 X Dn. In relational model terminology the datatype describing the type of values that can appear in each column is called a domain. 1) Since a relation is a set of tuples we use the mathematical notation of t r to denote that tuple t is in relation r. 2) A domain is atomic its not divisible], if elements of the domain are considered to be individual units. For e.g: the set of integers is an atomic domain. Entity set: The number of tuples in a relation is called an entity set. Database schema or relational schema: 1) Denoted by R [A, A3w, Ae..An] is made up of a relation name R and a list of attributes A1, A2, A3.An 2) Database instance is the data in DATABASE at a particular moment of time. 3) D is called domain of A1 and denoted by dom[A1] 4) A relational schema is a list of attributes and their corresponding domains [set of values] 5) To represent incomplete tuples, we must use NULL values; e.g.: Apartment number. 6) Candidate keys are other keys [except primary key]. 7) Primary attribute is one of the candidate keys, where values of their attribute is unique and NOT NULL Database Management Systems Unit 6 Sikkim Manipal University Page No.: 98 8) If we denote cardinality of a domain D by | D |, and assume that all domains are finite, the total Number of tuples in the Cartesian product is | dom(A1) | * |dom(A2) | * * | dom(An) | 9) Current relation state reflects only the valid tuples that represent a particular state of the real world. Tables must be normalized. Relational Model Notation: A relational schema R of degree 'n' is denoted by R[A1, A2. A3.An], known as degree of relation [total number of attributes]. An n-tuple t in a relation r(R) is denoted by t = [V1, V2. V3..Vn] where Vi is the value corresponding to attribute Ai The letters Q, R, S denote relation names. The letter q, r, s denote relation status The letters t, u, v denote tuples. In general the name of a relation such as STUDENT indicates the current set of tuples in that relation where STUDENT (name, SSN..) refers to the relation schema. Objectives To know about o Relational Database Concepts o Relational model constraints o Update Operation on Relations o Relational Algebra o Select Operation o Project operation o Set theoretic operations o The Join Operation Database Management Systems Unit 6 Sikkim Manipal University Page No.: 99 Self Assessment Question(s) (SAQs) (for section 6.1) 1. Define relational model and give one example. 6.2 Relational model constraints These include Domain constraints Key constraints Entity integrity constraints Referential integrity constraints Data dependencies [functional and multi valued dependencies] Domain constraints: It specifies that the value of each attribute A must be an atomic value from the domain dom(A) for that attribute. It also specifies that integer type holds only integer values but not float values. It is possible for several attributes to have the same domain. For e.g: Customer name and employee name must have the same domain. The SQL standard supports a restricted set of domain types. Characters, fixed-length string, and variable-length with user specified length (char(20) and varchar2(20)) are also available. Numeric data types for integers and real number (e.g. Number (4) and Number (5,2)) Other possible domains maybe described by a subrange of values from a data type or as an enumerated data type where all possible values are explicitly listed. Standard SQL, allow the domain of the attribute to include the specification NOT NULL. This prohibits the insertion of a NULL value for this attribute. Any DATABASE modification that would cause a NULL to Database Management Systems Unit 6 Sikkim Manipal University Page No.: 100 be inserted in a NOT NULL domain generates error. By default, primary keys is of type NOT NULL. Key constraints: A relation is defined as a set of tuples. All tuples in a relation must also be distinct. This means that no 2 tuples can have the same value [maintains uniqueness]. Tl[sk] !=2[sk], here sk is a super key. In any schema there will be a super key[pk] to distinguish tuples. Every relation can have at least 1 super key. In general, a relation schema may have more than one key. In this case each of these keys is called a candidate key. Relational database schema and integrity constraints: A relational DATABASE schema S is a set of relation schema S = {R1, R2..Rn} and a set of integrity constraints (IC). A relational DATABASE instance DB of S is a set of relation instances DB = {r1, r2..rm} such that ri is an instance of Ri and such that each ri relations satisfy the integrity constraint specified in IC. The relational DATABASE schema for company is shown below: Employee: ENAME Minit Lname Ssn BDATE ADDR SEX SALARY SUPERSSN DNUM Department: DNAME DNUM MGSSN MGSTARTDATE Integrity constraints are specified on a DATABASE schema and are expected to hold on every database instance of the schema. Database Management Systems Unit 6 Sikkim Manipal University Page No.: 101 Entity constraints: It states that no PK value can be NULL, because PK value is used to identify individual tuple in a relation. Having NULL values for PK implies that we cannot identify some tuples. Referential integrity: Tables can be related by common columns; a referential integrity constraint requires that the value in the foreign key matches a value in the parent key [unique or primary key of the same or different table referenced key] For e.g: The attribute DNO of emp gives the dept. number for which each employee works, hence its value in every employee tuple must match the DNUM value of some tuple in the department relation. Foreign key: The condition for a foreign key specifies a referential integrity constraint between the two relation schemas R1 andR2. An attribute A is a foreign key, if it satisfies the following rules. A rule defined on a column in one table that allows insert or update of a row, only if the value for the column dependent table matches a value in a column of the referenced table. That is, the attribute in FK must have the same domain (values) as the primary key attribute PK of another relation (parent table). Foreign key reference, a parent key of the same table, is called self referential integrity constraint. For eg: DNUM is a foreign key of emp relation referring to the DNUM as a foreign key of emp relation, referring to the DNUM of dept relation. Self Assessment Question(s) (for section 6.2) 1. List constraints used in Relational model. 2. Explain the concept of Keys in relations model. Database Management Systems Unit 6 Sikkim Manipal University Page No.: 102 6.3 Update Operation on Relations Insert, Delete and Modify. Insert: Insert is used to insert a new tuple or tuples in a relation. Insert can violate any of the 4 types of constraints. A) Domain Constraints: can be violated if an attribute value is given that does not appear in the corresponding domain (allows only permitted values). B) Key Constraints: can be violated if a key value in the new tuple t already exists in another tuple in the Relation r(R) [avoids duplicate entries]. C) Entity Constraints: can be violated if the primary key of new tuple 't' is NULL (avoids NULL values). D) Referential Integrity: can be violated if the value of any foreign key in t refers to a tuple, that does not exist in the referenced relation[foreign key values should match with primary key values]. E.g.: insert into emp values (1, john.etc.) into emp acceptable. insert into emp values (1, smithetc.) into emp not acceptable because same eno already exist in the employee relation, violates key constraints. insert into emp values [null, raj.etc] into emp. not acceptable because null for the primay key eno; it violates entity integrity constraints. Insert into emp values (1, joy, 70, etc.) into emp not acceptable because it violates referential integrity constraints specified on dno, no department tuple exists with dno = 70. Delete: 1) It is used to delete tuples. Delete operation can violate only referential integrity if the tuple being deleted is referenced by foreign Database Management Systems Unit 6 Sikkim Manipal University Page No.: 103 keys from other tuples in the DATABASE. To specify the deletion, a condition on the relation selects the tuple to be deleted. 2) 3 options are available if a deletion operation causes a violation. a) The 1 st option is to reject the deletion. b) The 2 nd option is to attempt to delete the referenced tuples, when link data field is deleted. c) The 3 rd option is to modify the referencing attribute values that cause the violation. Delete the emp tuple with eno. = 5 this deletion is acceptable Delete the dept. tuple with dno = 10 this deletion is not acceptable because tuples in emp refer to this tuple. Referential integrity violation will result. Modify: 1) The modify operation is used to change the values of one or more attributes in a tuple/s some relation R 2) It is necessary to specify a condition on the attributes of relation 'R' to select the tuple/s to be modified. For e.g.: 1. Modify the salary of emp with empno = 101 to 1000.0 3) Modifying an attribute that is neither a primary key nor a foreign key usually causes no problems. The DBMS only needs to check to confirm that the new value is of correct data type and domain. 4) If a foreign key attribute is modified, the DBMS must make sure that the new value refers to n existing tuple in the referenced relation. 5) If you are modifying a primary key, key constraints are violated if that modified primary key value already exists E.g.: modify the salary of the employee tuple with eno = 100 to 10000-Acceptable E.g.: modify the no. of the department tuple with dno = 10 to 40 not acceptable, because it violates referential integrity. Database Management Systems Unit 6 Sikkim Manipal University Page No.: 104 Self Assessment Question(s) (SAQs) (for section 6.3) 1. Write and explain the different operations performed on Relations. 6.4 Relational Algebra Relational algebra operations are divided into two groups. 1) Set operations like union, intersection, difference, and Cartesian product. 2) Developed specifically for the relational databases, they are select, project and join. 6.4.1 The Select Operation It selects required rows from the table. This operation is used to select the subset of the tuples from a relation that satisfies a selection condition or search criteria. Mathematical symbol o [sigma] is used to denote the SELECT operator. The general syntax for selection operation is shown below. Sigma<selection condition>(<relation name>). The <selection condition> is a Boolean expression, consists of attribute names, comparison operators like =,!=,<,<=,>,>= and Boolean operations like AND, OR and NOT. E.g. 1.Select the employees who are working in department 10, and whose salary is greater than Rs.5000. o(DNO=0 AND SLARY>5000)(EMPLOYEE) E.g. 2. Select the employees who are working in department 10 and earning more than 5000 or employees who are working in department 20 and whose earnings are more than 8000 rupees. o(DNO=10 AND SALARY > 5000) OR (DNO=20 AND SALARY>8000 (EMPLOYEE) Database Management Systems Unit 6 Sikkim Manipal University Page No.: 105 6.4.2 Project operation: Projection operation is used to select only few columns from a table. the mathematical symbol t<ATTRIBUTE LIST>(<relation>) Here, <attribute list> is a list of attributes from the relation r hence the degree (number of columns) of the result is equal to the number of attributes specified in the attribute list. Eg 1. Select the name and salary of all the employees. tNAME. SALARY(EMPLOYEE). This query selected only name and salary attributes from relation EMPLOYEE Eg. 2. Select names and addresses of all employees working for department 10. tNAME, ADDRESS (DNO=10(EMPLOYEE) 6.4.3 Set theoretic operations: These are used to merge the elements of two sets in various ways, including union, intersection and difference. Three of these operations require the table to be union compatible. The two relations are said to require the table to be union compatible. The two relations are said to be union compatible if the following conditions are satisfied. 1. The two relation/ tables (say R & S) that have the same number of columns (have the same degree) 2. Each column of the first relation/table must be either the same data type as the corresponding column of the second relation/table(s). Relations R & S R S Eno Name Eno Name 1 Jyothi 3 Girija 2 Ganga 4 Ankitha 3 Girija 5 Tanvi 4 Ankitha 6 Manvi Database Management Systems Unit 6 Sikkim Manipal University Page No.: 106 Intersection (): The intersection operation selects the common tuples from the two relations. The result of the operation RS is RS Eno Name 3 Girija 4 Ankitha Union ( ): The result of this operation denoted by RS, is a relation that includes all tuples that are either in R or in S or in both. Duplicate tuples will not appear in the output. RS Eno Name 1 Jyothi 2 Ganga 3 Girija 4 Ankitha 5 Tanvi 6 Manvi Difference ( ): The result of the difference consists of all tuples in R but not in S R S Eno Name 1 Jyothi 2 Ganga Cartesian products (X): The Cartesian product or cross-product is a binary operation that is used to combine two relations. Assuming R & S as relations with n and m attributes respectively, the Cartesian products R x S can be written as, R (A 1 , A 2 ..A n ) x S (B 1 , B 2 .B n ) Database Management Systems Unit 6 Sikkim Manipal University Page No.: 107 The result of the above set operation is Q (A 1 , A 2 ..A n , B 1 , B 2 .B n ) Total number of columns in Q: degree (Q) = n + m Total number of tuples in Q: count (Q) = Number of tuples in R* Number of tuples in S R S Dno Name Pno P name 1 E & C 10 Networking 2 Computer Science 11 Payroll 3 HRD Cartesian product of R and S can be written as, RS R x S R S Dno Name Pno P name 1 E & C 10 Networking 1 E & C 11 Payroll 2 Computer Science 10 Net working 2 Computer Science 11 Payroll 3 HRD 10 Networking 3 HRD 11 Payroll The relation R has 2 columns and 3 tuples. The relation S has 2 columns and 3 tuples. So the Cartesian product has 4 columns (2+2) and 6 tuples (3 x 2). The Cartesian product operation applied by itself is generally meaningless. It is useful only when followed by selection and projection operations. Renaming (rho): This operation is used to rename the relations or attributes. The symbol (rho) is used to denote the rename operator. In some situations, it is better to break down a complex query into two or more simple querys. We must Database Management Systems Unit 6 Sikkim Manipal University Page No.: 108 rename the relations that hold the intermediate result relations. It improves the readability and facilitates better understanding. The syntax is as follows. Rename <OLD TABLE> to <NEW TABLE> 1. s(new attribute names)(R) It renames both the relations and its attributes. 2. s It renames the relation only. 3. (new attribute names)(R) It renames only the attributes. Here S is new relation and R is original relation. Ex 1: E (Employee) Renames relation employee into relation E. Ex.2: To retrieve the employee number and name, who are earning more than 5000 Rs. tebim ebane (oSal > 5000 (employee) We can split into two operation. Esal o sal>5000(employee) RESULT t eno,ename (Esal) Here intermediate result stored in Esal. 6.4.4 The Join Operation Join (): The capability of retrieving data from multiple tables using a single SQL statement is one of the most powerful and useful features of RDBMS. It is the availability of join operation. We know that one table may not give all the information about a particular entity. The join operation, denoted by is used to combine two relations to retrieve useful information. A join operation matches data from two or more tables; based on the values of one or more columns in each table, it allows us to process more than one table at a time. Database Management Systems Unit 6 Sikkim Manipal University Page No.: 109 For e.g.: The employee table gives only the department id's, if we want to know the department name, then we have to get the information by joining employee table and dept. table. In join, only combinations of tuples satisfying the join condition appear in the result. The general form of a Join operation is R<join condition>S For example by joining employee and department relations, we can get the name of the department in which the employee is working (department name exists in department table). Select emp_no,ename,dept.dname from emp.dept Where emp.deptno = dept.dept_no and emp_no = &emp_no. Emp_dept<--employee e.deptno=d.deptnoDEPT Result<-IIemp.enam,dname)emp_dept) The first operation in the join operation will combine the tuples of the employee and department relations on the basis of the dept no.to form a relation called emp_dept. Then the PROJECT operation will create a relation RESULT with the attributes eno. Ename, and dname. To perform join between two relations, there should be a common field between them. Theta Join: A join condition is of the form <condition>and<condition>and<condition> where each condition is of the form Ai 0 Bj (dept.deptno = emp.dept_no). Ai is an attribute of R and Bj is an attribute of S. Ai and Bj have the same domain (same values) and 0 is one of the comparison operators (=,<,<=,>,>=,!=). A join operation with such a general join condition is called a "Theta join". Database Management Systems Unit 6 Sikkim Manipal University Page No.: 110 Equi Join: While joining if the comparison operator is = then it is equijoin. Eg. Select emp_no.ename.dept.dname from emp.dept. Where emp.deptno = dept.dept_no. Natural Join: It is denoted by symbol. The standard definition of natural join requires that the join attributes have the same name in both relations. In general, natural join is performed by equating all attribute pairs that have the same name in the two relations. The general format is: Q R <list I> <list2> S Here list l specifies list of attributes from R and list2 specifies a list of attributes from S. Department DNumber DName 1 Admin 2 Research 3 Accounts Project Pnumber Pname DNum 10 Library Management 2 20 ERP 1 30 Hospital Management 3 40 Wireless Network 2 Project Dept. Pnumber PName DNum Dname 10 Library Management 2 Research 20 ERP 1 Admin 30 Hospital Management 3 Accounts 40 Wireless Network 2 research Database Management Systems Unit 6 Sikkim Manipal University Page No.: 111 Here, the joining is done over the attribute DNumber of Department relation and DNum of Project relation. In fact, DNum of Project is a foreign key which references DNumber of Department. Generally, in a natural join, the joining attribute is implicitly considered. Suppose the two relations have no attribute(s) in common, R S is simply the cross product of these two relation. Joining can be done between any set of attributes and need not be always with respect to the primary key and foreign key combinations. The expected size of the join result divided by maximum size i.e. n R n S leads to a relation called join selectively. Outer join: It returns both matching and non matching rows. It differs from the inner join, in that the rows in one table having no matching rows in the other table will also appear in the results table, with nulls in the other attribute position, instead of being ignored as in the case with the inner join. It outputs rows even if they do not satisfy the join condition; the outer join operator is used with the table having n matching rows. Worker Worker Skill Name Age Addr Name Skill Adah 23 - Adah work Andrew 29 - Jones Smithy Barath 22 - Elbert Discuss Jone 19 - Helen Driver Donald 23 - Wilfred Fitter Elbert 26 - Marg Smithy George 28 - Rita Fitting Helen 15 - Database Management Systems Unit 6 Sikkim Manipal University Page No.: 112 Result Name Age Addr Adah 23 Work Andrew 29 Barath 22 Jone 18 Smithy Donald 16 Elbert 43 Discuss George 41 Helen 27 Driver In the above example even though there is no matching row with B name, all workers are listed along with age and skill. If there is no match, simply get an empty skill column. The outer join can be used when we want to keep all the tuples in R or in S; those in both relations, whether or not they have matching tuples in the other relation. Left outer join: It is denoted by . The left outer join operation keeps every tuple in the first or left relation R in relation R S. If no matching tuple is found in S in the join, result is filled with null values. Right outer join: It is denoted by , and keeps every tuple in the second or right relation S in the result of R Full outer join: It is denoted by and keeps all tuples in both the left and right relations and when no matching tuples are found, filled with null values as needed. Division A division operation (denoted by ) is useful for a special kind of query; occasionally it maybe used to solve certain kind of problems. Consider the relations P (P) and Q (Q) as shown in the figure. The result of dividing P by Q is the relation R and it has two tuples. For each tuple in R, Ex. Select A.name, age, skill from worker A, work skill B where A.name = N.name Database Management Systems Unit 6 Sikkim Manipal University Page No.: 113 its product with the tuples of Q must be in P. In our example (a 1 , b 1 ) must both be tuples in P: the same is true for (a 5 , b 1 ) and (a 5 , b 2 ) Examples of the division operations R = P + Q: P(P) Q(Q) R(R) result A B B A a 1 b 1 b 1 a 1 a 1 b 2 b 2 a 5 a 2 b 1 a 3 b 1 a 4 b 2 a 5 b 1 a 5 b 2 For e.g.: To retrieve the names of employees who work on all the projects that 'John Smith' works on. 1. Retrieve the list of project numbers that John Smith works on the intermediate relation SMITH_PNOS: SMITH < - oNAME =johnsmith (EMPLOYEE) SMITH_PNOS <- tPNO(WORKS_ON_ESSN=SSN SMITH) 2. create a relation that includes a tuple < PNO,ESSN> whenever the employee whose social security number is ESSN works on the project whose number is PNO in the intermediate relation SSN_PNOS. SSN_PNOS < ESSN.PNO(WORKS_ON) 3. Apply the DIVISION operation to the two relations which gives the desired employees social security numbers. SSNS(SSN) <-SSN_PNOS SMITH_NOS RESULT <- tNAME (SSNA*EMPLOYEE) Database Management Systems Unit 6 Sikkim Manipal University Page No.: 114 TABLES SSB_PNOS SSN PNO SMITH_PNOS PNO 123 1 1 123 2 2 666 3 453 1 453 2 353 2 SSNS SSN 333 2 123 333 3 453 Notice here that 123,453 appear in SSN_PNOS in combination with all two tuples in SMITH_PNOS; that is why they appear in the resulting relation SSNS. Grouping and Aggregate functions: It is often required in data base applications to find an aggregate value over some column (to find summation). For example, we may wish to find the sum of salary drawn by all the employees, or to find the total number of employees working in a department etc. for which aggregate function can be used. It is also useful in grouping the tuples in a relation by the value of some of their attributes, and then applying an aggregate function independently to each group. Commonly used aggregate functions are sum, average, count, maximum and minimum. For example: Group employee tuples by dno, so that each group includes the tuples for employees working in the same department; after that we can apply aggregate function to find the average salary of employees within the department. Database Management Systems Unit 6 Sikkim Manipal University Page No.: 115 Aggregate function is denoted by (read as calligraphic G) The general format is: <grouping attributes> <function list> (R) Here grouping attributes is a list of attributes of the relation R, and function list is a list of aggregate functions like SUM.AVERAGE, MIN. MAX, COUNT, and attributes are column names. The steps involved in the evaluation of this are: 1. Partition the relation into groups. 2. Apply aggregate function to each group, output group and aggregate values, one tuple per group. E.g.: To retrieve each department number, the number of employees working in the department and their average salary. DNUM COUNT empno AVG salary (EMPLOYEE) Resulting relation has the grouping attributes in addition to one attribute for each element in the function list. Self Assessment Question(s) (SAQs) (For section 6.4) 1. Explain the concept of select operations. 2. Define and explain Project operation. 3. Write a note on all set theoretic operations. 4. Explain the concept of Join operation. 6.5 Summary In this unit we have learnt the following o Relational Database Concepts o Relational model constraints o Update Operation on Relations o The Relational Algebra: Database Management Systems Unit 6 Sikkim Manipal University Page No.: 116 o The Select Operation o Project operation: o Set Theoretic operations o The Join Operation 6.6 Terminal Questions (TQs) 1. Explain the following terms: a) Domain b) Attribute c) Tuple d) Degree of relation e) Relation data base scheme f) Relation data base state 2. Discuss the Update Operation on Relations. 3. Discuss the relational algebraic operations. 4. Explain the operations: (a) Union (b) Intersection (c) Difference 6.7 Multiple Choice Questions (MCQs) 1. For each attribute there is a set of permitted values called the .. of those attributes. (a) Domain (b) Design (c) Database (d) None of the above 2. . specify that the value of each attribute A must be an atomic value from the domain dom(A) for that attribute. It also specifies that integer type hold only integer values but not float values. (a) Domain constraints (b) Key constraints (c) Entity integrity constraints (d) None of the above Database Management Systems Unit 6 Sikkim Manipal University Page No.: 117 3. All tuples in a relation must also be distinct in a Relationship set (a) Domain constraints (b) Key constraints (c) Entity integrity constraints (d) None of the above 4. . selects required rows from the table (a) select (b) product (c) union (d) None of the above 6.8 Answers to SAQs, TQs, and MCQs 6.8.1 Answers to Self Assessment Questions (SAQs) For Section 6.1 1. The relational model represents the database as a collection of relations having a set of rows and columns. (Refer section 6.1) For Section 6.2 1. Relational model constraints These include Domain constraints Key constraints Entity integrity constraints Referential integrity constraints Data dependencies [functional and multi valued dependencies] (Refer section 6.2) 2. Key constraints: A relation is defined as a set of tuples. Database Management Systems Unit 6 Sikkim Manipal University Page No.: 118 All tuples in a relation must also be distinct. This means that no 2 tuples can have the same value [maintains uniqueness]. Tl[sk] !=2[sk], here sk is a super key. In any schema there will be a super key [pk], to distinguish tuples. Every relation can have at least 1 super key. In general, a relation schema may have more than one key. In this case each of these keys is called a candidate key. (Refer section 6.2) For Section 6.3 1. Insert, Delete and Modify (Refer section 6.3) For Section 6.4 1. The Select Operation It selects required rows from the table. This operation is used to select the subset of the tuples from a relation that satisfy a selection condition or search criteria. (Refer section 6.4.1) 2. Project operation: Projection operation is used to select only a few columns from a table. The mathematical symbol is t<ATTRIBUTE LIST>(<relation>) (Refer section 6.4.2) 3. Set theoretic operations: These are used to merge the elements of two sets in various ways, including union, intersection and difference; three of these operations require the table to be union compatible. (Refer section 6.4.3) 4. Join (): the capability of retrieving data from multiple tables using a single SQL (Refer section 6.4.4) Database Management Systems Unit 6 Sikkim Manipal University Page No.: 119 6.8.2 Answers to Terminal Questions (TQs) 1. A domain D is a set of atomic values. For each attribute there is a set of permitted values called the domain of those attributes. (Refer section 6.1) 2. Insert: Insert is used to insert a new tuple or tuples in a relation. Insert can violate any of the 4 types of constraints. (Refer section 6.3) 3. The relational algebra operations are divided into two groups. Set operations like union, intersection, difference, and Cartesian product. Developed specifically for the relational databases, they are select, project, and join. (Refer section 6.4) 4. The intersection operation selects the common tuples from the two relations. (Refer section 6.4.3) 6.8.3 Answers to Multiple Choice Question(s) MCQs) 1. A 2. A 3. B 4. A