Search code examples
mysqlauthenticationbilling

mysql: For billing purpose, printing user ID on bill .


I have this idea which I need some help with. Currently I am developing a mysql database with a java interface. It is a hotel management system, and for billing purpose. I have the following tables.

Bill (BillID, ResvID, IssueDate, ToTalBill, ChargedTo)

Employee (EmpID, Name, Age, Nationality, NatId, Mobile, Telephone, Email, Position, Language, Salary, JoinDate)

User(UserID, Password)

as per the requirements, the ID number of the employee (UserID or EmpID) should be printed on the bill.

Any suggestions or ideas about implementing this ?

Thanx

Note : to log in the system the user has to log in (front desk receptionist). The employee table includes list of all the employees, and there is another table User (who are the users of the system, In other words, User has to be an employee and not all the employees are users ) I am considering linking Bill table to User table


Solution

  • Change your table structure as follows

    Bill (BillID, ResvID, IssueDate, ToTalBill, ChargedTo, UserID(foreign key User))  
    
    Employee (EmpID, Name, Age, Nationality, NatId, Mobile, Telephone, Email, Position, Language, Salary, JoinDate)
    
    User(UserID, EmpID(foreign Key Employee), Password)
    

    Now you have user id in bill itself and if required you can get empID using userID
    Assumptions
    - every user is employee
    - only users can generate bills.