DB Ch07
DB Ch07
DB Ch07
IS222
Ms.Abeer Alkulaib
[email protected]
Chapter 7
Slide 1-14
A Sample Database Application
COMPANY
– Employees, departments, and projects
– Company is organized into departments
– Department controls a number of projects
– Employee: store each employee’s name, Social
Security number, address, salary, sex (gender),
and birth date
– Keep track of the dependents of each employee
Entities and Attributes
Entity
– Thing in real world with independent existence
– (for example, a particular person, car, house, or
employee)
– or it may be an object with a conceptual
existence (for instance, a company, a job, or a
university course
Entity and Attributes
Attributes
– Particular properties that describe entity
• Examples: an EMPLOYEE entity may have the attributes
Name, SSN, Address, Sex, BirthDate
Types of Attributes
• Simple attribute (sometimes called atomic):
– Each entity has a single value for the attribute. For example, the
SSN or Sex of an employee.
• Composite attribute (also called compound):
– The attribute may be composed of several components. For
example:
• Address(Apt#, House#, Street, City, State, ZipCode, Country), or
• Name(FirstName, MiddleName, LastName).
• Composition may form a hierarchy where some components are
themselves composite).
• Multi-valued attribute (also called repeating group or
collection):
– An single entity may have multiple values for that attribute. For
example, Color of a CAR or PreviousDegrees of a STUDENT.
• Denoted as {Color} or {PreviousDegrees}.
Entity Type
• Entities with the same basic attributes are
grouped (or typed) into an entity type.
– Examples: EMPLOYEE or PROJECT.
– A name /label assigned to objects/items that exists
in real world and that have similar properties
Example:
– Entity type: Student
– Entity instance: Fatima Ali
– Entity Set: All students
Entity Types, Entity and Entity Sets
Entity
Naming convention for entity type
Singular name recommended
Relationship
– When an attribute of one entity type refers to
another entity type
– Represent references as relationships not attributes
Relationship Types, Sets, and
Instances
Relationship type R among n entity types E1,
E2, ..., En
– Defines a set of associations among entities from
these entity types
Relationship instances ri
– Each ri associates n individual entities (e1, e2, ...,
e n)
– Each entity ej in ri is a member of entity set Ej
Relationship Degree
Slide 1-59
Virtual Library system: Home Work
In a “Virtual Library” system a database is to be created to enable
users to browse books, search stored books, and to read books
online.
A user can browse books using categories; each book is classified
into exactly one category. Moreover, a user can browse books using
authors; any book has at least one author. A book is composed of
any number of pages; in which, each one holds some text.
Search function should allow a user to filter the list of books using
the book title, year of publish, author, and/or category. Moreover, a
user can search the library looking for some text, the system should
return in this case all books with each book page number(s) that
contain the given text.
Banner System: Home Work
This system uses a database to maintain the registration of students in courses
within a certain collage.
The system should allow the following set of operations:-
– Add/Delete/Update student’s profiles.
– Add/Delete/Update Courses.
– Register a given student into a certain section with the regulation of the
collage, student load should not exceed a certain limit of credits, the room
for that section still can accommodate more students, no time conflict will
result from this registration, and that the student already passed the
needed prerequisite for this course.
– Drop a certain section.
– Add/Update/Delete instructors, and assign them to sections.
The system should allow for the following list of reports:-
– List all student/Instructors/sections/ or courses.
– Print the details for a certain student/instructor/ section/ or course.
– Print the schedule for a certain student or instructor.
– Print the list of students in a certain section.
– Calculate and print the GPA for a certain student.
Assignments
Homework Exercises
– 7.52, 7.53, 7.54, 7.56
Reading Material
– 7.1-7.8
Summary