If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Multiple Table Relation Design

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-28-05, 13:07
ChrisCowart ChrisCowart is offline
Registered User
 
Join Date: Nov 2005
Posts: 3
Question Multiple Table Relation Design

I'm curious whether my concept of database design is correct. Here is my case:

Case #1

Usage for a car lot.

Tables:
Sales, Accounts, CashSales

Sales:
Sale_ID, Time_Sold

Accounts:
Account_ID, Sale_ID

CashSales:
CashSale_ID, Sale_ID

The concept is that redundancy is eliminated by keeping Time_Sold in Sales, and all operations based on Sales (Sales for the month, total sales etc.) can be executed with a simple query.

The problem is that, depending on interface design (i.e. PHP site), an Account and a CashSale can have the same Sale_ID... Which is incorrect!

My question is this: is this proper design? It doesn't seem that way.

Also, what follows is my other choice for a solution, and the same question still applies.

Case #2

Sales:
Sale_ID, Type ENUM('Account','CashSale'), Related_ID

Accounts:
Account_ID

CashSales:
CashSale_ID

The concept is that each Sale is either an Account or CashSale and queries would be based around this fact. The only problem is determining which table each record is in. In order to do this, you must check whether the Type is an Account or CashSale. My question in this regard is, is this correct to discern related tables based on data in a record?

Summary:
1) Is the design of Case #1 correct?
2) Is the design of Case #2 correct?
3) Is it correct to determine which table to used based on data in a record?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 12-01-05, 08:16
pramsey pramsey is offline
Registered User
 
Join Date: Nov 2005
Posts: 20
This only attempts to answer Case #1. Based on what I understand from your question, it is okay to have Sale_ID in two different tables as long as you have those relationships defined.
__________________
Programming/Web Design
http://eofficeprofessionals.com/forums

Offer solutions-not criticism.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On