dbTalk Databases Forums  

modelin problem

comp.databases comp.databases


Discuss modelin problem in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
luigi7up
 
Posts: n/a

Default modelin problem - 09-23-2006 , 08:50 AM






I'm trying to make a good model for a following problem.

Application is about to help, let's say, ROOMMATES to keep track of
payed/not payed BILLS for a house they live in.

I thought i could make 3 tables:

BILLS( #bill(PK),amount,date,payedBy )

ROOMMATES( #mate(PK),name )

RoomMatePayed( #bill(FK),#mate(FK))

I want to SELECT all the bills in the BILLS table and a name of roommate
fthat payed that bill.

Is it good idea to put NULL in payedBy atribut for bills that are not
payed?


Hope It's not confusing...

Thanks

Reply With Quote
  #2  
Old   
Michael Zedeler
 
Posts: n/a

Default Re: modelin problem - 09-23-2006 , 06:19 PM






luigi7up wrote:
Quote:
Application is about to help, let's say, ROOMMATES to keep track of
payed/not payed BILLS for a house they live in.

I thought i could make 3 tables:

BILLS( #bill(PK),amount,date,payedBy )

ROOMMATES( #mate(PK),name )

RoomMatePayed( #bill(FK),#mate(FK))

I want to SELECT all the bills in the BILLS table and a name of roommate
fthat payed that bill.

Is it good idea to put NULL in payedBy atribut for bills that are not
payed?
Yes. Sounds okay to me. But what do you intend to do with the
RoomMatePayed relation?

Regards,

Michael.
--
Which is more dangerous? TV guided missiles or TV guided families?
I am less likely to answer usenet postings by anonymous authors.
Visit my home page at http://michael.zedeler.dk/


Reply With Quote
  #3  
Old   
FreeData
 
Posts: n/a

Default Re: modelin problem - 09-23-2006 , 10:43 PM



Quote:
I'm trying to make a good model for a following problem.

Application is about to help, let's say, ROOMMATES to keep
track of payed/not payed BILLS for a house they live in.

I thought i could make 3 tables:

BILLS( #bill(PK),amount,date,payedBy )

ROOMMATES( #mate(PK),name )

RoomMatePayed( #bill(FK),#mate(FK))

I want to SELECT all the bills in the BILLS table and a
name of roommate fthat payed that bill.

Is it good idea to put NULL in payedBy atribut for bills
that are not payed?


Hope It's not confusing...

Thanks
No, that would not be a good idea. If the roomate has not
paid anything, don't add a row. See the beauty?


Reply With Quote
  #4  
Old   
Lennart
 
Posts: n/a

Default Re: modelin problem - 09-24-2006 , 02:52 AM




FreeData wrote:
[...]
Quote:
Thanks
No, that would not be a good idea. If the roomate has not
paid anything, don't add a row. See the beauty?
IMO, It depends on the process. A reasonable approach would be that a
bill is added each month, and when it is payed, the bill is marked as
such.


/Lennart



Reply With Quote
  #5  
Old   
luigi7up
 
Posts: n/a

Default Re: modelin problem - 09-24-2006 , 07:36 AM



Sorry , I just noticed that ROOMMATES and BILLS is not M:M relationship

so roommatePayed is not necessary as Associative entity.

My solution is going to look as follows:

BILLS(#bill (PK) ,amount,date,payedBy (FK) ) // I'm about to
put payedBy = NULL if the bill hasn't been payed yet. This is OK?

ROOMMATES(#roommate(PK),name)

This way I'll be able to create following SELECTS:
- All BILLS
- all not payed bills (where payedBy = NULL)
- all payed bills
- bills payed by some user
etc.

Hope this is 3NF now

regards ,

Luka

Michael Zedeler wrote:
Quote:
luigi7up wrote:
Application is about to help, let's say, ROOMMATES to keep track of
payed/not payed BILLS for a house they live in.

I thought i could make 3 tables:

BILLS( #bill(PK),amount,date,payedBy )

ROOMMATES( #mate(PK),name )

RoomMatePayed( #bill(FK),#mate(FK))

I want to SELECT all the bills in the BILLS table and a name of
roommate fthat payed that bill.

Is it good idea to put NULL in payedBy atribut for bills that are not
payed?

Yes. Sounds okay to me. But what do you intend to do with the
RoomMatePayed relation?

Regards,

Michael.

Reply With Quote
  #6  
Old   
Michael Zedeler
 
Posts: n/a

Default Re: modelin problem - 09-24-2006 , 12:12 PM



luigi7up wrote:
Quote:
Sorry , I just noticed that ROOMMATES and BILLS is not M:M relationship

so roommatePayed is not necessary as Associative entity.

My solution is going to look as follows:

BILLS(#bill (PK) ,amount,date,payedBy (FK) ) // I'm about to
put payedBy = NULL if the bill hasn't been payed yet. This is OK?

ROOMMATES(#roommate(PK),name)
Sounds ok to me.

Regards,

Michael.
--
Which is more dangerous? TV guided missiles or TV guided families?
I am less likely to answer usenet postings by anonymous authors.
Visit my home page at http://michael.zedeler.dk/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.