Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSET 3300 Databases & ER Data Models. Databases A database is a collection of data (information). A DataBase Management System (DBMS) is a software system.

Similar presentations


Presentation on theme: "CSET 3300 Databases & ER Data Models. Databases A database is a collection of data (information). A DataBase Management System (DBMS) is a software system."— Presentation transcript:

1 CSET 3300 Databases & ER Data Models

2 Databases A database is a collection of data (information). A DataBase Management System (DBMS) is a software system that manages execution of users applications to access and modify database data. – Manages very large amounts of data – Supports efficient access to very large amounts of data – Provides data security and data reliability – Supports multi-user concurrent access – Safety from system failures – Recovery – High throughput (thousands ~ millions transactions per minute)

3 Relational Database Management System Attributes (column headers) Tuples (rows) Relation name NameManufacturer WinterbrewPete’s Bud LiteAnheuser-Busch Beers  Data organized as tables called relations

4 DataBase Management System High-level Query Q DBMS Answer Data TeraBytes  PetaBytes Empire B. Bob Dylan USA Columbia 10.90 Translates Q into best execution plan for current conditions, runs plan Keeps data safe and correct despite failures, concurrent updates, online processing, etc.

5 Example: Car Sales DB IDNameAge 12Nemo22 34Ray42 89Gill36 156Dory21 ……… MakeModelOwnerID HondaAccord12 ToyotaCamry34 MiniCooper89 HondaAccord156 ……… Cars Owners Filter (Make = Honda and Model = Accord) Join (Cars.OwnerID = Owners.ID) MakeModelOwnerIDIDNameAge HondaAccord12 Nemo22 HondaAccord156 Dory21 Owners of Honda Accords who are <= 23 years old Filter (Age <= 23)

6 DB Applications It used to be about boring stuff: employee records, bank records, etc. Today, the field covers all the largest sources of data, with many new ideas. – Web search. – Scientific and medical databases. – Market transaction databases (sales data) You may not notice it, but databases are behind almost everything you do on the Web. – Google searches. – Queries at Amazon, eBay, etc.

7 Database Systems The big commercial database vendors: – Oracle – IBM (with DB2) bought Informix recently – Microsoft (SQL Server) – Sybase Some free database systems (Unix) : – Postgres – MySQL – Predator Here we use MySQL. You may use something else, but then you are on your own.

8 Three Aspects to Studying DBMS's Three broad categories – Modeling and design of databases. Allows exploration of issues before committing to an implementation. – Database programming: queries and DB operations like update. SQL – DBMS implementation. How does one build a DBMS (query processing, organizing storage, etc.)

9 Database Design The process of designing the general structure of the database: – Logical Design – Deciding on the database schema. Business decision – What properties should we record in the database? Computer Science decision – What relation schemas should we have and how should the attributes be distributed among the various relation schemas? – Physical Design – Deciding on the physical layout of the database

10 Entity-Relationship Model The E/R model allows us to sketch the design of a database informally. Designs are pictures called entity- relationship diagrams. Fairly mechanical ways to convert E/R diagrams to real implementations like relational databases exist.

11 Entity Sets Entity = “thing” or object. Entity set = collection of similar entities. – Similar to a class in object-oriented languages. Attribute = property of an entity set. – Generally, all entities in a set have the same properties. – Attributes are simple values, e.g. integers or character strings.

12 E/R Diagrams In an entity-relationship diagram, each entity set is represented by a rectangle. Each attribute of an entity set is represented by an oval, with a line to the rectangle representing its entity set. Beers namemanufacturer  Entity set Beers has two attributes, name and manufacturer.  Each Beer entity has values for these two attributes, e.g. (Bud, Anheuser- Busch)

13 Relationships A relationship connects two or more entity sets. It is represented by a diamond, with lines to each of the entity sets involved.

14 Example Drinkers addrname Beers name Bars name license addr Note: license = beer, full, none Sells Bars sell some beers. Likes Drinkers like some beers. Frequents Drinkers frequent some bars. manufacturer

15 Relationship Set The current “value” of an entity set is the set of entities that belong to it. – Example: the set of all bars in our database. The “value” of a relationship is a set of lists of currently related entities, one from each of the related entity sets.  For the relationship Sells, we might have a relationship set like: BarBeer Joe’s BarBud Joe’s BarMiller Sue’s BarBud Sue’s BarPete’s Ale Sue’s BarBud Lite

16 Binary vs. Multiway Relationships Sometimes, we need a relationship that connects more than two entity sets. Suppose that drinkers will only drink certain beers at certain bars. – Our three binary relationships Likes, Sells, and Frequents do not allow us to make this distinction. – But a 3-way relationship would.

17 Example Bars Beers Drinkers name addr nameaddr license Preferences manufacturer Bar Drinker Beer Joe’s Bar Ann Miller Sue’s Bar Ann Bud Joe’s Bar Bob Bud Joe’s Bar Bob Miller Joe’s Bar Cal Miller Sue’s Bar Cal Bud

18 One-One Relationships In a one-one relationship, each entity of either entity set is related to at most one entity of the other set.  Example: Relationship Best-seller between entity sets manufacturer and Beers.  A beer cannot be made by more than one manufacturer, and no manufacturer can have more than one best-seller (assume no ties).

19 Many-One Relationships Some binary relationships are many -one from one entity set to another. Each entity of the first set is connected to at most one entity of the second set. But an entity of the second set can be connected to zero, one, or many entities of the first set.  E.g. Favorite, from Drinkers to Beers is many-one.  A drinker has at most one favorite beer.  But a beer can be the favorite of any number of drinkers, including zero.

20 Many-Many Relationships Think of a relationship between two entity sets, such as Sells between Bars and Beers. In a many-many relationship, an entity of either set can be connected to many entities of the other set. – E.g., a bar sells many beers; a beer is sold by many bars.

21 Representing “Multiplicity” Show a many-one relationship by an arrow entering the “one” side. Show a one-one relationship by arrows entering both entity sets. DrinkersBeers Likes Favorite

22 Attributes on Relationships Sometimes it is useful to attach an attribute to a relationship. Think of this attribute as a property of tuples in the relationship set. BarsBeers Sells price Price is a function of both the bar and the beer, not of one alone.

23 Diagrams Without Attributes on Relations Create an entity set representing values of the attribute. Make that entity set participate in the relationship. BarsBeers Sells price Prices Note convention: arrow from multiway relationship = “all other entity sets determine a unique one of these.”

24 Roles Sometimes an entity set appears more than once in a relationship. Label the edges between the relationship and the entity set with names called roles. Drinkers Married husbandwife Relationship Set HusbandWife BobAnn JoeSue…

25 DB Design Example A university registrar’s office maintains data about the following entities: prerequisites a)courses, including number, title, credits, syllabus, and prerequisites; course number instructor b)course offerings, including course number, year, semester, section number, instructor(s), timings, and classroom; c)students, including student-id, name, and program; d)instructors, including identification number, name, department, and title. – Further, the enrollment of students in courses and grades awarded to students in each course they are enrolled for must be appropriately modeled.

26 Entities course course- offerings student instructor

27 Course prerequisites “courses including number, title, credits, syllabus, and prerequisites” Attribute? Relationship? prerequisite maincourse course_no title requires course syllabus credits

28 Course Offering course number instructor “course offerings, including course number, year, semester, section number, instructor(s), timings, and classroom” time room course section_no semester year course- offerings is offered course_no

29 Student, Instructor “students, including student-id, name, and program” “instructors, including identification number, name, department, and title” student namesid program instructor title dept name iid

30 Enrollment Relationship “Further, the enrollment of students in courses and grades awarded to students in each course they are enrolled for must be appropriately modeled.” student course- offerings enrolls grade

31 Teaching Relationship Instructor teaches course….. course- offerings instructor teaches

32 title dept name iid prerequisite maincourse course_n o requires course syllabus credits time room section_no semester year course- offerings is offered enrolls grade namesid program student instructor teaches title Complete ER Diagram for University


Download ppt "CSET 3300 Databases & ER Data Models. Databases A database is a collection of data (information). A DataBase Management System (DBMS) is a software system."

Similar presentations


Ads by Google