# DB & AR advise please (diagram inc)

**URL:** <https://www.ruby-forum.com/t/db-ar-advise-please-diagram-inc/97972>\
**Category:** Rails\
**Created:** [January 27, 2006, 5:13pm UTC](https://www.ruby-forum.com/t/db-ar-advise-please-diagram-inc/97972 "2006-01-27T17:13:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [January 27, 2006, 5:13pm UTC](https://www.ruby-forum.com/t/db-ar-advise-please-diagram-inc/97972/1 "2006-01-27T17:13:25Z")

</div>

Hi,  
Being new to Rails and Active record could someone please check my  
database diagram:

[![](http://spectrais.com//images/0.png) ](http://spectrais.com//images/0.png)

I am building a trouble ticket system for my company. Simply put a  
client has many users. Those users can create trouble tickets. Each  
trouble ticket can have many journals that track the progress of the  
ticket. An employee (of our company) can take ownership of a trouble  
ticket to solve the problem.

As you can see from the diagram the employees and users table looks  
identical. Is this something that I can acomplish with singe table  
inheritance, thus creating a model for employees and one for users?

Also is my Active record text correct in your opinion? I would like to  
be able to do things like:

client = Client.find(params[:id])  
client.get\_all\_active\_tickets

user = User.find(params[:id])  
user.get\_all\_tickets

ticket = Ticket.find(params[:id])  
ticket.get\_all\_journals  
ticket.get\_current\_employee  
ticket.get\_status  
ticket.get\_company\_name  
ticket.get\_company\_email

employee = Employee.find(“John S.”)  
employee.get\_all\_my\_tickets

Any help would be fantastic!

Thanks Aftershock

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [January 27, 2006, 5:30pm UTC](https://www.ruby-forum.com/t/db-ar-advise-please-diagram-inc/97972/2 "2006-01-27T17:30:15Z")

</div>

You might want to have a look at this site,  
[http://www.simpleticket.net/](http://www.simpleticket.net/).  
Open source ticket system about to be launched this weekend. I am not  
in  
any way associated with Architel.  
Harvey

On 27/1/06 16:13, “James W.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ticket. An employee (of our company) can take ownership of a trouble  
> client.get\_all\_active\_tickets
> 
> employee = Employee.find(“John S.”)  
> employee.get\_all\_my\_tickets
> 
> Any help would be fantastic!
> 
> Thanks Aftershock

This e-mail has been scanned for all viruses by MessageLabs.

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [January 27, 2006, 5:37pm UTC](https://www.ruby-forum.com/t/db-ar-advise-please-diagram-inc/97972/3 "2006-01-27T17:37:09Z")

</div>

Harvey,

Thanks I have seen the simpleticket blog etc. The system i’m building is  
only part of the whole application and it is tailored to what we  
require. After this is completed it will be expanded to include client  
invoicing (this is currently done by PDF), client kit ordering, employee  
timesheets (linked in with the time spent on answering trouble tickets)  
etc.

It would be useful to see what simpleticket has but I am very keen to  
learn my own way of doing things rather than copy another solution. My  
plan is to learn more and more ruby & rails stuff.

Does the diagram look ok? Am I on the right lines?
