Database Management LNotes by John Martin

download Database Management LNotes by John Martin

of 76

Transcript of Database Management LNotes by John Martin

  • 8/3/2019 Database Management LNotes by John Martin

    1/76

    R. John Martin

    Lecturer in IT, Higher College of Technology

    Sultanate of Oman

  • 8/3/2019 Database Management LNotes by John Martin

    2/76

  • 8/3/2019 Database Management LNotes by John Martin

    3/76

    Data & Information

    Data Information

    1 Data is collection of factsand figures

    Processed form of data is information

    2 No conclusions can bedrawn on data.

    Used to draw conclusions.

    3 Data is raw material forprocessing. It is processed

    further.

    Info. Can also be further utilized to

    produce high quality information.

    4 It is not time bound It is time bounded.

    E.g. An amount of money withdrawn from an account on

    particular day is a data.

    This data is further used for preparing balance sheet,

    profit-l loss statement etc. when such processing is

    done on data, it is called as information.

    Soinformation is processed form of data

  • 8/3/2019 Database Management LNotes by John Martin

    4/76

    Data vs. Information

    Data - a collection of facts made up of text,numbers and dates:

    Ahmad 35000 7/18/86

    Information - the meaning given to data in the wayit is interpreted:

    Mr. Ahmad is a sales person whose annual salaryis $35,000 and whose hire date is July 18, 2006.

  • 8/3/2019 Database Management LNotes by John Martin

    5/76

    What is a Database

    Database is an organized collection of inter related

    information. It is a collection of persistent data that can be shared

    & interrelated. Persistent Data reside on stable storage such as

    magnetic disk and available for ever. Interrelated Data stored as separate units can be

    connected to provide a whole picture. It contains conventional & non-conventional

    information.

    Conventional information - facts about persons,things, events etc.,

    Non-conventional information - photographs,fingerprints, videos etc.,

  • 8/3/2019 Database Management LNotes by John Martin

    6/76

    Database is an organized collection of interrelated

    information. When we perform some operation on the data and organize

    in some meaningful format, it is called as database system.

    The software which allows user to create (table creation) and

    maintain (insert, delete, change) database is calledDatabase Management System (DBMS).

    DBMS MS-Access, ORACLE, Ingres, INFORMIX,

    SyBase, PostgreSQL, MS-SQL Server.

    MS

    BASE

    DATA

    Database, Database System & DBMS

  • 8/3/2019 Database Management LNotes by John Martin

    7/76

    1. Data - (Data / Information)

    2. Hardware - ( Computer, Secondary StorageDevices, Processor, Input/Output Devices etc.,)

    3. Software - Set of programs. (DBMS)

    4. Users - (Application Programmers, End-Users, DBA)

    Components (Resources) of a Database System

  • 8/3/2019 Database Management LNotes by John Martin

    8/76

  • 8/3/2019 Database Management LNotes by John Martin

    9/76

  • 8/3/2019 Database Management LNotes by John Martin

    10/76

    PROGRAMMER (Application Program)

    FILE-BASED SYSTEM DATA BASE SYSTEM

    There are two approaches for storing and maintaining

    the data on persistent storage.

    Database Approaches

  • 8/3/2019 Database Management LNotes by John Martin

    11/76

    FILE-BASED SYSTEM

    Each programmer has their own set of data withouthaving any link to the other.

    They are independent systems (stand alone)

    Application programs cannot exchange information.

  • 8/3/2019 Database Management LNotes by John Martin

    12/76

    TEACHERSSTUDENTSAFFAIRSSTUDENTSREGISTRATION

    StudentsRegistration

    Details

    Student Information Attendance Report

    Own set of data

    No link / sharing

    Works independently

    Changing is be done separately

    EXAMPLE

  • 8/3/2019 Database Management LNotes by John Martin

    13/76

    Elements of a database:

    Database consists of three major elements.

    1. Entities 2. Relationships 3. Procedures

    Entity an entity can denote a person, place, thing orevent.Example: Employees, Departments, Students, Course, Registration

    etc.,

    Relationship it represents a link or a relationship betweenthe entities.Example : Employees working in a department, Students registered

    for a course.

    Procedures - An ordered set of tasks/rule for performingsome action on the database.Example : Teachers assignment, Course Scheduling, Registering

    students.

  • 8/3/2019 Database Management LNotes by John Martin

    14/76

    Business department wants to create a database which will

    store information about all the students those who are

    studying the department, all the teachers working in the

    department, list of courses offered, the information about

    the courses allotted for a teacher, students registered for a

    particular course, and teacher for a particular course, using

    the above information, Students registration, add courseand drop course should be done successfully.

    Find the entities, relationships and procedures in thefollowing problem.

  • 8/3/2019 Database Management LNotes by John Martin

    15/76

    Entities:

    StudentsTeachersCoursesDepartment

    Relationships:

    Course - TeacherStudentCourseTeacher - Department

    Add course

    EXAMPLE 1 : COLLEGE DATABASE

    Drop Course

    Registeringstudents

  • 8/3/2019 Database Management LNotes by John Martin

    16/76

    In a Hypermarket a database is maintained to store the

    information about all the products that are available in that

    shop, all the employees working, the shopping carts available

    and the details of the customers. Whenever any customer

    comes to the shop, the customer should collect all the

    products he need in a shopping cart, if he needs any help, he

    can contact any employee of the shop and finally a bill

    should be generated by an employee and stock should be

    updated for all the products.

    Find the entities, relationships and procedures in thefollowing problem

  • 8/3/2019 Database Management LNotes by John Martin

    17/76

    Entities:

    CustomersProductsEmployeesShopping-cart

    Relationships:

    Products - CustomerCustomer Shopping CartShopping Cart - Products

    Billing

    EXAMPLE 2 : HYPERMARKET DATABASE

    Stock Updating

  • 8/3/2019 Database Management LNotes by John Martin

    18/76

    It is a computerized record keeping system.

    Its purpose is to maintain information and make thatinformation available to all users anytime they are

    required.

    The information kept in a database can be anything thatis important to the company or organization.

    DATABASE SYSTEM

  • 8/3/2019 Database Management LNotes by John Martin

    19/76

    In a database system, data kept in the computer will beintegrated and shared by users.

    Integrated means that the database can be thought as a

    collection of information where repeated data are removedfrom the system.

    Shared means that individual pieces of data in a database

    can be shared among different users.

    DATABASE SYSTEM (Cont..)

  • 8/3/2019 Database Management LNotes by John Martin

    20/76

    DATABASE SYSTEM

    Students PersonalInformation

    Students Attendance

    Students Result

    DATABASE

    STUDENTSAFFAIRS

    HEAD OF THE DEPT

    LECTURES

  • 8/3/2019 Database Management LNotes by John Martin

    21/76

    College maintains a file named personal information tostore the details of the students such as Student-Id, Student-name, Specialization, Address, School-details, Emergency-contact number.

    Apart from personal information, the college is alsomaintaining a separate file named student resultsto storethe results of the results of the students which consists ofStudent-Id, Student-name, Specialization, Result.

    A separate file named students attendance is maintained tostore the attendance details of the students which consiststhe student-Id, Student-name, date-of-absent and period.

    Apply File-based / Database Approach

  • 8/3/2019 Database Management LNotes by John Martin

    22/76

    In a Hypermarket a file named Product-file is used to storethe information about all the products like Product-number,Product-name, Unit, Price, Stock.

    A separate file named Employee-file is used to maintain the

    details of the employees, like Employee-number, Employee-name, Date-of-birth, Emp-Address, Salary.

    Another file named Customer-file is used to store thecustomer details such as Customer-no, Customer-Name,

    Cust-Address. A file named Sales-file is used to store the sales details such

    as Product-no, Product-Name, Customer-no, customer-name, units, price, total-amount.

    Apply file-based / Database approach

  • 8/3/2019 Database Management LNotes by John Martin

    23/76

    Objectives and Need of Database System

    To specify information requirements of user.

    To provide ad-hoc reports ( which are not required regularly)

    To provide a natural and easy way of structuring of data.

    To support the processing requirements & any performance

    objective.

    To design data structure which will remain robust over time.(i.e. new information can be easily added to database)

  • 8/3/2019 Database Management LNotes by John Martin

    24/76

    Lab Exercise : Ms-Access

    Introduction, Working with tables, Table formatting

  • 8/3/2019 Database Management LNotes by John Martin

    25/76

    1. Redundancy of data can be reduced.

    2. Inconsistency can be avoided

    3. Data sharing

    4. Security restrictions can be applied

    5. Integrity can be maintained

    6. Data independence

    Advantages of database approach

  • 8/3/2019 Database Management LNotes by John Martin

    26/76

    1. Redundancy of data can be reduced

    Here College_Id, Student_name, Specialization is repeated in

    PERSONAL INFORMATION, STUDENT RESULT AND STUDENT ATTENDANCE.

    That is redundancy (repetition of information)

  • 8/3/2019 Database Management LNotes by John Martin

    27/76

    2. INCONSISTENCY CAN BE AVOIDED

    College-ID Student-Name Specialization Address

    1001 SALIM IT MUSANNA

    College-ID Student-Name Specialization Result

    1001 SALIM ENG PASS

    College-ID Student-Name SpecializationAttendance

    %

    1001 SALIM IT 79

    PERSONAL INFORMATION

    STUDENTS RESULT

    STUDENTS ATTENDENCE

    Inconsistency means incorrect information or confusing information.

  • 8/3/2019 Database Management LNotes by John Martin

    28/76

    3. DATA SHARING

    Students PersonalInformation

    Students AttendanceStudents Result

    STUDENTSAFFAIRS

    HEAD OF THE DEPT

    LECTURES

    Data is easily available to all users in database system as it is shared.

  • 8/3/2019 Database Management LNotes by John Martin

    29/76

    4. SECURITY RESTRICTIONS

    DBA - Database Administrators, USERS

    Permissions to access, modify or delete data.

    DBA creates users and give rights (permissions)to them to access, modify or deletion ofinformation from table.

    Data is more secure in database system than filebased system.

  • 8/3/2019 Database Management LNotes by John Martin

    30/76

    5. DATA INTEGRITY

    Students PersonalInformation

    Students AttendanceStudents Result

    STUDENTSAFFAIRS

    HEAD OF THE DEPT

    LECTURES

    Data that we are storing in database must satisfy some

    condition is called data integrity.

    e.g: age > 0. such conditions are easily given in database.

    The user can rely on the data given by the system

    because of Security restrictions and elimination of Data

    redundancy.

  • 8/3/2019 Database Management LNotes by John Martin

    31/76

    6. DATA INDEPENDENCE

    USERS

    APPLICATION PROGRAMS

    DATA

    Data Structures (Table Design) can be changed withoutchanging the application programs.

  • 8/3/2019 Database Management LNotes by John Martin

    32/76

    Database + Application Programes =DBMS

    DB

    Collection of data.AP - Collection of Programs (Software) to maintain database.

    DATABASE MANAGEMENT SYSTEM

  • 8/3/2019 Database Management LNotes by John Martin

    33/76

    Database Operations (Maintenance):

    Insert new information

    Retrieve existing information

    Delete existing information

    Modify existing information

    Store the information

    Distribute the information

    Format the information

  • 8/3/2019 Database Management LNotes by John Martin

    34/76

    Sharing of data and common interface is provided by DBMS.

    Less redundancy.

    Efficient and easy data access.

    Data integrity is maintained. Provides security for data.

    Data administration is easy.

    Standards can be enforced.

    User need not require to know about location of data on

    the disk.

    Reduced application development time.

    Benefits of DBMS

  • 8/3/2019 Database Management LNotes by John Martin

    35/76

    Use of expensive hardware and software i.e. it is

    costly.

    Difficult and costly to develop, because it needstrained professionals, persons.

    Centralized data. Complete shut down when

    subject to failure.

    Disadvantages (Drawbacks) of DBMS:

  • 8/3/2019 Database Management LNotes by John Martin

    36/76

    Database Applications:

    Banking: all money transactions

    Airlines: reservations, schedules

    Universities: registration of students, results of students.

    Sales: customers information, products info., purchases info.

    Online retailers: order tracking, customized recommendations

    Manufacturing: production, inventory, orders, supply chain

    Human resources: employee records, salaries, tax deductions

    Databases touch all aspects of our lives

  • 8/3/2019 Database Management LNotes by John Martin

    37/76

    Types of Data Models

    Data Model is a design of database. Data model defines how data is organized, stored and

    retrieved in database.

    It shows data and their relationship.

    There are 3 models.

    Hierarchical Model

    Network Model Relational Model

  • 8/3/2019 Database Management LNotes by John Martin

    38/76

    1. Hierarchical Model

    It is a database management system that link recordstogether like ordered tree.

    The Relationship is One-To-Many Relationship is unidirectional

    Data is shown by rectangles

    Relationship is shown by lines

  • 8/3/2019 Database Management LNotes by John Martin

    39/76

    ExampleA

    B C D

    E F G H

    Hierarchical Model ( Like Tree structure)

    Disadvantages:

    1. Slow in processing.

    2. Difficulty in getting data.

    3. Difficult programs are required to write to get data.

    Parent

    Childs

  • 8/3/2019 Database Management LNotes by John Martin

    40/76

    2. Network Model

    Used in early days

    Data is shown by rectangles

    Relationship is shown by lines

    It is shown like arbitrarygraph.

    The Relationship is a Many-To-Many

    Relationship is unidirectional

  • 8/3/2019 Database Management LNotes by John Martin

    41/76

    Example

    A

    B

    C

    D

    E

    F

    G

    Network model ( Like graph)

    Disadvantages: Slow in processing than relational model.

    Difficulty in getting data.

    Difficult programs are required to write to get data.

  • 8/3/2019 Database Management LNotes by John Martin

    42/76

    3. Relational Model

    Collection of tables are used to show data and theirrelationship.

    Data is stored in 2 dimensional tables.

    Table is collection of rows and columns.

    In relational database

    Rows are called tuples.

    Columns are called attributes.

  • 8/3/2019 Database Management LNotes by John Martin

    43/76

    Example

    Stud_id Name Course

    1 Ali IT

    2 Mohammad ENG

    Stud_id Marks Mobile_No

    1 78 95746111

    2 67 95111111

    1 80 95746333

    STUDENT STUDENT-MARKS

    Relational model using 2 tables

    Row/

    Tuple

    Column/

    Attributes

    Data and Relationship shown by two tables.

    Table name

  • 8/3/2019 Database Management LNotes by John Martin

    44/76

    Relational Database is a set ofrelations.

    Relation is a table with rows, columns and is made up of two partsnamely schema and instance.

    Schema specifies name of relation plus name and type of eachcolumn. For example, Student Table

    Sid Number

    Name Text

    Specialization Text

    GPA Number

    Instance is a table with rows, columns and row data.For example,

    Sid Name Specialization

    GPA

    111 Ali IT 3

    222 Muna IT 2.5

    333 Huda IT 3.2

  • 8/3/2019 Database Management LNotes by John Martin

    45/76

    INTEGRITY CONSTRAINTS

    Integrity constraints are conditions that must be true for any instance

    of a database. A legal instance of a relation is one that satisfies allspecified Integrity constraints. Integrity constraints are specified using

    keys.

    KEYS

    A set of fields is a key. Keys provide one form of integrityconstraints. Keys are a way to associate rows in different

    relations.

    Super key:column(s) with unique values

    Candidate key: a key, although not selected as a primary key, canalso be used to uniquely identify a row or entity.

    Null value: special value meaning value unknown or inapplicable

  • 8/3/2019 Database Management LNotes by John Martin

    46/76

    Sid and {Sid, GPA}are super keys. Chose any one as primary

    key, for instance Sid. The other key becomes candidate key.

    A primary key is a field (or combination of fields, called a

    composite key), which uniquely identifies a row or entity.

    For example consider the following student table,

    Sid Name Specialization GPA

    Primary key:

    F i K

  • 8/3/2019 Database Management LNotes by John Martin

    47/76

    a field in one relation, which refers to a field in another. Foreign

    keys are used in relational schema to represent a relationship

    between two relations/entities. A foreign key in one relation refersto the primary key field of the related relation/entity.

    an attribute/field or combination of attribute in a table whose value

    match primary key in another table.

    Sid Cid Grade

    111 ITSE1100 A

    222 ITDB1102 B111 ENGL1100 C+

    111 ITSE1101 B+

    Enrollment

    Sid Name Login GPA

    111 Ali T015 3.2

    222 Muna T026 3.3

    333 Huda T018 3.0

    (Sid, Cid) - Primary Key Sid Primary Key

    Sid - Foreign key

    Student

    Foreign Key:

  • 8/3/2019 Database Management LNotes by John Martin

    48/76

    Each table has column(s) with unique values. That is no two

    rows of a table can contain the same value for the primarykey. In addition, no row can contain a null value for any

    columns of a primary key.

    For example, the primary key Sid is unique in the

    following table.

    Sid Name Specialization

    GPA

    111 Ali IT 3.2

    222 Huda IT 3

    333 Muna ENGG 3.3

    444 Muna IT 3.0

    Entity integrity: primary keys

    R f i l i i f i k

  • 8/3/2019 Database Management LNotes by John Martin

    49/76

    Ensures valid references among tables

    Foreign keys can be null in some cases Foreign keys must match primary key of referenced table.

    For example, Sid is foreign key in Enrollment its values matchwith the Student tables Sid.

    Sid Cid Grade

    111 ITSE1100 A

    222 ITDB1102 B

    111 ENGL1100 C+

    111 ITSE1101 B+

    Sid Name Login GPA

    111 Ali T015 3.2

    222 Muna T026 3.3333 Huda T018 3.0

    (Sid, Cid) - Primary Key Sid Primary KeySid - Foreign key

    Enrollment Student

    Referential integrity: foreign keys

  • 8/3/2019 Database Management LNotes by John Martin

    50/76

    Data Model

    A data model is an overall design of a database.

    It shows a data and relationship between them.

    It is a conceptual tool to represent the database.

    The data model focuses on what data is required and

    how it should be organized.

  • 8/3/2019 Database Management LNotes by John Martin

    51/76

    The design of the database is a step-by-step

    procedure. It can be divided into three separate

    stages

    Conceptual data modeling

    Logical schema construction

    Physical database design

    For small projects the above stages can be handledby one person only, whereas in big projects each

    stage can be handled by separate persons.

  • 8/3/2019 Database Management LNotes by John Martin

    52/76

    Conceptual data

    Modeling

    Logical SchemaConstruction

    Physical Databasedesign

    Big Projects

  • 8/3/2019 Database Management LNotes by John Martin

    53/76

    Physical Database

    Logical Schema Construction

    Conceptual data Modeling

    Small Projects

    Ph f D b D i

  • 8/3/2019 Database Management LNotes by John Martin

    54/76

    Conceptual Data Modeling

    Logical Schema Construction

    Physical Database Design

    Database Requirements

    E R Diagram (on papers)

    Relational Database Tables (on papers)

    Schema and Instances

    (Inside computer)

    Phases of Database Design

    A) C l D M d li

  • 8/3/2019 Database Management LNotes by John Martin

    55/76

    A) Conceptual Data Modeling

    It includes objects ( i.e. documents ) of an interest to

    an organization.E.g. Al Musanaa College of Technology.

    Personal informationName - Ali Al Balushi

    Section - 1

    DOB - 04-Dec-1988

    Address - Muladha

    Hostel - Yes

    GPA - 2.67

    LevelLevelcode - 101

    Leveldesc -Certificate

  • 8/3/2019 Database Management LNotes by John Martin

    56/76

    B) Logical Schema Construction Based on data provided by conceptual model, the database

    structure is designed on paper. This is known as logical schema

    construction.Student Table

    Field Name Data Type Field Size Format Decimal

    StudId Number Long Integer

    Name Text 30

    Section Number

    DOB Date dd-mmm-yyyy

    Address Text 40

    InHostel Logical

    LevelCode Number Integer

    CourseCode Number Integer

    Field Name DataType Field Size Format Decimal

    LevelCode Number

    LevelDesc Text

    Level Table

  • 8/3/2019 Database Management LNotes by John Martin

    57/76

    During the logical schema construction, the following can

    be determined.

    What element of data you will store?

    How large each element can be?

    What kind of information each element can contain?

    What elements may be left blank?

    Which elements are considered to be of a fixed range?

    Whether and how various tables are linked?

  • 8/3/2019 Database Management LNotes by John Martin

    58/76

    C) Physical Database Design

    It refers to the actual structures created inside the computer.

    Based on data structure designed on paper in the logical

    schema construction stage, actual structure are created

    inside computer.

    Computer

    Student Table

    Level Table

    Attendance Table

    Course Table

    Physical Database Design:

  • 8/3/2019 Database Management LNotes by John Martin

    59/76

    Physical Database Design:

    Student Table Created In Ms-Access (DBMS)

  • 8/3/2019 Database Management LNotes by John Martin

    60/76

    Conceptual Modeling

    This is the first step of database design.

    Relevant elements are identified and analyzed. Such asdocuments like daily attendance report, students grading

    sheet and objects like teacher, student, library.

    To analyze the information, data modeling techniques are

    used. Data Modeling techniques are-

    A) Entity Relationship Diagram. (ERD)

    B) Normalization.

    C) Functional Dependency Diagram. (FDD)

    Output of the analysis is called Conceptual Data.

    A) E tit R l ti hi Di (ERD)

  • 8/3/2019 Database Management LNotes by John Martin

    61/76

    A) Entity Relationship Diagram (ERD)1976 proposed by Peter Chen

    Entity Relationship Diagram is a conceptual data modeling

    technique which shows all entities and the relationship

    exists between them.

    Entity Relationship Diagram is a graphical representation of

    a database.

    CustID DepositorCustomerAccount

    CustName DOB

    CustCity

    ActNo

    Balance

    Entity Relationship Diagram

  • 8/3/2019 Database Management LNotes by John Martin

    62/76

    In Entity Relationship Diagram

    Rectangle represents - Entity Set

    Diamond represents Relationship Set

    Ellipses represents Attributes

    Symbols Used to show relationship between the entities

    One-to-One (1:1)

    One-to-Many (1:M)

    Many-to-Many (M:M) -

  • 8/3/2019 Database Management LNotes by John Martin

    63/76

    The conceptual model is often stated in terms of:

    Entities an entity is an object about which information is

    collected. This can be person (i.e. student, teacher), place (i.e.

    department), things (grade) or events (attendance).

    Entity set Group of similar entities.

    e.g. all person, all places.

    Attributes Attributes are the properties or characteristics of an

    entity. e.g. StudId, StudName, DOB, Address.

    Entity Occurrence It is an instance of an entity. i.e. set of

    values , usually records or tuple.

  • 8/3/2019 Database Management LNotes by John Martin

    64/76

    Relationship In database relationship must exists between

    entities.

    Relationships are classified by their degree, connectivity,

    cardinality, direction and type

    Attribute Domain Each attribute has permitted set of values

    called attribute domain. E.g.

    Date might be dd-mmm-yyyy thus 10-May-1980 is valid, but

    10/05/1980 not valid for domain of attribute date.

    If we give condition salary >= 1000 and salary

  • 8/3/2019 Database Management LNotes by John Martin

    65/76

    Degree of a Relationship

    The degree of relationship is the number of entity setsassociated (linked) with the relationship.

    Binary relationship- It is an association between two entity sets

  • 8/3/2019 Database Management LNotes by John Martin

    66/76

    y p y

    Ternary Relationship It involves three entity sets.

    N-Ary Relationship More than three entity sets are involved inrelationship

    Degree =2

    Degree =3

    Degree =5

  • 8/3/2019 Database Management LNotes by John Martin

    67/76

    Mapping Cardinality - Mapping cardinality shows how entities of one entity

    set associated with another entity set via arelationship set.

    One To One (1:1)

    One To Many (1:M)

    Many To One (M:1)

    Many To Many (M:M)

  • 8/3/2019 Database Management LNotes by John Martin

    68/76

    One-to-One (1:1)At most one instance of entity set A there is only

    one instance of entity set B. And at most oneinstance of entity set B there is onlyone instanceof entity set A.

    One-one

    A B

    e.g.

    Car CarNumber

    Country - CapitalCity

    Department - HeadOfDepartment

  • 8/3/2019 Database Management LNotes by John Martin

    69/76

    One-to-Many (1:M) For oneinstance of entity setA, there are zero, one

    or many instances of entity set B.

    But for one instance of entity set B there is onlyone instance of entity setA.A B

    One-to-Many

    e.g.

    One Department - Many

    Student

  • 8/3/2019 Database Management LNotes by John Martin

    70/76

    Many-to-One (M:1) For oneinstance of entity set B , there are zero, one

    or many instances of entity setA.

    But for one instance of entity setAthere is onlyone instance of entity set B.A B

    Many-to-One

    e.g.

    Many Student One Course

  • 8/3/2019 Database Management LNotes by John Martin

    71/76

    Many-to-Many (M:M) For oneinstance of entity set A , there are zero, one or

    many instances of entity set B.

    But for one instance of entity set B there is many

    instances of entity set A.A B

    Many-to-Many

    e.g.

    Employee Project

    Suppliers Part

    Author - Book

    O M

  • 8/3/2019 Database Management LNotes by John Martin

    72/76

    One-to-Many

    Consider another entity set; Department and Courses. Looking

    at figure below we can say that ONE department can offer

    MANY courses.

    Business Studies

    Marketing

    Business Ethics

    E-Business

    M M

  • 8/3/2019 Database Management LNotes by John Martin

    73/76

    Many-to-Many

    Consider another entity set Students and Courses. Looking at

    figure below we can say that ONE Student is registered to

    MANY courses and Courses has MANY Students.

    Ali Marketing

    Business Ethics

    E-BusinessHaider

    Ismail

  • 8/3/2019 Database Management LNotes by John Martin

    74/76

    Example ER Diagram.

    CUSTOMER

    ACCOUNT BANK

    HAS

    HANDLES

  • 8/3/2019 Database Management LNotes by John Martin

    75/76

    Relationship with linking words/phrases-

    Relationships are also sometimes expressed in verbs (action

    words).

    e.g. Department Head manages Department.

    On the other hand Department is managed by Department Head.

    A Department Head can manage only ONE department and

    department can have only ONE head ( 1:1 relationship)

    Department Head DepartmentManages a

    Managed by

    MR X IT Department

    One-to-One

  • 8/3/2019 Database Management LNotes by John Martin

    76/76

    References:

    Course Text BookTitle : Database Design, Application Development and Administration

    Author: Michael V.Mannino

    ISBN:0-07121489-5

    Chapters: 1 , 2 and 5

    E-brary BookTitle: Databases A Beginner's Guide

    Author: Oppel, Andy

    ISBM:9780071608473

    Chapters: 1,7