r/DatabaseHelp • u/aumonkey • Jun 23 '17
Help setting up database from spreadsheet
I am trying to learn about databases and downloaded libre base and understand setting up some of the basic forms and such but I am having trouble understanding relationships. I have a spreadsheet that I use to track sales of all of my employees. It works very well but is a pain to pull reports from and is getting big enough that it needs to be put into a database and not excel.
Would anyone be willing to help guide me in how to setup what fields I need and such based off of my existing spreadsheet? I will post more info when needed if there's any interest.
TIA!
View all comments
Show parent comment
2
u/wolf2600 Jun 26 '17 edited Jun 26 '17
Okay, that's pretty simple. I'd set up the tables like this:
Then for each of the columns which are noted as foreign key in the main table above, create a dimension table (ie: Customers, Circuits, Styles, etc) where each record in the dimension tables would have additional details (customer name, customer address, customer since date, circuit name, circuit type, preferred vendor, etc).
Then as new sales are made, you can load the data into the main table and then update the various dimension tables as needed with the additional supporting data.
However.....
The accepted standard for storing sales order data in a database would be to have two tables, one for the Order headers (one record per order), and another for the OrderDetails (one record per line item in the orders). Then various other supporting dimension tables like I mentioned above.
This would be a better method if you had the case where one order had multiple line items. In your current spreadsheet, you're limited to a single line item per record.... an order can have only one circuit with one style. If a customer wanted to order multiple circuits/styles in a single purchase, they've have to have multiple records in the spreadsheet.
Then the data in the Order and OrderItems table could look like this:
Once you have the database set up, you could then run different queries to produce various reports/invoices/etc.
To get a list of products sold each day in June: