Download presentation
Presentation is loading. Please wait.
Published byHubert McKenzie Modified over 9 years ago
1
LIS512 lecture 1 the entity-relationship model Thomas Krichel 2010-09-22
2
today entities entity sets relations identifiers building a sophisticated description…
3
entity An entity is something that is – we are interested in to describe – we can distinctly identify What you look at as an entity depends on what you want to be doing. For example, if you look at persons, you may restrict this to living people. Or you may included only people we think have actually lived. FRBR (next week) talks about entities in libraries.
4
attributes to an entity Each entity is described by a bunch of attributes. Each attributes has a name. Each attribute takes a value. We can say that we have an attribute/value pair. Example “birthday: 1965-06-05”.
5
another attribute example Let us say we have an entity called person. Each person has – birthday – sex – height – weight We can use this data, together with the present time, to determine if the person is overweight.
6
another example a person – name: Thomas – email: krichel@openlib.org – age: 48 some other person – name: Jose – email: barrueco@uv.es – age: 37
7
tables We often write information about entities in a table. Each row in the table describes an entity. The different columns contain values of attributes of the entity. Remember, this is just a way to write things.
8
example name | email address | age Thomas | krichel@openlib.org | 48 Jose | barrueco@uv.es | 37 Feng | feng.chen@gmail.com | 42
9
records in a table In fact, in the table we have a sequence of records. Each record describes an entity. The fact that there is a sequence is imposed by the fact that we list the records about each entity in a table.
10
set “set” is the most ambiguous word in the English language. In the mathematical set, it a set is a bunch of elements (or members) without any order between them. Most of the time, entities out there come in sets.
11
entity sets A group of entities is called an entity set. Each member in the set takes the same attributes. But the value that the attributes take may be different for different members in the set. Usually, entities in an entity set are commonly understood, such as users, books and libraries. But if you think about your problem a bit more, you realize that the issue is not that simple.
12
entity and entity set example A book is an entity. It has an attribute called “author”. The value is “Karl Marx”. It has an attribute called “title”. The value is “Das Kapital”. A book is something that has a title, an author etc. All books form a set.
13
relationships The entity relationship model comes to live when we look relationship. We have a relationship between entities sets when elements of one set may be related to elements in another entity set. For example, consider books and people.
14
symmetric relationships Sometimes relationships are symmetric. When one entity is related to another, the other has exactly the same relationship with the one. “being married to” is a symmetric relationship. “being husband of” is mostly not.
15
relationship types Usually, relationships are grouped by three types. There are one-to-one relationships. There are one-to-many relationships. There are many-to-many relationships.
16
one-to-one relationship Look at two entity set. In a one-to-one relationship, each entity in one set is connected to one in the other set. In a library setting, I did not find an example. Look at cars on the road. – each car has one driver – there is one driver in each car one-to-one relationships are uncommon.
17
many-to-one relationship Consider two entity sets, people and books. Each person has a favorite book. But a book can be the favorite book of more than one person. “is favorite-book of” is a many-to-one relationship between books and people. “has favorite book” is a one-to-many relationship between people and books.
18
many-to-many relationships Look at two entity sets, libraries and persons. The relationship “patronizes” is a many-to- many relationship between persons and libraries. The relationship “is patronized by” is a many- to-many relationship between libraries and persons.
19
relationship in the library world Imagine entity sets “libraries”, “books”, “users”. We can draw three relationships. – Users read books. – Users patronize libraries. – Libraries store books.
20
examples Brentwood Public Library has a copy of Moby Dick. Purchase Public Library has a copy of Moby Dick. Thomas reads Moby Dick. Thomas patronizes Brentwood Public Library.
21
tables Remember that in a database records are represented as lines in a table. The first line of the table lists the field names. Here is a sample table with two records |name | birthday | | Thomas Krichel| 1965-06-05| | Karl Marx | 1818-05-13|
22
identity Consider an extract from the same table |name | birthday | | Thomas Krichel | 1965-06-05| Is the record a duplicate? Without further information, we can not tell. Certainly, no computer can tell.
23
identity and key Identity can only be conferred by a human. Often that is some sort of information worker. A information processing system can not find identity. But there are there are tools that are used to encode the identity in an information system.
24
key To be able to find what records describe the same entities, databases use a construct called a key. An attribute is a key if the value taken by the attribute must be different for each entity. Unusually, there is only one key attribute. In that case the value taken by the key attribute is called the identifier of the entity.
25
examples Here is a correct example |key|name | birthday | |2 | Thomas Krichel | 1965-06-05| | 1 | Thomas Krichel | 1965-06-05| Here is an incorrect example |key|name | birthday | |1 | Thomas Krichel | 1965-06-05|
26
identity Identity is simple when it comes to person. But when it comes to other entities we are interested in the world of libraries. Identifiers and the handling of them is one of the most difficult issues of digital librarianship. If I have two copies of the same book are they the same book or are they different books? FRBR gives us some answer next week…
27
why bother with identity Once we have identified an entity in an entity set, we can create a relationship with an entity in another set, or in the same set. Once we have done this, we can – encode a much richer description – maintain it at relatively low cost. This can be illustrated with the introduction of a relational database.
28
relations Not all database system are relational. The most widely used ones are relational. That means you can build relationships between tables and enforce them. I am coming to this from an old example.
29
relational databases A relational database is a set of tables. There may be relations between the tables. Each table has a number of records. Each record has a number of fields. They give us values that attributes take for the entity described. Let us look at this bottom up.
30
example: Movie database ID| title | director| date M1| Gone with the wind | F. Ford Coppola | 1963 M2| Room with a view| Coppola, F Ford | 1985 M3| High Noon| Woody Allan| 1974 M4 | Star Wars| Steve Spielberg | 1993 M5| Alien| Allen, Woody | 1987 M6| Blowing in the Wind| Spielberg, Steven| 1962 Single table No relations between tables, of course
31
problem with this database All data wrong, but this is just for illustration. Name covered inconsistently. There is no way to find films by Woody Allan without having to go through all spelling variations. Mistakes are difficult to correct. We have to wade through all records, a masochist’s pleasure.
32
Better movie database ID| title |director| year M1| Gone with the wind | D1| 1963 M2| Room with a view| D1| 1985 M3| High Noon| D2| 1974 M4 | Star Wars| D3| 1993 M5| Alien| D2 | 1987 M6| Blowing in the Wind| D3| 1962 ID |director name| birth year D1| Ford Coppola, Francis| 1942 D2| Allan, Woody| 1957 D3| Spielberg, Steven| 1942
33
Relational database We have a one to many relationship between directors and film – Each film has one director – Each director has produced many films Here it becomes possible for the computer – To know which films have been directed by Woody Allen – To find which films have been directed by a director born in 1942
34
enforcing relationships Relational database software has ways to enforce relationships. So when you change the record of M5 to say it was directed by director D9, it will complain that no such director has been defined.
35
Many-to-many relationships Each film has one director, but many actors star in it. Relationship between actors and films is a many to many relationship. Here are a few actors ID| sex| actor name | birth year A1| f| Brigitte Bardot | 1972 A2| m| George Clooney| 1927 A3| f| Marilyn Monroe| 1934
36
Actor/Movie table actor id| movie id A1| M4 A2| M3 A3| M2 A1| M5 A1| M3 A2| M6 A3| M4 … as many lines as required
37
relational databases Relational databases are powerful within organizations that have a relatively centralized command and control structure, i.e. within a company and / or a government department. The relational database model has problems when we are working in a coordinated fashion between several providers of information. Imagine the web working an a relational database model!
38
http://openlib.org/home/krichel Thank you for your attention! Please switch off machines b4 leaving!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.