SamSagaZ: Part of your.

 
Bartolomeo: Xgc: What is the correct way to inherit?

Vanfossen: Brunoalano: In your model, user does not inherit from employee and employee does not inherit from user. You need another object / table that holds the common detail for both, but none of the unique detail for each.

Osberg: Xgc: Can be a Account model, right? Both are accounts

Trepanier: Brunoalano: There are all sorts of ways to do that. I’m hinting at one way.

Holshouser: Brunoalano: Sure. You could call the root table an account table.

Moltrie: Xgc: I don’t know the best way to do the link of an Account to his endpoint User or Employee

Rezai: Xgc: Account user_id, employee_id or Useraccount_id ?

Oras: Brunoalano: Read about models which use roles to determine behavior / identity.

Handly: Xgc: or Account account_type: ‘User’, account_type_id: XX ?

Gullace: Brunoalano: No. I would not do that.

Walterman: Arguilez: using SELECT DISTINCT with with INNER JOIN and getting the results that i want, but not 100% sure that its right, because in that way i cant filter the newest stored stock variation

Bridenbaugh: Brunoalano: Account would be neither a user, nor an employee. So don’t add that detail to account.

Oeltjen: Brunoalano: You could identify a user or an employee by the related data found in other tables.

Pageau: Xgc: But at the moment that I authenticate and find the correct Account based on email and p***word, how can be a beautiful way to find the User or Employee instead of doing 2 queries?

Cavness: Brunoalano: Account would contain only the common detail, like name, beer preference.

Dececco: Brunoalano: You told me that only employees have an email and p***word. Not users.

Rix: Xgc: Sorry, both have email and p***word, so, both can authenticate. When the Employee authenticate, it will see the dashboard

Haymans: Brunoalano: That’s very different. It’s important to be precise in your descriptions.

Taruc: Xgc: So, what can I do now?

Hartlep: Brunoalano: Ok. Sorry. Both have email/p***word. But only users have subdomain and only employees have dashboard access, correct?

Zuazo: Xgc: Right, and Employees has roles

Merkel: Brunoalano: It’s still the same. The common account will have name, email, p***, beer_perference and then you have some other relationships that indicate subdomain access and dashboard access.

Delisle: Brunoalano: Nothing special. Just create those relationships.

Staab: Xgc: Ok, but let’s figure a scenario: I authenticate with a email and p***word, and find an Account. So, what I do now? Account has_one Employee optional, can be NULL?

Whitney: Brunoalano: You could. I would not.

Keesee: Xgc: What you would do?

Pizzolato: Brunoalano: I prefer not to use optional columns in most cases.

Ley: Xgc: Me too, but it’s the only way without doing 2 queries to find if it’s a Employee or User

Shake: SamSagaZ: sqlfiddle.com is an easy way to share your schema, your data, and the queries you’re testing. It saves us time and makes it more likely that you’ll get an answer! Make sure you set it to use MySQL.

Arguilez: I’m out of time to look sorry

Lanteigne: Brunoalano: You use separate relationships. Instead of a column to primary key relationship in the same table, use a separate table to related dashboard to account.

Nolde: Brunoalano: it’s a simple relationship between tables. But you probably need more detail to know what needs to be stored to represent a dashboard link.

Parmann: Brunoalano: Dashboard doesn’t mean anything to me. It may mean much more to you.

Oathout: Brunoalano: Don’t forget to read the “groupwise max” articles, along with information on normalization.

Lenig: SamSagaZ: Sorry. That’s for you.

Purpora: SamSagaZ; Distinct isn’t the solution for you.

Toothill: SamSagaZ: http://jan.kneschke.de/projects/mysql/groupwise-max/ http://dev.mysql.com/doc/refman/5.6/en/example-maximum-column-group-row.html

Castleton: SamSagaZ: Part of your problem is knowing what you mean, but forgetting to relate your description to the schema you are using. For instance, you keep saying “newest”, but I don’t see any concept of “newest” in your description of the tables.