Department of computer Science
Database group assignment
Name                                    ID
Case Study : Art General Hospital
   1. Identify Entities: Entities are the objects or concepts we want to track
      information about. In your case, the entities would be Department, Doctor,
      Patient, Treatment, and Payment.
   2. Identify Attributes: Attributes are the pieces of information we want to track
      for each entity. For example, for the Doctor entity, the attributes would be
      Doctor ID , Name, Qualification, Salary, Date Of Joining, YearsOfExperience,
      DepartmentID, and Doctor Type.
   3. Identify Relationships: Relationships are the associations between entities.
      For example, a Doctor works in a Department, a Doctor treats a Patient, a Patient
      makes a Payment, etc.
   4. Identify Cardinality: Cardinality defines the numerical attributes of the
      relationship between two entities. For example, one Doctor can treat many
      Patients, but each Patient is treated by one Doctor at a time.
   5. Draw the ER Diagram: Start by drawing rectangles for entities, ovals for
      attributes, diamonds for relationships, and lines to connect them. Use crow’s
      foot notation at the end of the lines to indicate cardinality.
Entity      Attributes          Relationshi   Relationsh   Cardinalit   Primary      Foreign
                                ps            ip Type      y            Key          Key
Departme    DepartmentID,       Department    Strong       One to       Department   -
nt          DepartmentNam       has Doctors                Many         ID
            e,
            DepartmentLocat
            ion
Doctor      Doctor ID, Name,    Doctor        Strong       One to       Doctor ID    Department
            Qualification,      belongs to                 Many (for                 ID
            Salary,             a                          Patients
            DateOf Joining,     Department                 and
            YearsOfExperienc    , Doctor                   Treatment
            e, DepartmentID,    treats                     s), Many
            Doctor Type         Patients,                  to One
                                Doctor                     (for
                                performs                   Departme
                                Treatments                 nt)
Patient     Patient Number,     Patient is    Strong       One to       Patient      -
            Name, Age, Sex,     treated by                 Many (for    Number
            Address,            Doctor,                    Treatment
            Entry Date          Patient                    s and
                                undergoes                  Payments),
                                Treatment,                 Many to
                                Patient                    One (for
                                makes                      Doctor)
                                Payment
Treatment   Treatment ID,       Treatment     Strong       One to       Treatment    Patient
            Patient Number,     is given by                One (for     ID           Number,
            Doctor ID,          Doctor,                    Payment),                 Doctor ID,
            DepartmentID,       Treatment                  Many to                   Department
            Ailment,            is received                One (for                  ID
            Admission Date,     by Patient,                Doctor
            Discharge Date      Treatment                  and
                                incurs                     Patient)
                                Payment
Payment     Payment ID,         Payment is    Strong       One to       Payment ID   Treatment
            Treatment ID,       made for                   One                       ID
            Test Charges,       Treatment
            OperationCharge
            s, Blood Charges,
            Doctor Charges,
            Total Charges
MAP ER-DIAGRAM to Relational model
Steps:
   1. Strong Entity Types: Each strong entity becomes a table. The primary key of the entity becomes
      the primary key of the table.
   2. Weak Entity Types: Each weak entity also becomes a table. This table includes a foreign key
      referencing the primary key of the owning entity.
   3. Binary 1:1 Relationship Types: For each binary 1:1 relationship, choose one of the entities
      (preferably the one with total participation) and include a foreign key in its table that references
      the primary key of the other entity’s table.
   4. Binary 1:N Relationship Types: For each binary 1:N relationship, include a foreign key in the
      table of the entity on the “N” side. This foreign key references the primary key of the entity on
      the “1” side.
   5. Binary M:N Relationship Types: For each binary M:N relationship, create a new table. This table
      includes foreign keys that reference the primary keys of the tables of both participating entities.
      The combination of these foreign keys forms the primary key of the new table.
   6. Multivalued Attributes: For each multivalued attribute, create a new table. This table includes a
      foreign key referencing the primary key of the table of the entity owning the attribute. The
      combination of this foreign key and the multivalued attribute forms the primary key of the new
      table.
Implementing :
Sure, let’s map the ER model to a relational model using the steps you provided:
   1. Mapping of Strong Entity Types:
        o Department: Create a table Department with attributes DepartmentID ,
             DepartmentName, and DepartmentLocation.
        o Doctor: Create a table Doctor with attributes Doctor ID, Name, Qualification,
             Salary, Date Of Joining, YearsOfExperience, DepartmentID and Doctor Type.
        o Patient: Create a table Patient with attributes Patient Number, Name, Age, Sex,
             Address, and Entry Date.
   2. Mapping of Weak Entity Types: There are no weak entities in this model.
   3. Mapping of Binary 1:1 Relationship Types: There are two 1:1 relationships in this
      model.
   4. Mapping of Binary 1:N Relationship Types:
        o Doctor-Department: The DepartmentID in the Doctor table is a foreign key
             referencing the Department table.
        o Treatment-Doctor: The Doctor ID in the Treatment table is a foreign key
             referencing the Doctor table.
        o Treatment-Patient: The Patient Number in the Treatment table is a foreign key
             referencing the Patient table.
   5. Mapping of Binary M:N Relationship Types: There are no M:N relationships in this
      model.
    6. Mapping of Multivalued Attributes: There are no multivalued attributes in this model.
1,Department
DepartmentID                         DepartmentName                        DepartmentLocation
2,Doctor
 Fname       Mname       Lname        Doc id     Salary      Date of        Dept ID   Doc type   Experience
                                                             joining
3,Patient
Fname        Mname       Lname        sex         age         address        E-date     pnumber     Doc id
4,Treatment
Treatment       Pnumber          Doc id         Department      Ailment           Admission      Discharge
ID                                              ID                                date           Date
5.Payment
Payment ID      Treatment        Test Charges   Operation       Blood             Doctor         Total
                ID                              Charges         Charges           charges        Charges
Code Implementation
CREATE DATABASE Art hospital
CREATE TABLE Department (ID varchar(8) primary key, name text not null, location varchar(10))
CREATE TABLE Doctor(Fname text not null, Mname text , Lname not null, ID varchar(8) primary key ,
qualification text not null, salary float check(salary >= 5000), Date of joining date , deptID varchar(8)
foreign key(deptID) references Department(ID), type text not null)
CREATE TABLE Patient(Fname text not null, Mname text , Lname text notnull, sex char check(sex = ‘M’
or sex = ‘F’), age int check(age > 0), address text , Entrydate date notnull, Pnumber varchar(8) primary
key, DocID varchar(8) foreign key(DocID) references Doctor(ID) )
CREATE TABLE Treatment (Ailment text , Admissiondate date not null, Dischargedate date not null,
TreatmentID varchar(8) primary key, Pnumber varchar(8) foreign key(Pnumber) references
Patient(Pnumber), DocID varchar(8) foreign key(DocID) references Doctor(ID), deptID varchar(8) foreign
key(deptID) references Department(ID))
CREATE TABLE Payment(ID varchar(8) primary key, TreatmentID foreign key(TreatmentID) references
Treatment(ID), Testcharges float , operationcharges float, bloodcharges float, doctorcharges float,
totalcharges float )