I am developing one web based payment system. I am facing problem in database design.
Following are tables and their fields:
Customer: cust_id , name
Supplier: supplier_id, name
Employee: employee_id, name
Expanse: expanse_id , name
group: group_id, group_name
(groups are: {1,Customer},{2,Supplier},{3,Employee},{4,Expanse})
and there will be one more table:
payment: payment_id, group_id, name(ids), amount
In above table, name field will contain id of respective group. Like if group id is 1 and name is 15 that is customer whose id is 15 (customer_id=15)
I want to know that above tables satisfy 3NF? if not then what is the correct way.
Also i want to know that if i want list of all the payment, which will have fields like: payment_id, group_name, name_of_person/expanse. What will be the query to get this list.
-
Not 3NF to me. That would be some ugly queries.paparazzo– paparazzo2016年09月18日 16:44:20 +00:00Commented Sep 18, 2016 at 16:44
-
1"In above table, name field will contain id of respective group. Like if group id is 1 and name is 15 that is customer whose id is 15 (customer_id=15)" -- This is too cryptic. Please show sample data, and show the query.Rick James– Rick James2016年09月19日 00:04:14 +00:00Commented Sep 19, 2016 at 0:04
-
Customer table data ({1,'Ana'},{2,'John'},...,{15,'Tim'}). Supplier table data ({1,'Mark'},{2,'Sophia'},...,{18,'Elizabeth'}). payment table data ({1,1,15},{4,2,18}). Then list of payment should be: ({1,'Customer','Tim'},{4,'Supplier','Elizabeth})Kartik Parekh– Kartik Parekh2016年09月19日 01:57:36 +00:00Commented Sep 19, 2016 at 1:57
-
3What are the FDs? Without that, questions about normalization are mere speculation.Walter Mitty– Walter Mitty2016年09月19日 10:39:39 +00:00Commented Sep 19, 2016 at 10:39
2 Answers 2
One of these is not like the others - expanse
Entities:
groupID, ID, name
composite PK on groupID, ID
(As non-native English speaker, "expanse" is not immediately clear to me)
I'd join the four tables (customer, supplier, employee, expanse) to a single table
(id, group, name)
Depending on your needs, id
could be unique key, so group
would be only foreign key for linking group. In this case group
can be dropped from payment
.
-
It's likely a typo of "expense".ypercubeᵀᴹ– ypercubeᵀᴹ2016年09月20日 17:40:46 +00:00Commented Sep 20, 2016 at 17:40
Explore related questions
See similar questions with these tags.