Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Relational Model for Database Management Systems CIS 205, Fall 2004 Last edited September 17, 2004 By C. Herbert ©2004, all rights reserved.

Similar presentations


Presentation on theme: "The Relational Model for Database Management Systems CIS 205, Fall 2004 Last edited September 17, 2004 By C. Herbert ©2004, all rights reserved."— Presentation transcript:

1 The Relational Model for Database Management Systems CIS 205, Fall 2004 Last edited September 17, 2004 By C. Herbert ©2004, all rights reserved

2 CIS 205 Relational Model p.2 Most modern database management systems use the Relational Model, in which data is organized as a set of tables. NameAddressPhone Number Joe Smith111 Oak Ave555-1111 Mary Jones222 Main St555-1212 George Bush1600 Penn. Ave555-1000 John Kerry12 Lexington Rd555-1313 The Relational Model for Database Management Systems

3 CIS 205 Relational Model p.3 The Relational Model for Database Management Systems Tables are organized into rows and columns. NameAddressPhone Number Joe Smith111 Oak Ave555-1111 Mary Jones222 Main St555-1212 George Bush1600 Penn. Ave555-1000 John Kerry12 Lexington Rd555-1313

4 CIS 205 Relational Model p.4 The Relational Model for Database Management Systems Tables are organized into rows and columns. Each row represents one “record” in the database. NameAddressPhone Number Joe Smith111 Oak Ave555-1111 Mary Jones222 Main St555-1212 George Bush1600 Penn. Ave555-1000 John Kerry12 Lexington Rd555-1313

5 CIS 205 Relational Model p.5 The Relational Model for Database Management Systems Tables are organized into rows and columns. Each column represents a different “field”. NameAddressPhone Number Joe Smith111 Oak Ave555-1111 Mary Jones222 Main St555-1212 George Bush1600 Penn. Ave555-1000 John Kerry12 Lexington Rd555-1313

6 CIS 205 Relational Model p.6 The Relational Model for Database Management Systems There is a table for each type of item in a data base. For example, SEPTA might have a table for drivers, a table to keep track of buses, and another table for bus routes. NameAddressPhone Number Joe Smith111 Oak Ave555-1111 Mary Jones222 Main St555-1212 George Bush1600 Penn. Ave555-1000 John Kerry12 Lexington Rd555-1313 Route #StartEnd 233600 S 11 th St9000 Germantown 9Andorra PlazaBroad and South 25400 N. 17th3300 S. 16th Bus #MakeModel 2078GMStarliner 2079MercedesDymaxion 2080GMSunliner

7 CIS 205 Relational Model p.7 The Relational Model for Database Management Systems In relational database management, another name for a table is a relation. We also talk about entities, attributes and relationships. An entity is what each table is all about. There is a table for each entity in a database.

8 CIS 205 Relational Model p.8 The Relational Model for Database Management Systems There is a table for each entity in a database. In our SEPTA example we have tables for drivers, buses, and bus routes. NameAddressPhone Number Joe Smith111 Oak Ave555-1111 Mary Jones222 Main St555-1212 George Bush1600 Penn. Ave555-1000 John Kerry12 Lexington Rd555-1313 Route #StartEnd 233600 S 11 th St9000 Germantown 9Andorra PlazaBroad and South 25400 N. 17th3300 S. 16th Bus #MakeModel 2078GMStarliner 2079MercedesDymaxion 2080GMSunliner

9 CIS 205 Relational Model p.9 The Relational Model for Database Management Systems The word entity refers to the general object for each table. Each specific object is called an instance of the entity. There is a row for each instance of the entity.

10 CIS 205 Relational Model p.10 The Relational Model for Database Management Systems NameAddressPhone Number Joe Smith111 Oak Ave555-1111 Mary Jones222 Main St555-1212 George Bush1600 Penn. Ave555-1000 John Kerry12 Lexington Rd555-1313 There is a row for each instance of the entity.

11 CIS 205 Relational Model p.11 The Relational Model for Database Management Systems NameAddressPhone Number Joe Smith111 Oak Ave555-1111 Mary Jones222 Main St555-1212 George Bush1600 Penn. Ave555-1000 John Kerry12 Lexington Rd555-1313 An attribute is something that provides information about, or describes, an entity. There is a column for each attribute of the entity.

12 CIS 205 Relational Model p.12 The Relational Model for Database Management Systems A relationship is formed when two tables share an attribute. (have a common column) Data in one table is “cross referenced” with data in another table through the column they have in common. (the shared attribute) “Cross-referencing” data is one of the keys to effective database management.

13 CIS 205 Relational Model p.13 The Relational Model for Database Management Systems In our SEPTA example, bus routes can be cross referenced with buses to find out what make and model of bus is being used on each route. Route #StartEndBus # 233600 S 11 th St9000 Germantown2078 9Andorra PlazaBroad and South2080 Bus #MakeModel 2078GMStarliner 2079MercedesDymaxion 2080GMSunliner

14 CIS 205 Relational Model p.14 The Relational Model for Database Management Systems In our SEPTA example, bus routes can be cross referenced with buses to find out what make and model of bus is being used on each route. Route #StartEndBus # 233600 S 11 th St9000 Germantown2078 9Andorra PlazaBroad and South2080 Bus #MakeModel 2078GMStarliner 2079MercedesDymaxion 2080GMSunliner Here, we can see that a GM Starliner is scheduled for use on Route 23. Is it too big for the streets on that route?

15 CIS 205 Relational Model p.15 The Relational Model for Database Management Systems In order for this cross referencing to work, we must be able to uniquely identify each instance of an entity. In other words, each row in a table must have a unique value for a particular column. Bus #MakeModel 2078GMStarliner 2079MercedesDymaxion 2080GMSunliner We call such a column the primary key for the table. The primary key uniquely identifies each instance of an entity.

16 CIS 205 Relational Model p.16 The Relational Model for Database Management Systems Here the Bus # is different for each row in the database. The Bus # can be used as the primary key for the bus table. Bus #MakeModel 2078GMStarliner 2079MercedesDymaxion 2080GMSunliner We call such a column the primary key for the table. The primary key uniquely identifies each instance of an entity.

17 CIS 205 Relational Model p.17 The Relational Model for Database Management Systems A column in one table that is the primary key for another table is called a foreign key. Route #StartEndBus # 233600 S 11 th St9000 Germantown2078 9Andorra PlazaBroad and South2080 Bus #MakeModel 2078GMStarliner 2079MercedesDymaxion 2080GMSunliner

18 CIS 205 Relational Model p.18 The Relational Model for Database Management Systems Here, Bus # is a foreign key in the bus route table, because it is a primary key in the bus table. Route #StartEndBus # 233600 S 11 th St9000 Germantown2078 9Andorra PlazaBroad and South2080 Bus #MakeModel 2078GMStarliner 2079MercedesDymaxion 2080GMSunliner Foreign keyPrimary key

19 CIS 205 Relational Model p.19 Sometimes a single column is not enough to form a key field. NameAddressPhone Number Joe Smith111 Oak Ave555-1111 Mary Jones222 Main St555-1212 George Bush1600 Penn. Ave555-1000 John Kerry12 Lexington Rd555-1313 The Relational Model for Database Management Systems

20 CIS 205 Relational Model p.20 In this table, the Name column by itself could be a primary key, assuming no two names are the same. NameAddressPhone Number Joe Smith111 Oak Ave555-1111 Mary Jones222 Main St555-1212 George Bush1600 Penn. Ave555-1000 John Kerry12 Lexington Rd555-1313 The Relational Model for Database Management Systems

21 CIS 205 Relational Model p.21 However, if the first name and last name are in separate columns, then both must be used to form a primary key. First Name Last Name AddressPhone Number JoeSmith111 Oak Ave555-1111 MaryJones222 Main St555-1212 GeorgeBush1600 Penn. Ave555-1000 JohnKerry12 Lexington Rd555-1313 The Relational Model for Database Management Systems

22 CIS 205 Relational Model p.22 A key that is formed from more than one column is called a composite key. The Relational Model for Database Management Systems First Name Last Name AddressPhone Number JoeSmith111 Oak Ave555-1111 MaryJones222 Main St555-1212 GeorgeBush1600 Penn. Ave555-1000 JohnKerry12 Lexington Rd555-1313


Download ppt "The Relational Model for Database Management Systems CIS 205, Fall 2004 Last edited September 17, 2004 By C. Herbert ©2004, all rights reserved."

Similar presentations


Ads by Google