1

In our new system we have three type of people

  1. Business owner
  2. Assistant of business owner
  3. Staff (a skilled employee)

I am having following entity

  1. [Business] - include detail about business owner
  2. [Assistant] - detail about the assistant
  3. [Staff] - detail about the staff

Business rules

  1. There will be only one business owner for a given business, means there can be only one login for business owner. He is like a super user for his business.
  2. Business owner can be staff as well.
  3. A single business can contains more then one staff and each staff have different kind of rights/permissions can be configured by business owner.
  4. Only one assistant allowed per business and rights/permissions can be configured by business owner.

What would be right way to go for class design as well as database design?

Any help/suggestion appreciated!!!

Update 1 : Base upon the feedback I have come up with following data model. I am using EF 4.1 with code first approach and each data entity will map directly with one class. Data model

Please suggest you feedback!

Mahesh
  • 1,754
  • 7
  • 36
  • 54
  • 1
    A few suggestions. 1) Is it possible in the future for a user to not have a login? I would probably combine those entities. 2) There are shared properties between business owner, staff and assistant. Couldn't they be moved to application user entity? – Dessus Jan 04 '12 at 20:49
  • @Dessus - Is up to business owner; he can create at most one assistant and one or more staff to login into the system. In this context only business owner will have login and others (assistant and staff) have optional login facility. – Mahesh Jan 05 '12 at 03:36

3 Answers3

1

Your question is quite vague, but for the multiple users scenario, I think this has been answered excellently here: Single Table Inheritance (Database Inheritance design options) pros and cons and in which case it used?

I would also recommend you look at database normalization, see: http://en.wikipedia.org/wiki/Database_normalization

Unfortunately I can't recommend much more without more information.

Community
  • 1
  • 1
Dessus
  • 2,147
  • 1
  • 14
  • 24
1

If I understand correctly, you have some front end right? these 3 types of people doesn't access database directly (logging into database server). I think you need to have users and associated roles stored in your users table and based on logged in user role your front end web/desktop application need to constraint the operations. When business owner need to assign a role, he is going to select staff and roles from roles table and map it.

This is how I am envisiong, UserTable with ID,pass,adress etc., RolesTable with RoleID,RoleDescription,RoleName etc., UserTable--RoleTable mapping table

While login, your frontend need to verify login details and get associated roles from userTable--RoleTable mapping table.

kosa
  • 65,990
  • 13
  • 130
  • 167
1

I have found some problems with your class design. Its not a proper way that you are keeping the information of a BusinessOwner in Business Class. I am proposing the following design of your system-

Abstract Class BusinessPeople

Class BusinessOwner extends BusinessPeople

Class Assistant extends BusinessPeople

Class Staff extends BusinessPeople

And in your Business class you can keep details of your business. You can design your database using the above class design. Create a table name Staff which must have a staff_id working as the primary key. Then create tables for BusinessOwner, Assistant ... other stakeholders each table having a attribute named staff_id which is the primary key of the table Staff and working as a foreign key in these (BusinessOwner, Assistant etc.) tables.

Alim Ul Gias
  • 6,351
  • 2
  • 28
  • 39
  • Base upon your suggestion I am come up with first version of data model. – Mahesh Jan 04 '12 at 08:51
  • I think you should use UserRole instead of permission. That will probably make the application more easier to handle with.But obviously the choice is up to you. Cheers !!! – Alim Ul Gias Jan 04 '12 at 12:15
  • You are right, this data model just to discuss the specific scenario. – Mahesh Jan 04 '12 at 12:25