I'm creating a feature that has an option to create infinite bank account transactions by month, for example: A user buy something in 12x parcels, will be created 12 rows on database with relation with this purchase in a table called bank_account_transactions.
Now the problematic scenario: A user has a salary that increase the balance of bank account every month for the rest of his life, how can i store this in database?
I thought store data equivalent to 100 years (12*100=1200) but it is so slow because when the user update the value of his salary, will update 1200 rows in database.
How can I solve this in a performatic way? The project is developed with Nodejs and MongoDB.
Building an internal web-based project management tool for my company. Need some help with the database design for the timesheet component.
We currently use an MS Excel file where:
Column headings - Days of the week
Rows - Time of the day with 30 minutes per row (Row1: 9:00AM, Row2: 9:30AM and so on)
Each cell in the table has a dropwdown menu that fetches from a set of predefined tasks set by a manager and the employee selects one of the tasks against that day and that particular 30 minute time slot.
I want the front end interface to remain the same for the employees.
Need help with designing a database that supports this. I'm open to any suggestions/changes in the restrictions I laid out if it allows for better efficiency. Thank you!
Is something like this what you're after?
Task (all of the tasks an employee might be assigned)
PK: Id
Name
... other details ...
Employee
PK: Id
Name
... other details ...
EmployeeTask (the list of tasks that have been assigned to an employee)
PK: Id
FK: TaskId
FK: EmployeeId
TimePeriod (the row labels)
PK: Id
Start (9:30, 10:00 etc.)
Timesheet (chops out a region of time and says it's one thing - gives column headings)
PK: Id
Start date
End date (don't need this if timesheets cover the same length of time)
EmployeeTimesheetCell
PK: Id
FK: TimesheetId
FK: EmployeeId
FK: TimePeriodId
FK: TaskId
Date or day of the week
Time spent
You'd probably want some kind of status or Finished Date on Task and/or EmployeeTask, so that old finished tasks don't clutter up the GUI.
I have to design tables in 0NF for my project, I am required to design the tables in 0NF form first then proceed to normalization and then draw the ERD. However it has been a real challenge for me to obtain the 0NF forms of my tables, lots of time has been wasted trying to redesign so I thought of asking help from people who might be more experienced in database design.
My database is of a Car Rental System. The system should keep records of customers,cars,employees, details of each rental and also the company is supposed to have multiple branches at different locations and each branch must have their own set of unique(identified by their license plate number) cars available.
One customer can have multiple rental records(i.e. made a rental in January then another in March .e.t.c) but one rental record is related to only one customer
A customer can book multiple cars in a single rental
Each rental is made through a single booking agent(an employee)
Employees is divided between Managers and booking agents. Each branch has a single manager but multiple booking agents.
Each branch has multiple cars located there but each car can be located at a single branch
So far, I've come up with these 0NF tables, they don't look correct to me though:
Cars(CarID,LicensePlateNo,Make,Model,Year,Color,mileage,Capacity,seats,Availability, Rate, BranchID,BranchLocation)
Customer(CustomerID, FirstName,LastName, Address ,ContactNo,Gender,DOB,NIC,RentalID,DateRented,RentalCost)
Agent(AgentID,FirstName,LastName,Address,ContactNo,Gender,DOB,NIC,MonthlyRentals,Salary,ManagerID,ManagerName,MangerLastName,ManagerAddress,ManagerContact,BranchID,BranchLocation)
Rental(RentalID,DateRented,Duration,RentalCost,Discount,AgentID,CarID,LicensePlateNo,Make,Model)
Branch(BranchID,BranchName,BranchLocation,ContactNumber,ManagerID)
I have replaced the Agent table with the Employee table and I have added 2 new columns (Position and Manager) to it. I believe the position column should store either 'Agent' or 'Manager'. If employee is an Agent, the Manager field should contain the ID of his/her Manager (EmployeeID). If employee is Manager, most probably the Manager column should be left NULL. I have also removed all other columns which were being repeated(Example BranchLocation in cars table etc...)
Cars(CarID,LicensePlateNo,Make,Model,Year,Color,Mileage,Capacity,Seats,Availability, Rate, BranchID)
Customer(CustomerID, FirstName,LastName,Address,ContactNo,Gender,DOB,NIC,RentalID)
Rental(RentalID,DateRented,Duration,RentalCost,Discount,EmployeeID,CarID)
Branch(BranchID,BranchName,BranchLocation,ContactNumber,EmployeeID)
Employee(EmployeeID,FirstName,LastName,Address,ContactNo,Gender,DOB,NIC,MonthlyRentals,Salary,BranchID,Position,Manager)
Thanks
I am in the process of designing a small database application for a health center in my local community. The health center can receive both In & Out-Patients.
The one area i am not sure of how best it should be implemented is how to bill the patient automatically from the drugs/medication they have be given. I don't want the user to type in the name and price of the drugs given to the patient. I want to automate it with a list of all available drugs and their CURRENT prices in a table so that the user just selects a drug from a list & i the software should be able to determine the total.
I also want to maintain the history of drugs over time. Some thing like drug XXX was selling at $1234 in January, $4567 in September, $12 in 2008. So if i am to print a receipt for a patient who visited in 2008, the patient should be billed at the rates of 2008 not the drug current rate.
I am just asking for some general guidance and suggestions on the best database schema of a scenario related to my problem description above.
Thanks a lot.
With a table of drugprices
DrugPriceID DrugID PriceStartDate DrugPrice
1 1 1-1-2008 1234
2 1 1-9-2008 4567
which links to a table of drugs on DrugID. The price applies until it is superseded by a new price.
A table of Patients, which links to a table of PatientOrders,
PatientOrderID PatientID OrderDate
5 3 4-5-2008
and a further table of OrderDrugs
OrderDrugID PatientOrderID DrugID
6 5 1
I am developing a Electronic Bill Payment System for a bank which has more than 100 customers subscribing for Electronic Bill Payment.
I have a table in which I am creating profile for customer like the following.
Customer Table
Customer_ID (Primary key)
Customer_Name
Address
Phone
Bill_Master
Customer_ID
Enrollment_Date
UtilityCompany_ID
Bill_Generation_Date (lets say 18th of every month)
Bill_Due_Date (lets say 27th of every month)
Our_CutOff_Date (when the bank will generate the bill for payment)
I have created the customer along with clue that which utility company's bill generates on which date and what will be the due date of EVERY MONTH.
I want to create an interface where the user will see the entries of all the customers whoz date is due for bill generation and after that user will click on the particular entry and generate the bill manually by entering the amount and other details so for this I am clueless how to find out which customer's utility company bill is due for generation..
Any help how should I design it and query of it? or would be a automatic procedure like job or something which will do it.
thanks
Well if its a query you need to generate bills that are due 27th of every month and also find the customer's utility company, then you can try this -
SELECT A.Customer_Name, B.UtilityCompany_ID FROM
Customer A inner join Bill_Master B on A.Customer_ID = B.Customer_ID
WHERE Bill_Due_Date BETWEEN GETDATE() AND DATEADD(MONTH,-1,GETDATE())