-1

So the detail is I am developing bookshop system, so I have two tables that have relation with my project. First one is table book which has price attribute, same goes with table stationary and it has price attribute too so my question is since both of them have price attribute inside it so they will be foreign key right? and should I create price attribute for book table as BookPrice while stationary StationaryPrice?

I am expecting for suggestion of my book and stationary table for prices attributes

June7
  • 19,874
  • 8
  • 24
  • 34
  • 2
    Does this answer your question? [How can you represent inheritance in a database?](https://stackoverflow.com/questions/3579079/how-can-you-represent-inheritance-in-a-database) – philipxy Dec 07 '22 at 07:01
  • Correct spelling is "station**e**ry". How different are the fields for book and stationery? No, price would not be foreign key. – June7 Dec 07 '22 at 07:24
  • It may not be a good idea if you have one table for each product category. Try to apply 'Abstraction Principle', think of models instead of individual products. Then you can come up with a more flexible design. – JHH Dec 07 '22 at 07:24

1 Answers1

0

if there are same columns in both the tables, then it is not good idea to have two different tables. Simply create a single table with the extra column for the product category. If this does not solve your problem, share the table descriptions so that we can figure out the actual problem.

tejas
  • 48
  • 4