ASSIGNMENT NO 03 DB
ASSIGNMENT NO 03 DB
ASSIGNMENT NO 03
Submitted to:
DR. MADIHA
Submitted by:
MOHSIN IDREES
SP21-BAI-014
Question - 1:
Design an EER-schema for a database of a canteen/cafeteria. The canteen has a certain feature of menus it can
produce. Each menu has an identifying number, a name, and a price. The name is used for advertising the menu;
menus which differ only slightly can have the same name. Each day, the canteen offers several menus. It wants
to store which menu was offered on which day and how often it was sold. Internally, the menus are constructed
from a main course (usually meat) and several side dishes (such as soup, salad, vegetables, dessert). In this
canteen the customer cannot choose the side dishes. The composition of menu is used only for the preparation,
because every component (main dish or side dish) can be prepared independently. Also, if some component is
used in different menus, the information about it does not have to be stored redundantly. For every menu
component, the recipe has to be stored (how to cook this part of the meal).
EERD:
Relational Schema:
Menu (menu_id (PK), name, price)
MenuComponent (component_id (PK), menu_id (FK), component_type (main course or side
dish), recipe)
Ingredient (ingredient_id, name, calories)
MenuComponentIngredient (component_id (FK), ingredient_id (FK), quantity)
MenuSale (menu_id (FK), sale_date, quantity_sold)
3. Ingredient Table: Contains information about each ingredient used in the menu
components. The ingredient_id serves as the primary key, and the name stores the
name of the ingredient. The calories column records the number of calories per 100
grams of the ingredient.
5. MenuSale Table: Stores data about the sales of menus. The menu_id column is a
foreign key referencing the Menu Table, indicating which menu was sold. The
sale_date column records the date of the sale, and the quantity_sold column represents
the number of times the menu was sold on a specific day.
Problem-4: Finance Company
A financial institution offers different investment schemes to its customers such as shares and
debentures. The company also accepts fixed deposits from the general public, institutions, and its
employees. The company keeps a database with valuable information about its customers (such as ID,
name, and address), which could be individual customers, employees and financial institutions.
Institutions have focal person and other details along with ID, name, address etc.
Fixed deposits have varying terms of 1, 2, or 3 years. For fixed deposits there are currently two
payment schemes. Under the first scheme, the investors get the principal plus the interest on maturity.
Under the second scheme, they get the principal on maturity, but interest is paid periodically. The
interest rates for fixed deposits under the first scheme may be paid quarterly, semi-annually, or
annually. Investors have the option to renew their deposits on maturity.
The company also raises debentures periodically. The debentures may be either convertible or
nonconvertible. Convertible debentures can be converted to equity shares on completion of the period.
Debentures are issued for periods of 1, 2 or 3 years.
The company also calls for shares periodically. The company issues two kinds of shares: equity shares
and preferred shares. The dividend is declared at the end of the year. The system keeps track of the
dividend rates, dividend issued to the shareholders, etc.
The company has employees which deal with depositors. Employees can be permanent with job
experience in years and can be contractual with contract duration and specific dates (starting and
ending).
Draw the EER diagram of this database. Identify (if any) the subtypes of entity financial instrument and
member. Identify one (or more) unique attribute (relationship) for each subtype as well as one (or
more) attribute that is shared by all entity subtypes.
EERD:
Relational Schema:
Customer (customer_id (PK), customer_type, name, address)
IndividualCustomer (customer_id (PK)(FK))
Employee (employee_id (PK), employee_type, name, address, experience_years
(applicable for permanent employees))
PermanentEmployee (employee_id (PK)(FK)))
ContractEmployee(employee_id (PK)(FK), contract duration, start_date, end_date)
FinancialInstitution (institution_id (PK), institution_type, name, address,
focal_person)
Deposit (deposit_id (PK), customer_id (FK), deposit_type, term (1, 2, or 3 years),
renewal_option)
FixedDeposit(deposit_id (PK),(FK), payment_scheme (first or second),
interest_payment_frequency (quarterly, semi-annually, annually) )
Debenture (debenture_id (PK), debenture_type (convertible or non-convertible), term
(1, 2, or 3 years))
Share (share_id (PK), share_type (equity or preferred), dividend_rate)
Shareholder (shareholder_id (PK), customer_id(FK), share_id(FK))
Dividend (dividend_id (PK), shareholder_id(FK), dividend_amount, year)