# Question on Nested Link & defining relationship

**URL:** <https://www.ruby-forum.com/t/question-on-nested-link-defining-relationship/115979>\
**Category:** Rails\
**Created:** [October 1, 2007, 9:23am UTC](https://www.ruby-forum.com/t/question-on-nested-link-defining-relationship/115979 "2007-10-01T09:23:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [October 1, 2007, 9:23am UTC](https://www.ruby-forum.com/t/question-on-nested-link-defining-relationship/115979/1 "2007-10-01T09:23:58Z")

</div>

Hi,  
I am a newbie to ROR and ActiveScaffold, below please find my DB  
schema and the issue that I am seeing with relationship

## Table Userviews

userview\_id (Prim Key)  
drama\_id - belongs to table Drama  
venue\_id - belongs to table Venue

## Table Dramas (has many showtimes)

drama\_id (Prim Key)  
drama\_name  
.  
.  
.

## Table Venues (has many showtimes)

venue\_id (Prim Key)  
venue\_name  
.  
.  
.

## Table Showtimes

show\_id (Prim Key)  
show\_date  
drama\_id  
drama\_id - belongs to table Drama  
venue\_id - belongs to table Venue

The link between Drama & Showtime, Venue & Showtime, Userview & Venue,  
Userview & Drama are working fine. The userview table is the one which  
define which showtimes can be accessed by a user.

I am having trouble defining the relationship between Userviews &  
Showtimes - can anyone check this and let me know how should these two  
models be linked such that I can add a nested link from Userview  
record to Showtimes based on the drama\_id and venue\_id for each  
record.

Thanks  
Ram

---

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [October 1, 2007, 9:30am UTC](https://www.ruby-forum.com/t/question-on-nested-link-defining-relationship/115979/2 "2007-10-01T09:30:24Z")

</div>

Hi Ram

Take a look at activescaffold.  
There are some excellent examples on their homepage which will be of  
help to you.

---

<div class="post-metadata">

**Author:** ![ram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ram](https://www.ruby-forum.com/u/ram)\
**Post date:** [October 4, 2007, 6:38am UTC](https://www.ruby-forum.com/t/question-on-nested-link-defining-relationship/115979/3 "2007-10-04T06:38:36Z")

</div>

Ram wrote:

> venue\_id (Prim Key)  
> drama\_id  
> record to Showtimes based on the drama\_id and venue\_id for each  
> record.
> 
> Thanks  
> Ram

Why is usersviews linked to drama\_id and venue\_id instead of just  
show\_id?

–  
Michael W.
