Relational Database Systems 1

Size: px
Start display at page:

Download "Relational Database Systems 1"

Transcription

1 Relational Database Systems 1 Wolf-Tilo Balke Joachim Selke Institut für Informationssysteme Technische Universität Braunschweig

2 Exercise 4.1 The four major steps of conceptual schema integration 1. Pre-integration analysis Decide on the right integration strategy Result: Conflicting schemas and integration strategy 2. Comparison of schemas Identify conflicts in the schemas (naming/structure) Result: List of conflicts 3. Conformation of schemas Resolve the conflicts between the different schemas Result: Modified, non-conflicting schemas Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 2

3 Exercise 4.1 The four major steps of conceptual schema integration 4. Merging and restructuring Combine the modified schemas and do some optimization Result: Your new integrated global schema Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 3

4 Exercise 4.2 The three main goals of restructuring Completeness All different concepts of each individual schema are included in the global schema Minimality There is no redundant information in the global schema Ease of understanding The new model is easy to understand That is, for example: Entities are clearly distinguishable, the level of abstraction looks natural, Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 4

5 Exercise 4.3 Two models: A. The data of interest is about books. Books have titles. They are published by publishers with names and addresses. Books are adopted by universities having a name and belonging to a state. Books refer to certain topics. B. The data of interest includes publications of different types. Each publication has a title, a publisher, and a list of keywords. Each keyword consists of a name, a code, and a research area. Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 5

6 Exercise 4.3 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 6

7 Exercise 4.3 Turn Keywords into Topics. Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 7

8 Exercise 4.3 Let Publisher become an entity. Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 8

9 Exercise 4.3 Put them together. Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 9

10 Exercise 4.3 Introduce a subset relationship. Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 10

11 Exercise 4.3 Drop duplicated properties from Book. Pictures taken from Bartini/Lenzerini/Navathe: A Comparative Analysis of Methodologies for Database Schema Integration (1987) Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 11

12 Exercise 4.4 Integrate that! EXAM DEPARTMENT Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 12

13 Exercise 4.4 Integrate that! STAFF PHONE STUDENT PHONE Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 13

14 Exercise 4.4 One solution of many: Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 14

15 Overview Basic set theory Relational data model Relational Algebra Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 15

16 5.1 Basic Set Theory Set theory is the foundation of mathematics You probably all know these things from your math course, but repeating never hurts The relational model is based on set theory; understanding the basic math will help a lot Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 16

17 5.1 Sets A set is a mathematical primitive, and thus has no formal definition A set is a collection of objects (called members or elements of the set) Objects (or entities) have to be understood in a very broad sense, can be anything from physical objects, people, abstract concepts, other sets, Objects belong (or do not belong) to a set (alternatively, are or are not in the set) A set consists of all its elements Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 17

18 5.1 Sets Sets can be specified extensionally List all its elements Example: A = {IfIS, 42, Balke, Hurz!} Sets can be specified intensionally Provide a criterion deciding whether an object belongs to the set or not (membership criterion) Examples: A = {x x > 4 and x Z} B = {x N x < 7} C = {all facts about databases you should know} Sets can be either finite or infinite Set of all super villains is finite Set of all numbers is infinite Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 18

19 5.1 Sets Sets are different, iff they have different members {a, b, c} = {b, c, a} Duplicates are not supported in standard set theory {a, a, b, c} = {a, b, c} Sets can be empty (written as {} or ) Notations for set membership: a {a, b, c} e {a, b, c} Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 19

20 5.1 Sets Defining a set by its intension: Intension must be well-defined and unambiguous There always is a clear membership criterion to determine whether an object belongs to the set (or not) Not a valid definition (Russell s paradox): In a small town, there is just one male barber. He shaves all and only those men in town who do not shave themselves. Does the barber shave himself? Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 20

21 5.1 Sets Still, the set s extension might be unknown (however, there is one) Example: All students in this room who are older than 22. Well-defined, but not known to us But (at least in principle) we can find out! As we will see later: Intension Database query Extension Result of a query Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 21

22 5.1 Sets For every set, there is an accompanying definition of equality (or equivalence) Is x = y? If they are equal, they are actually just one element However, you could have two different descriptions of the same element Example: The set of all 26 standard letters ö is not contained in this set m = M and is also element of the set ( m and M are different descriptions of the same object) Example: The set of all 59 letters and umlauts in German ö is element of the set m M and both are element of the set ( m and M two different objects) Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 22

23 5.1 Sets Sets have a cardinality (i.e., number of elements) Denoted by A {a, b, c} = 3 A B B A Set A is a subset of set B, denoted by A B, iff every member of A is also a member of B B is a superset of A, denoted by B A, iffa B Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 23

24 5.1 Tuples A tuple (or vector) is a sequence of objects Length 1: Singleton Length 2: Pair Length 3: Triple Length n: n-tuple In contrast to sets Tuples can contain an object more than once The objects appear in a certain order The length of the tuple is finite Written as a, b, c or (a, b, c) Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 24

25 5.1 Tuples Hence: <a, b, c> <c, b, a>, whereas {a, b, c} = {c, b, a} <a 1, a 2 > = <b 1, b 2 > iff a 1 =b 1 anda 2 =b 2 n-tuples (n > 2) can also be defined as a cascade of ordered pairs: <a, b, c, d> = <a, <b, <c, d>>> Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 25

26 5.1 Set Operations Four binary set operations Union, intersection, difference and Cartesian product Union: Creates a new set containing all elements that are contained in (at least) one of two sets {a, b} {b, c} = {a, b, c} Intersection: Creates a new set containing all elements that are contained in both sets {a, b} {b, c} = {b} A B A B A A B B Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 26

27 5.1 Set Operations Difference: Creates a set containing all elements of the first set without those also being in the second set {a, b} {b, c} = {a} A A B B Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 27

28 5.1 Set Operations Cartesian product: The Cartesian product is an operation between two sets, creating a new set of pairs such that: A B = {<a, b> a A andb B} Named after René Descartes Example: {a, b} {b, c} = {<a, b>, <a, c>, <b, b>, <b, c>} Cleverness = { genius, dumb } Character = { hero, villain } Cleverness Character = { <genius, hero>, <dumb, hero>, <genius, villain>, < dumb, villain> } The Cartesian product can easily be extended to higher dimensionalities. Example: A B C is a set of triples. Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 28

29 5.1 Relations A relationrover some sets D 1,, D n is a subset of their Cartesian product R D 1 D n The elements of a relation are tuples The D i are called domains Each D i corresponds to an attribute of a tuple n=1: Unary relation or property n=2: Binary relation n=3: Ternary relation Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 29

30 5.1 Relations Some important properties: Relations are sets in the mathematical sense, thus no duplicate tuples are allowed The list of tuples is unordered The list of domains is ordered Relations can be modified by inserting new tuples, deleting existing tuples, and updating (that is, modifying) existing tuples. Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 30

31 5.1 Relations A special case: Binary relations R D 1 D 2 D 1 is called domain,d 2 is called codomain (range, target) Relates objects of two different sets to each other Ris just a set of ordered pairs R = {<a,1>, <c,1>, <d,4>, <e,5>, <e,6>} Can also be written as ar1, cr1, dr4, Imagine Likes Person Beverage Joachim Likes Coffee, Tilo Likes Tea, D b e c a R 1 2 d V Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 31

32 5.1 Relations Example: accessory = {spikes, butterfly helmet} material = {silk, armor plates} color = {pink, black} color material accessory = {<pink, silk, butterfly helmet>, <pink, silk, spikes>, <pink, armor plates, butterfly helmet>, <pink, armor plates, spikes>, <black, silk, butterfly helmet>, <black, silk, spikes>, <black, armor plates, butterfly helmet>, <black, armor plates, spikes>} Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 32

33 5.1 Relations Relation FamousHeroCostumes color material accessory FamousHeroCostumes = {<pink, silk, butterfly helmet>, <black, armor plates, spikes>} Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 33

34 5.1 Functions Functions are special case of binary relations Partial function: Each element of the domain is related to at most one element in the codomain Total function: Each element in the domain is related to exactly one element in the codomain Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 34

35 5.1 Functions Functions can be used to abstract from the exact order of domains in a relation Alternative definition of relations: A relation is a set of functions. Every tuple in the relation is considered as a function of the type {A 1,,A n } D 1 D n That is, every tuple maps each attribute to some value Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 35

36 5.1 Functions Example: color = {pink, black} material = {silk, armor plates} accessory = {spikes, butterfly helmet} The tuple <pink, silk, butterfly helmet> can also be represented as the following function t: t(color) = pink t(material) = silk t(accessory) = butterfly helmet Usually, one writes t[color] instead of t(color) Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 36

37 5.2 Relational Model Well, that s all nice to know But: We are here to learn about databases! Where is the connection? Here it is A data model is a description of concepts in terms of attributes and domains A database instance is a set of objects having certain attribute values Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 37

38 5.2 Relational Model OK, then Giving a data model (e.g., by ER modeling) determines entities and relationships, as well their corresponding sets of attributes and associated domains The Cartesian product of the respective domains is the set of all possible instances (of each entity type or relationship type) A relation formalizes the actually existing subset of all possible instances Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 38

39 5.2 Relational Model Data models are described by relation schemas, denoted by R(A 1 :D 1,, A n :D n ) The actual database instance is given by a set of matching relations Example Relation schema: CATS(name : varchar(10), age : integer) A matching relation: { (Blackie, 10), (Pussy, 5), (Fluffy, 12) } Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 39

40 5.2 Relational Model Relations can be written as tables: relation name attributes tuples PERSON firstname lastname sex Clark Joseph Kent m Louise Lane f Lex Luthor m Charles Xavier m Erik Magnus m Jeanne Gray f Ororo Munroe f Tony Edward Stark m Matt Murdock m Raven Wagner f Robert Bruce Banner m domain values Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 40

41 5.2 Relational Model A relational database schema consists of a set of relation schemas a set of integrity constraints A relational database instance (or state) is A set of relations adhering to the respective schemas and respecting all integrity constraints Relation Schemas R a b c x 67 zv Integrity Constraints y 56 qa Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 41

42 5.2 Relational Model Every relational DBMS needs a language to define its relation schemas (and integrity constraints) Data definition language (DDL) Typically, it is difficult to formalize all possible integrity constraints, since they tend to be complex and vague A relational DBMS also needs a language to handle tuples Data manipulation language (DML) Today s RDBMS use SQL as DDL and DML Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 42

43 5.2 Conversion from ER After modeling a conceptual schema (e.g., using an ER diagram), the schema can be automatically transformed into a relational schema Remember: conceptual design ER diagram UML, logical design tables, columns, physical design tablespaces, Indexes, Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 43

44 5.2 Conversion from ER Each entity typeewith attributes A 1,, A n from domainsd 1,, D n is converted into an n-ary relation schemae(a 1 :D 1,, A n :D n ) If there is a relationship type E is_af involved (specialization), the inheritance relationship can be expressed by copying all key attributes from F Person telephoneno weakness alias Hero firstname lastname Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 44

45 5.2 Conversion from ER A relationship type R between entity types E 1,, E n is converted to a relation schema whose attributes are all the key attributes of E i If keys share the same name, they have to be renamed If the relationship type has own attributes they are also copied to the relation schema Hero uses Power situation Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 45

46 5.2 Conversion from ER Example: Person telephoneno firstname lastname Hero uses Power reach weakness alias situation type name Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 46

47 5.2 Conversion from ER Entity types: Person telephoneno firstname lastname Hero Person(firstname:Varchar(20), lastname: Varchar(30), telephoneno: Integer) alias weakness Hero(firstname: Varchar(20), lastname: Varchar(30), alias : Varchar(20), weakness : Varchar(10)) Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 47

48 5.2 Conversion from ER Relationship types: Hero uses Power reach weakness alias situation type name Hero(firstname: Varchar(20), lastname: Varchar(30), alias : Varchar(20), weakness : Varchar(10)) Power(name :Varchar(20), type : Varchar(20), reach : Integer) Uses(firstname:Varchar(20), lastname: Varchar(30), name : Varchar(20), situation : Varchar(30)) Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 48

49 5.2 Conversion from ER Note: The ER diagram is semantically richer than the relational model Examples: No key constraints and functionalities yet Integrity constraints like disjoint/overlapping generalization cannot be expressed Therefore, it usually is a really good idea to create an ER diagram before coding a logical schema Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 49

50 5.2 Integrity Constraints Integrity constraints are difficult to model in ER Basically annotations to the diagram, especially for behavioral constraints Example: The popularity rating of any assistant should always be less than the respective professor s But some structural constraints can directly be expressed Key constraints Functionalities Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 50

51 5.2 Inherent Constraints A relation is defined as a set of tuples All tuples have to be distinct, i.e., no two tuples can have the same combinations of values for all attributes So-called uniqueness (unique key) constraint Any subset of a relation type s attributes is called a superkey if two tuples never can share the same values with respect to this subset The set of all attributes is always a superkey, but there may be smaller sets Superkeys may have redundant attributes Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 51

52 5.2 Inherent Constraints A minimal superkey is called a key Minimal means that no attribute can be removed without losing the superkey property Of course, a relation can have several keys The key property is determined from the semantics of the attributes, not from the current data instances Example: Relation address(street, number, zip code, city) Keys: {street, number, zip code} and {street, number, city} Assumption: No city contains streets that share the same name but differ only in their zip code Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 52

53 5.2 Inherent Constraints The set of keys of some relation R is called candidate key set or cand(r) For each relation, a single candidate key has to be chosen to identify tuples in the relation, the so-called primary key Analogously to ER diagrams, the chosen primary key is often underlined in the relation schema Example: address(street, number, zip-code, city) Though any candidate key can be chosen, it is usually better to choose a primary key with a small number of attributes Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 53

54 5.2 Inherent Constraints Assume that an ER diagram is converted into relation schemas, what are the candidate keys of the relation schemas? If the relation schema has been derived from some entity type E with key attributes K E := {A 1,, A n }, then K E cand(r) has been derived from an N:M relationship type betweeneandf, thenk E K F cand(r) Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 54

55 5.2 Inherent Constraints If the relation schema has been derived from an 1:1 relationship type between E and F, then cand(e) cand(f) = cand(r) has been derived from an N:1 relationship type betweene 1,,E n andf, thenk E 1 K E n cand(r) In this case, it might also be a good to add F s key attributes Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 55

56 5.2 Inherent Constraints Another constraint from ER diagrams is whether a value has to be provided for some attribute NULL values, allowed by default Again, this is a semantic property A second inherent constraint for each relation is that primary keys must never be NULL So-called entity integrity constraint Example: address( street NOT NULL, number NOT NULL, zip-code, city NOT NULL ) Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 56

57 5.2 Inherent Constraints A third integrity constraint applies to all relation schemas that have been derived from relationship types Relationship types borrow their (primary) keys from the entities involved, so-called foreign keys Relationships only exists, if the respective entities exist So-called referential integrity constraint Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 57

58 5.2 Inherent Constraints Example: Hero uses Power situation Uses(firstname:Varchar(20), lastname: Varchar(30), name: Varchar(20), situation : Varchar(30)) Foreign key from Hero Foreign key from Power If a tuple ( Clark, Kent, X-Ray vision, Bomb threat ) exists in Uses, there has to be a tuple ( Clark, Kent, ) in Hero and a tuple ( X-Ray vision, ) in Power Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 58

59 5.2 Inherent Constraints All these three structural constraints have to be checked by the database Unique key constraint Entity integrity constraint Referential integrity constraint This is especially necessary when inserting, deleting, or updating tuples in relations Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 59

60 5.2 First Normal Form There is a another major constraint on the attributes data types in the relational model The value of any attribute must be atomic, that is, it cannot be composed of several other attributes If this property is met, the relation is often referred to as a being in first normal form (1NF or minimal form) In particular, set-valued and relation-valued attributes (tables within tables) are prohibited Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 60

61 5.2 First Normal Form Example of a set-valued column: A person may own several telephones (home, office, cell, ) Person firstname lastname telephoneno Clark Joseph Kent Louise Lane { , , } Lex Luthor Charles Xavier Erik Magnus { , } Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 61

62 5.2 First Normal Form Note: It is possible to model composed attributes in ER models To transform such a model into the relational model, a normalization step is needed This is not always trivial, e.g., what happens to keys? Person firstname lastname telephoneno Clark Joseph Kent Louise Lane Louise Lane Louise Lane Lex Luthor Charles Xavier Erik Magnus Erik Magnus Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 62

63 5.2 First Normal Form In a purely relational database, all relations are in first normal form Object-oriented databases feature multi-valued attributes, thus closing the modeling gap Object-relational extensions integrate user-defined types (UDTs) into relational databases Oracle from version 9i, IBM DB2 from version 8.1, Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 63

64 5.3 Relational Algebra How do you work with relations? Relational algebra! Proposed by Edgar F. Codd: A Relational Model for Large Shared Data Banks, Communications of the ACM, 1970 The theoretical foundation of all relational databases Describes how to manipulate relations and retrieve interesting parts of available relations Relational algebra is mandatory for advanced tasks like query optimization Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 64

65 5.3 Relational Algebra Elementary operations: Set algebra operations Set Union Set Intersection Set Difference Cartesian Product New relational algebra operations Selection σ Projection π Renaming ρ Additional derived operations (for convenience) All sorts of joins,,, Division EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 65

66 5.3 Example Relations students matnr firstname lastname sex 1005 Clark Kent m 2832 Louise Lane f 4512 Lex Luther m 5119 Charles Xavier m 6676 Erik Magnus m 8024 Jeanne Gray f 9876 Logan m courses crsnr title 100 Intro. to being a Superhero 101 Secret Identities How to take over the world exams student course result EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 66

67 5.3 Relational Algebra Selection σ Selects all tuples (rows) from a relation that satisfy some given Boolean predicate (condition) Selection = Create a new relation that contains exactly the satisfying tuples σ <condition condition>(r) Condition clauses: <attribute> θ<value> <attribute> θ<attribute> θ {=, <,,, >, } Clauses may be connected by, and (logical AND, OR, and NOT) EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 67

68 5.3 Relational Algebra Example: students matnr firstname lastname sex 1005 Clark Kent m 2832 Louise Lane f 4512 Lex Luther m 5119 Charles Xavier m 6676 Erik Magnus m 8024 Jeanne Gray f 9876 Logan m Select all female students σ sex= f (students) EN 6 σ sex= f (students) matnr firstname lastname sex 2832 Louise Lane f 8024 Jeanne Gray f Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 68

69 5.3 Relational Algebra Example: exams student course result Select exams within course 100 with a result of worse than 3.0 σ course=100 result>3.0 (exams) σ course=100 result>3.0 (exams) student course result EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 69

70 5.3 Relational Algebra Projection π Retains only attributes (columns) with given names Again: Creates a new relation with only those attribute sets which are specified within some attribute list If tuples are identical after projection, duplicate tuples are removed π <attributelist> (R) courses crsnr title 100 Intro. to being a Superhero 101 Secret Identities How to take over the world All courses titles : π title (courses) π title (courses) title title Intro. to being a Superhero Secret Identities 2 How to take over the world EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 70

71 5.3 Relational Algebra Of course, these operations can be combined Retrieve first name and last name of all female students π firstname, lastname sex=ʼfʼ students firstname lastnameσ sex ʼfʼ students matnr firstname lastname sex 1005 Clark Kent m 2832 Louise Lane f 4512 Lex Luther m 5119 Charles Xavier m 6676 Erik Magnus m 8024 Jeanne Gray f 9876 Logan m σ sex= f students matnr firstname lastname sex 2832 Louise Lane f 8024 Jeanne Gray f π firstname, lastname σ sex=ʼfʼstudents firstname lastname Loise Lane Jeanne Gray EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 71

72 5.3 Relational Algebra Renaming operator ρ Renames a relation and/or its attributes Also denoted by ρ S(B1, B2,, Bn) (R) or ρ S (R) or ρ (B1, B2,, Bn) (R) courses Retrieve all course numbers contained in courses and name the resulting relation lectures lectures π crsnr courses crsnr crsnr title 100 Intro. to being a Superhero 101 Secret Identities How to take over the world lectures crsnr EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 72

73 5.3 Relational Algebra Renaming operator ρ Select all result of course 100 from exams; the resulting relation should be called result and contain the attributes matno, crsno, and grade ρ results(matno matno, crsno, grade)σ course=100 exams results matno crsno, grade) course =100 σ course=100 exams student course result results matno crsno grade EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 73

74 5.3 Relational Algebra Union, intersection, and set difference Operators work as in set theory Operands have to be union-compatible (i.e., they must consist of the same attributes) Written as R S, R S, and R S, respectively σ course=100 exams course title σ course=100 exams σ course=102 exams 100 Intro. to being a Superhero course title σ course=102 exams course title 100 Intro. to being a Superhero 102 How to take over the world 102 How to take over the world EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 74

75 5.3 Relational Algebra Cartesian product Written as R S Also called cross product Creates a new relation by combining each tuple of the first relation with every tuple of the second relation Attribute set = all attributes of R plus all attributes of S The resulting relation contains exactly R S tuples EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 75

76 5.3 Relational Algebra goodgrades females student course result matno lastname Lane Gray cross student course result matno lastname Lane Lane Lane Gray Gray Gray females π matno goodgrades σ result 3.0 exams result 3.0 matno, lastnameσ sex=female femalestudents cross goodgrades females EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 76

77 5.3 Relational Algebra π lastname, title, result σ matno=student course=crsno crsno crsno females goodgrades courses lastname course result Lane How to take over the world? 2.0 This type of statement is very important! Cartesian product, followed by selections/projections Selections/projections involve different source relations This kind of query is called a join EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 77

78 5.3 Relational Algebra Theta join (θ) (θ is a Boolean condition) Sometimes also called inner join or just join Creates a new relation by combining related tuples from different source relations Written as R σ(condition condition) S or Theta joins are very similar to selections π lastname, title, result result females σ(matno matno=student π lastname, title, result σ matno=student course=crsno crsno lastname course result Lane How to take over the world? 2.0 σ (condition condition)(r S) student)goodgrades σ(course course=crsno crsno) courses crsno(females goodgrades courses) EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 78

79 5.3 Relational Algebra Equi-join (condition condition) Joins two relations only using equality conditions R (condition condition) S condition may only contain equality statements between attributes (A 1 =A 2 ) A special case of the theta join π lastname, title, result result females matno student goodgrades course matno=student π lastname, title, result σ matno=student course=crsno crsno lastname course result Lane How to take over the world? 2.0 course=crsno crsno crsno courses crsno females goodgrades courses EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 79

80 5.3 Relational Algebra Natural join A special case of the equi-join R (attributelist attributelist) S Implicit join condition Each attribute in attributelist must be contained in both source relations For each of these attributes, an equality condition is created All these conditions are connected by logical AND If attributelist is empty: Join attributes = All attributes that are shared between the two relations (that is, that have the same name) EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 80

81 5.3 Relational Algebra goodgrades matno crsnr result females matno lastname 2832 Lane 8024 Gray courses crsnr title 100 Intro. to being a Superhero 101 Secret Identities How to take over the world π lastname, title, result females goodgrades courses lastname course result Lane How to take over the world? 2.0 EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 81

82 5.3 Relational Algebra Left outer join and right outer join Theta-joins and its specializations join exactly those tuples that satisfy the join condition Tuples without a matching join partner are eliminated and will not appear in the result All information about non-matching tuples gets lost Outer joins allow to keep all tuples of a relation Padding with NULL values if there is no join partner Left outer join : Keeps all tuples of the left relation Right outer join : Keeps all tuples of the right relation Full outer join : Keeps all tuples of both relations EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 82

83 5.3 Relational Algebra Example: List students and their exam results π lastname, crsnr, result result students exams students exams matnr firstname lastname sex matnr crsnr result 1005 Clark Kent m Louise Lane f Lex Luther m Charles Xavier m π lastname, crsnr, result students exams lastname crsnr result Kent Kent Lane Lex Luther and Charles Xavier are lost because they didn t take any exams! Also, information on student 9876 disappears Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 83

84 5.3 Relational Algebra Left outer join: List students and their exam results π lastname, crsnr, result students matnr firstname lastname sex 1005 Clark Kent m 2832 Louise Lane f 4512 Lex Luther m 5119 Charles Xavier m π lastname, crsnr, result students exams lastname crsnr result Kent Kent Lane Luther NULL NULL Xavier NULL NULL result students exams exams matnr crsnr result Now, you could easily count all non-null results to get student statistics without looking into the students table. Kent: 2; Lane: 1; Luther: 0; Xavier: 0 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 84

85 5.3 Relational Algebra Right outer join: π lastname, crsnr, result students result students exams exams matnr firstname lastname sex matnr crsnr result 1005 Clark Kent m Louise Lane f Lex Luther m Charles Xavier m π lastname, crsnr, result students exams lastname crsnr result Kent Kent Lane NULL All exam result with student names if known. Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 85

86 5.3 Relational Algebra Full outer join: π lastname, crsnr, result students matnr firstname lastname sex 1005 Clark Kent m 2832 Louise Lane f 4512 Lex Luther m 5119 Charles Xavier m lastname crsnr result Kent Kent Lane Luther NULL NULL NULL Xavier NULL NULL result students exams exams matnr crsnr result π lastname, crsnr, result students exams Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 86

87 5.3 Relational Algebra Left semi-join and right semi-join Combination of a theta-join and projection R (condition S π (list of all attributes in R) (R) (condition R (condition S π (list of all attributes in S) (R) (condition condition)s condition S condition)s condition S (list of all attributes in S) condition)s condition)s condition Creates a copy of R (or S) while removing all those tuples that do not have a join partner A filtering operation Works like a natural join if condition is empty Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 87

88 5.3 Relational Algebra Left semi-join: students exams students matnr firstname lastname sex 1005 Clark Kent m 2832 Louise Lane f 4512 Lex Luther m 5119 Charles Xavier m exams matnr crsnr result students exams matnr firstname lastname sex 1005 Clark Kent m 2832 Louise Lane f All hard-trying students (those who did exams). Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 88

89 5.3 Relational Algebra Division Written R S S contains only attributes that are also present in R Division restricts R in terms of attributes and tuples Result s attributes = those in R but not in S Result s tuples = those in R such that any tuple in S is a join partner Useful for queries like Find the sailors who have reserved all boats. More formal: Let A R ={attributes of R}; A S ={attributes of S}; A S A R A = A R A S R S π A (R) π A ((π A (R) S) R R) Why the name division? Because (R S) S) S S = R. But: (R S) S S = R is not true in general Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 89

90 5.3 Relational Algebra Division: SC (= students and courses) matnr name crsnr 1000 Clark Kent C Clark Kent C Louise Lane C Lex Luther C Lex Luther C Lex Luther C Charles Xavier C Charles Xavier C100 Result contains all those students who took the same courses as Clark Kent (and possibly some more). CCK (= courses of Clark Kent) CCK π crsnr σ name= Clark Kent SC crsnr C100 C102 SC CCK matnr name 1000 Clark Kent 1002 Lex Luther EN 6 Relational Database Systems 1 Wolf-Tilo Balke Institut für Informationssysteme TU Braunschweig 90

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Benjamin Köhncke Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de Overview Basic set theory Relational data model

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Benjamin Köhncke Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de Overview Motivation Relational Algebra Query Optimization

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Jan-Christoph Kalo Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 6 Relational Algebra Motivation Relational Algebra

More information

Relational Database Systems 2 5. Query Processing

Relational Database Systems 2 5. Query Processing Relational Database Systems 2 5. Query Processing Silke Eckstein Andreas Kupfer Institut für Informationssysteme Technische Universität Braunschweig http://www.ifis.cs.tu-bs.de 5 Query Processing 5.1 Introduction:

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Hermann Kroll, Janus Wawrzinek, Stephan Mennicke Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de Common Mistakes

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke / Stephan Mennicke Hermann Kroll / Janus Wawrzinek Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 6 Relational Algebra

More information

Relational Database Systems 2 5. Query Processing

Relational Database Systems 2 5. Query Processing Relational Database Systems 2 5. Query Processing Silke Eckstein Benjamin Köhncke Institut für Informationssysteme Technische Universität Braunschweig http://www.ifis.cs.tu-bs.de 4 Trees & Advanced Indexes

More information

5.3 Parser and Translator. 5.3 Parser and Translator. 5.3 Parser and Translator. 5.3 Parser and Translator. 5.3 Parser and Translator

5.3 Parser and Translator. 5.3 Parser and Translator. 5.3 Parser and Translator. 5.3 Parser and Translator. 5.3 Parser and Translator 5 Query Processing Relational Database Systems 2 5. Query Processing Silke Eckstein Andreas Kupfer Institut für Informationssysteme Technische Universität Braunschweig http://www.ifis.cs.tu-bs.de 5.1 Introduction:

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Silke Eckstein Benjamin Köhncke Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de Overview Relational tuple calculus SQUARE & SEQUEL

More information

Relational Database Systems 1. Christoph Lofi Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig

Relational Database Systems 1. Christoph Lofi Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig Relational Database Systems 1 Christoph Lofi Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 7.0 Summary Basic relational algebra Selection σ Projection

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Stephan Mennicke Jan-Christoph Kalo Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 7.0 Introduction Beside the relational algebra,

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Philipp Wille Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 8.0 Overview of SQL SQL Queries SELECT Data Manipulation

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Benjamin Köhncke Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de Overview SQL Queries SELECT Data manipulation language

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Jan-Christoph Kalo Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 8.0 Overview of SQL SQL Queries SELECT Data Manipulation

More information

Relational Model: History

Relational Model: History Relational Model: History Objectives of Relational Model: 1. Promote high degree of data independence 2. Eliminate redundancy, consistency, etc. problems 3. Enable proliferation of non-procedural DML s

More information

RELATIONAL DATA MODEL: Relational Algebra

RELATIONAL DATA MODEL: Relational Algebra RELATIONAL DATA MODEL: Relational Algebra Outline 1. Relational Algebra 2. Relational Algebra Example Queries 1. Relational Algebra A basic set of relational model operations constitute the relational

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Silke Eckstein Benjamin Köhncke Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 2. Data Modeling Introduction Data Models Phases

More information

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions.

Relational Model History. COSC 304 Introduction to Database Systems. Relational Model and Algebra. Relational Model Definitions. COSC 304 Introduction to Database Systems Relational Model and Algebra Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was

More information

Review for Exam 1 CS474 (Norton)

Review for Exam 1 CS474 (Norton) Review for Exam 1 CS474 (Norton) What is a Database? Properties of a database Stores data to derive information Data in a database is, in general: Integrated Shared Persistent Uses of Databases The Integrated

More information

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity COSC 416 NoSQL Databases Relational Model (Review) Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Relational Model History The relational model was proposed by E. F. Codd

More information

CS317 File and Database Systems

CS317 File and Database Systems CS317 File and Database Systems Lecture 3 Relational Model & Languages Part-1 September 7, 2018 Sam Siewert More Embedded Systems Summer - Analog, Digital, Firmware, Software Reasons to Consider Catch

More information

Relational Model, Relational Algebra, and SQL

Relational Model, Relational Algebra, and SQL Relational Model, Relational Algebra, and SQL August 29, 2007 1 Relational Model Data model. constraints. Set of conceptual tools for describing of data, data semantics, data relationships, and data integrity

More information

CS 377 Database Systems

CS 377 Database Systems CS 377 Database Systems Relational Algebra and Calculus Li Xiong Department of Mathematics and Computer Science Emory University 1 ER Diagram of Company Database 2 3 4 5 Relational Algebra and Relational

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 10.0 Introduction Up to now, we have learned......

More information

Relational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

Relational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan Relational Model DCS COMSATS Institute of Information Technology Rab Nawaz Jadoon Assistant Professor COMSATS IIT, Abbottabad Pakistan Management Information Systems (MIS) Relational Model Relational Data

More information

Relational Database Systems 1 Wolf-Tilo Balke Hermann Kroll, Janus Wawrzinek, Stephan Mennicke

Relational Database Systems 1 Wolf-Tilo Balke Hermann Kroll, Janus Wawrzinek, Stephan Mennicke Relational Database Systems 1 Wolf-Tilo Balke Hermann Kroll, Janus Wawrzinek, Stephan Mennicke Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 10.0 Introduction

More information

Lecture 03. Spring 2018 Borough of Manhattan Community College

Lecture 03. Spring 2018 Borough of Manhattan Community College Lecture 03 Spring 2018 Borough of Manhattan Community College 1 2 Outline 1. Brief History of the Relational Model 2. Terminology 3. Integrity Constraints 4. Views 3 History of the Relational Model The

More information

Chapter 3. The Relational Model. Database Systems p. 61/569

Chapter 3. The Relational Model. Database Systems p. 61/569 Chapter 3 The Relational Model Database Systems p. 61/569 Introduction The relational model was developed by E.F. Codd in the 1970s (he received the Turing award for it) One of the most widely-used data

More information

Data about data is database Select correct option: True False Partially True None of the Above

Data about data is database Select correct option: True False Partially True None of the Above Within a table, each primary key value. is a minimal super key is always the first field in each table must be numeric must be unique Foreign Key is A field in a table that matches a key field in another

More information

Databases 1. Daniel POP

Databases 1. Daniel POP Databases 1 Daniel POP Week 4 Agenda The Relational Model 1. Origins and history 2. Key concepts 3. Relational integrity 4. Relational algebra 5. 12+1 Codd rules for a relational DBMSes 7. SQL implementation

More information

Relational Database Systems 2 6. Query Optimization

Relational Database Systems 2 6. Query Optimization Relational Database Systems 2 6. Query Optimization Silke Eckstein Benjamin Köhncke Institut für Informationssysteme Technische Universität Braunschweig http://www.ifis.cs.tu-bs.de 5 Query Processing The

More information

v Conceptual Design: ER model v Logical Design: ER to relational model v Querying and manipulating data

v Conceptual Design: ER model v Logical Design: ER to relational model v Querying and manipulating data Outline Conceptual Design: ER model Relational Algebra Calculus Yanlei Diao UMass Amherst Logical Design: ER to relational model Querying and manipulating data Practical language: SQL Declarative: say

More information

Chapter 6: RELATIONAL DATA MODEL AND RELATIONAL ALGEBRA

Chapter 6: RELATIONAL DATA MODEL AND RELATIONAL ALGEBRA Chapter 6: Relational Data Model and Relational Algebra 1 Chapter 6: RELATIONAL DATA MODEL AND RELATIONAL ALGEBRA RELATIONAL MODEL CONCEPTS The relational model represents the database as a collection

More information

Relational Database Systems 2 6. Query Optimization

Relational Database Systems 2 6. Query Optimization Relational Database Systems 2 6. Query Optimization Silke Eckstein Andreas Kupfer Institut für Informationssysteme Technische Universität Braunschweig http://www.ifis.cs.tu-bs.de 6 Query Optimization 6.1

More information

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity

Relational model continued. Understanding how to use the relational model. Summary of board example: with Copies as weak entity COS 597A: Principles of Database and Information Systems Relational model continued Understanding how to use the relational model 1 with as weak entity folded into folded into branches: (br_, librarian,

More information

Database Technology Introduction. Heiko Paulheim

Database Technology Introduction. Heiko Paulheim Database Technology Introduction Outline The Need for Databases Data Models Relational Databases Database Design Storage Manager Query Processing Transaction Manager Introduction to the Relational Model

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Jan-Christoph Kalo Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de Summary last week Databases are logical interfaces

More information

ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION

ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION JING YANG 2010 FALL Class 3: The Relational Data Model and Relational Database Constraints Outline 2 The Relational Data Model and Relational Database Constraints

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Christoph Lofi Institut für Informationssysteme Technische Universität Braunschweig http://www.ifis.cs.tu-bs.de Data Modeling Introduction Basic ER Modeling

More information

COSC344 Database Theory and Applications. σ a= c (P) Lecture 3 The Relational Data. Model. π A, COSC344 Lecture 3 1

COSC344 Database Theory and Applications. σ a= c (P) Lecture 3 The Relational Data. Model. π A, COSC344 Lecture 3 1 COSC344 Database Theory and Applications σ a= c (P) S P Lecture 3 The Relational Data π A, C (H) Model COSC344 Lecture 3 1 Overview Last Lecture Database design ER modelling This Lecture Relational model

More information

Relational Database: The Relational Data Model; Operations on Database Relations

Relational Database: The Relational Data Model; Operations on Database Relations Relational Database: The Relational Data Model; Operations on Database Relations Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin Overview

More information

Chapter 4. The Relational Model

Chapter 4. The Relational Model Chapter 4 The Relational Model Chapter 4 - Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations and relations in the relational model.

More information

Unit- III (Functional dependencies and Normalization, Relational Data Model and Relational Algebra)

Unit- III (Functional dependencies and Normalization, Relational Data Model and Relational Algebra) Unit- III (Functional dependencies and Normalization, Relational Data Model and Relational Algebra) Important questions Section A :(2 Marks) 1.What is Functional Dependency? Functional dependency (FD)

More information

Relational Query Languages. Preliminaries. Formal Relational Query Languages. Example Schema, with table contents. Relational Algebra

Relational Query Languages. Preliminaries. Formal Relational Query Languages. Example Schema, with table contents. Relational Algebra Note: Slides are posted on the class website, protected by a password written on the board Reading: see class home page www.cs.umb.edu/cs630. Relational Algebra CS430/630 Lecture 2 Relational Query Languages

More information

Basant Group of Institution

Basant Group of Institution Basant Group of Institution Visual Basic 6.0 Objective Question Q.1 In the relational modes, cardinality is termed as: (A) Number of tuples. (B) Number of attributes. (C) Number of tables. (D) Number of

More information

Mahathma Gandhi University

Mahathma Gandhi University Mahathma Gandhi University BSc Computer science III Semester BCS 303 OBJECTIVE TYPE QUESTIONS Choose the correct or best alternative in the following: Q.1 In the relational modes, cardinality is termed

More information

CIS 330: Applied Database Systems. ER to Relational Relational Algebra

CIS 330: Applied Database Systems. ER to Relational Relational Algebra CIS 330: Applied Database Systems ER to Relational Relational Algebra 1 Logical DB Design: ER to Relational Entity sets to tables: ssn name Employees lot CREATE TABLE Employees (ssn CHAR(11), name CHAR(20),

More information

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 3 Relational Model Hello everyone, we have been looking into

More information

Ian Kenny. November 28, 2017

Ian Kenny. November 28, 2017 Ian Kenny November 28, 2017 Introductory Databases Relational Algebra Introduction In this lecture we will cover Relational Algebra. Relational Algebra is the foundation upon which SQL is built and is

More information

Midterm Review. Winter Lecture 13

Midterm Review. Winter Lecture 13 Midterm Review Winter 2006-2007 Lecture 13 Midterm Overview 3 hours, single sitting Topics: Relational model relations, keys, relational algebra expressions SQL DDL commands CREATE TABLE, CREATE VIEW Specifying

More information

Lecture 03. Fall 2017 Borough of Manhattan Community College

Lecture 03. Fall 2017 Borough of Manhattan Community College Lecture 03 Fall 2017 Borough of Manhattan Community College 1 2 Outline 1 Brief History of the Relational Model 2 Terminology 3 Integrity Constraints 4 Views 3 History of the Relational Model The Relational

More information

THE RELATIONAL DATABASE MODEL

THE RELATIONAL DATABASE MODEL THE RELATIONAL DATABASE MODEL Introduction to relational DB Basic Objects of relational model Properties of relation Representation of ER model to relation Keys Relational Integrity Rules Functional Dependencies

More information

Relational Database Systems 1. Christoph Lofi Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig

Relational Database Systems 1. Christoph Lofi Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig Relational Database Systems 1 Christoph Lofi Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 10.0 Introduction Up to now, we have learned... how

More information

; Spring 2008 Prof. Sang-goo Lee (14:30pm: Mon & Wed: Room ) ADVANCED DATABASES

; Spring 2008 Prof. Sang-goo Lee (14:30pm: Mon & Wed: Room ) ADVANCED DATABASES 4541.564; Spring 2008 Prof. Sang-goo Lee (14:30pm: Mon & Wed: Room 302-208) ADVANCED DATABASES Syllabus Text Books Exams (tentative dates) Database System Concepts, 5th Edition, A. Silberschatz, H. F.

More information

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data. Managing Data Data storage tool must provide the following features: Data definition (data structuring) Data entry (to add new data) Data editing (to change existing data) Querying (a means of extracting

More information

Relational Data Model

Relational Data Model Relational Data Model 1. Relational data model Information models try to put the real-world information complexity in a framework that can be easily understood. Data models must capture data structure

More information

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #2: The Relational Model and Relational Algebra

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #2: The Relational Model and Relational Algebra CS 4604: Introduction to Database Management Systems B. Aditya Prakash Lecture #2: The Relational Model and Relational Algebra Course Outline Weeks 1 4: Query/ Manipulation Languages and Data Modeling

More information

Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra

Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra Relational Data Model and Relational Constraints Part 1 A simplified diagram to illustrate the main

More information

Informationslogistik Unit 4: The Relational Algebra

Informationslogistik Unit 4: The Relational Algebra Informationslogistik Unit 4: The Relational Algebra 26. III. 2012 Outline 1 SQL 2 Summary What happened so far? 3 The Relational Algebra Summary 4 The Relational Calculus Outline 1 SQL 2 Summary What happened

More information

Fundamentals of Database Systems

Fundamentals of Database Systems Fundamentals of Database Systems Assignment: 1 Due Date: 8th August, 2017 Instructions This question paper contains 15 questions in 5 pages. Q1: The users are allowed to access different parts of data

More information

ECE 650 Systems Programming & Engineering. Spring 2018

ECE 650 Systems Programming & Engineering. Spring 2018 ECE 650 Systems Programming & Engineering Spring 2018 Relational Databases: Tuples, Tables, Schemas, Relational Algebra Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) Overview

More information

Introduction to Relational Databases. Introduction to Relational Databases cont: Introduction to Relational Databases cont: Relational Data structure

Introduction to Relational Databases. Introduction to Relational Databases cont: Introduction to Relational Databases cont: Relational Data structure Databases databases Terminology of relational model Properties of database relations. Relational Keys. Meaning of entity integrity and referential integrity. Purpose and advantages of views. The relational

More information

CS 377 Database Systems

CS 377 Database Systems CS 377 Database Systems Relational Data Model Li Xiong Department of Mathematics and Computer Science Emory University 1 Outline Relational Model Concepts Relational Model Constraints Relational Database

More information

Relational Algebra. Note: Slides are posted on the class website, protected by a password written on the board

Relational Algebra. Note: Slides are posted on the class website, protected by a password written on the board Note: Slides are posted on the class website, protected by a password written on the board Reading: see class home page www.cs.umb.edu/cs630. Relational Algebra CS430/630 Lecture 2 Slides based on Database

More information

Relational Data Model ( 관계형데이터모델 )

Relational Data Model ( 관계형데이터모델 ) Relational Data Model ( 관계형데이터모델 ) Outline Terminology of Relational Model Mathematical Relations and Database Tables Candidate, Primary, and Foreign Keys Terminology in the Relational Model Relation:

More information

CMP-3440 Database Systems

CMP-3440 Database Systems CMP-3440 Database Systems Relational DB Languages Relational Algebra, Calculus, SQL Lecture 05 zain 1 Introduction Relational algebra & relational calculus are formal languages associated with the relational

More information

The Relational Data Model (ALL the Vocabulary)

The Relational Data Model (ALL the Vocabulary) (ALL the Vocabulary) Lecture 2 1 A Quick Reminder One of the key features of a DBMS is use of data models to support data independence The conceptual representation is independent of underlying storage

More information

Comp 5311 Database Management Systems. 2. Relational Model and Algebra

Comp 5311 Database Management Systems. 2. Relational Model and Algebra Comp 5311 Database Management Systems 2. Relational Model and Algebra 1 Basic Concepts of the Relational Model Entities and relationships of the E-R model are stored in tables also called relations (not

More information

8) A top-to-bottom relationship among the items in a database is established by a

8) A top-to-bottom relationship among the items in a database is established by a MULTIPLE CHOICE QUESTIONS IN DBMS (unit-1 to unit-4) 1) ER model is used in phase a) conceptual database b) schema refinement c) physical refinement d) applications and security 2) The ER model is relevant

More information

ADVANCED DATABASES ; Spring 2015 Prof. Sang-goo Lee (11:00pm: Mon & Wed: Room ) Advanced DB Copyright by S.-g.

ADVANCED DATABASES ; Spring 2015 Prof. Sang-goo Lee (11:00pm: Mon & Wed: Room ) Advanced DB Copyright by S.-g. 4541.564; Spring 2015 Prof. Sang-goo Lee (11:00pm: Mon & Wed: Room 301-203) ADVANCED DATABASES Copyright by S.-g. Lee Review - 1 General Info. Text Book Database System Concepts, 6 th Ed., Silberschatz,

More information

The Relational Model and Relational Algebra

The Relational Model and Relational Algebra The Relational Model and Relational Algebra Background Introduced by Ted Codd of IBM Research in 1970. Concept of mathematical relation as the underlying basis. The standard database model for most transactional

More information

CS275 Intro to Databases

CS275 Intro to Databases CS275 Intro to Databases The Relational Data Model Chap. 3 How Is Data Retrieved and Manipulated? Queries Data manipulation language (DML) Retrieval Add Delete Update An Example UNIVERSITY database Information

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de Overview Advanced database concepts for application

More information

Why Study the Relational Model? The Relational Model. Relational Database: Definitions. The SQL Query Language. Relational Query Languages

Why Study the Relational Model? The Relational Model. Relational Database: Definitions. The SQL Query Language. Relational Query Languages Why Study the Relational Model? The Relational Model Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. Legacy systems in older models E.G., IBM s IMS Recent competitor: object-oriented

More information

Relational Model and Relational Algebra. Rose-Hulman Institute of Technology Curt Clifton

Relational Model and Relational Algebra. Rose-Hulman Institute of Technology Curt Clifton Relational Model and Relational Algebra Rose-Hulman Institute of Technology Curt Clifton Administrative Notes Grading Weights Schedule Updated Review ER Design Techniques Avoid redundancy and don t duplicate

More information

Relational Database Systems Part 01. Karine Reis Ferreira

Relational Database Systems Part 01. Karine Reis Ferreira Relational Database Systems Part 01 Karine Reis Ferreira karine@dpi.inpe.br Aula da disciplina Computação Aplicada I (CAP 241) 2016 Database System Database: is a collection of related data. represents

More information

Relational Algebra 1

Relational Algebra 1 Relational Algebra 1 Relational Query Languages v Query languages: Allow manipulation and retrieval of data from a database. v Relational model supports simple, powerful QLs: Strong formal foundation based

More information

CS2300: File Structures and Introduction to Database Systems

CS2300: File Structures and Introduction to Database Systems CS2300: File Structures and Introduction to Database Systems Lecture 9: Relational Model & Relational Algebra Doug McGeehan 1 Brief Review Relational model concepts Informal Terms Formal Terms Table Relation

More information

Chapter 6 The Relational Algebra and Relational Calculus

Chapter 6 The Relational Algebra and Relational Calculus Chapter 6 The Relational Algebra and Relational Calculus Fundamentals of Database Systems, 6/e The Relational Algebra and Relational Calculus Dr. Salha M. Alzahrani 1 Fundamentals of Databases Topics so

More information

Relational terminology. Databases - Sets & Relations. Sets. Membership

Relational terminology. Databases - Sets & Relations. Sets. Membership Relational terminology Databases - & Much of the power of relational databases comes from the fact that they can be described analysed mathematically. In particular, queries can be expressed with absolute

More information

Relational Query Languages: Relational Algebra. Juliana Freire

Relational Query Languages: Relational Algebra. Juliana Freire Relational Query Languages: Relational Algebra Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model supports simple, powerful QLs: Simple

More information

CMPT 354: Database System I. Lecture 5. Relational Algebra

CMPT 354: Database System I. Lecture 5. Relational Algebra CMPT 354: Database System I Lecture 5. Relational Algebra 1 What have we learned Lec 1. DatabaseHistory Lec 2. Relational Model Lec 3-4. SQL 2 Why Relational Algebra matter? An essential topic to understand

More information

The Relational Model

The Relational Model The Relational Model What is the Relational Model Relations Domain Constraints SQL Integrity Constraints Translating an ER diagram to the Relational Model and SQL Views A relational database consists

More information

2.1 Sets 2.2 Set Operations

2.1 Sets 2.2 Set Operations CSC2510 Theoretical Foundations of Computer Science 2.1 Sets 2.2 Set Operations Introduction to Set Theory A set is a structure, representing an unordered collection (group, plurality) of zero or more

More information

Chapter 2: Intro to Relational Model

Chapter 2: Intro to Relational Model Non è possibile visualizzare l'immagine. Chapter 2: Intro to Relational Model Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Example of a Relation attributes (or columns)

More information

Relational Algebra Homework 0 Due Tonight, 5pm! R & G, Chapter 4 Room Swap for Tuesday Discussion Section Homework 1 will be posted Tomorrow

Relational Algebra Homework 0 Due Tonight, 5pm! R & G, Chapter 4 Room Swap for Tuesday Discussion Section Homework 1 will be posted Tomorrow Relational Algebra R & G, Chapter 4 By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental power of

More information

Relational Algebra for sets Introduction to relational algebra for bags

Relational Algebra for sets Introduction to relational algebra for bags Relational Algebra for sets Introduction to relational algebra for bags Thursday, September 27, 2012 1 1 Terminology for Relational Databases Slide repeated from Lecture 1... Account Number Owner Balance

More information

Relational Algebra. Study Chapter Comp 521 Files and Databases Fall

Relational Algebra. Study Chapter Comp 521 Files and Databases Fall Relational Algebra Study Chapter 4.1-4.2 Comp 521 Files and Databases Fall 2010 1 Relational Query Languages Query languages: Allow manipulation and retrieval of data from a database. Relational model

More information

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1

B.H.GARDI COLLEGE OF MASTER OF COMPUTER APPLICATION. Ch. 1 :- Introduction Database Management System - 1 Basic Concepts :- 1. What is Data? Data is a collection of facts from which conclusion may be drawn. In computer science, data is anything in a form suitable for use with a computer. Data is often distinguished

More information

Unit I. By Prof.Sushila Aghav MIT

Unit I. By Prof.Sushila Aghav MIT Unit I By Prof.Sushila Aghav MIT Introduction The Need for Databases Data Models Relational Databases Database Design Storage Manager Query Processing Transaction Manager DBMS Applications DBMS contains

More information

CS211 Lecture: Database Querying and Updating

CS211 Lecture: Database Querying and Updating CS211 Lecture: Database Querying and Updating last revised 9/30/2004 Objectives: 1. To introduce the relational algebra. 2. To introduce the SQL select statement 3. To introduce the SQL insert, update,

More information

1 Relational Data Model

1 Relational Data Model Prof. Dr.-Ing. Wolfgang Lehner INTELLIGENT DATABASE GROUP 1 Relational Data Model What is in the Lecture? 1. Database Usage Query Programming Design 2 Relational Model 3 The Relational Model The Relation

More information

COSC344 Database Theory and Applications. σ a= c (P) S. Lecture 4 Relational algebra. π A, P X Q. COSC344 Lecture 4 1

COSC344 Database Theory and Applications. σ a= c (P) S. Lecture 4 Relational algebra. π A, P X Q. COSC344 Lecture 4 1 COSC344 Database Theory and Applications σ a= c (P) S π A, C (H) P P X Q Lecture 4 Relational algebra COSC344 Lecture 4 1 Overview Last Lecture Relational Model This Lecture ER to Relational mapping Relational

More information

Relational Algebra. Mr. Prasad Sawant. MACS College. Mr.Prasad Sawant MACS College Pune

Relational Algebra. Mr. Prasad Sawant. MACS College. Mr.Prasad Sawant MACS College Pune Relational Algebra Mr. Prasad Sawant MACS College Pune MACS College Relational Algebra Tuple - a collection of attributes which describe some real world entity. Attribute - a real world role played by

More information

A database can be modeled as: + a collection of entities, + a set of relationships among entities.

A database can be modeled as: + a collection of entities, + a set of relationships among entities. The Relational Model Lecture 2 The Entity-Relationship Model and its Translation to the Relational Model Entity-Relationship (ER) Model + Entity Sets + Relationship Sets + Database Design Issues + Mapping

More information

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13

CS121 MIDTERM REVIEW. CS121: Relational Databases Fall 2017 Lecture 13 CS121 MIDTERM REVIEW CS121: Relational Databases Fall 2017 Lecture 13 2 Before We Start Midterm Overview 3 6 hours, multiple sittings Open book, open notes, open lecture slides No collaboration Possible

More information

Introduction to Data Management. Lecture #11 (Relational Algebra)

Introduction to Data Management. Lecture #11 (Relational Algebra) Introduction to Data Management Lecture #11 (Relational Algebra) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v HW and exams:

More information

Information Systems (Informationssysteme)

Information Systems (Informationssysteme) Information Systems (Informationssysteme) Jens Teubner, TU Dortmund jensteubner@cstu-dortmundde Summer 2018 c Jens Teubner Information Systems Summer 2018 1 Part IV Database Design c Jens Teubner Information

More information

Relational Algebra Part I. CS 377: Database Systems

Relational Algebra Part I. CS 377: Database Systems Relational Algebra Part I CS 377: Database Systems Recap of Last Week ER Model: Design good conceptual models to store information Relational Model: Table representation with structures and constraints

More information

Relational Database Systems 1. Christoph Lofi Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig

Relational Database Systems 1. Christoph Lofi Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig Relational Database Systems 1 Christoph Lofi Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de 10 Summary Design quality of database tables can be

More information