Quantcast
Channel: VBForums - Database Development
Viewing all articles
Browse latest Browse all 2918

[DB Schema] Need input on a DB schema

$
0
0
Well, right when I thought I had it figured out, I've run into a DB design snag.

DBName: ToolsDB

Current Table: Charts

Name:  Chart_Table.png
Views: 48
Size:  13.5 KB

I thought this table would be all I needed.

It would hold the PORTFOLIO name that will contain a number of CHARTS.

And it would have the CHART name and the PATH where the data to create the chart exists on the drive.

And the ToolsJSON would hold all the Tools and their attributes.


But here is where the issue lies.

The USER is required to create 1 or more Portfolios to house the charts.

The user might create a Portfolio called Futures and one called Stocks, for example.

Name:  2023-09-27_20-01-27.png
Views: 52
Size:  5.1 KB

These Porfolios would appear in a Listbox like this:

Name:  ListBoxPortfolios.png
Views: 54
Size:  3.9 KB

At this time, there are no CHARTS associated with those PORTFOLIOS. Thus, the CHARTS table shows NULL for all fields except Porfolio (and Chart_ID).

So now that it is time to add CHARTS to a PORTFOLIO, the user double-clicks the Portfolio name in the list and is presented with the opportunity to select data files to add, along with getting to name the chart.

Then I realized, I have one record per Portfolio with NULL fields. Do I fill in the existing Portfolio record with the first chart, and then each additional chart have to create a new record using the same Portfolio name but different chart, etc. etc.? My code is currently setup to allow only unique Portfolio names so that the list does not show multiple portfolios with the same name, etc.

I know I can filter this, but it seems sloppy.


I 'think' I need one table called PORTFOLIOS that list only Portfolios, with that column being UNIQUE. And it should have a Port_ID.

Name:  PortfolioTable.png
Views: 53
Size:  4.3 KB

I 'think' I then should have a table called CHARTS, that instead of holding the Portfolio name, should instead hold the Port_ID the chart record belongs to.

Name:  ChartsTable.png
Views: 53
Size:  4.5 KB

If this is correct, then I think that when a Portfolio is selected for inserting stocks into, I get the Port_ID for the Portfolio, and then for each stock (btw, stock and chart are synonymous) I create a new record in the CHARTS table and insert BOTH the Port_ID and the StockName, path. Later I can come back and store the JSON attributes by matching Port_ID and StockName.

(A stock can exist in multiple portfolios, but only one in each.)

Does this schema look logical for this task? Or something else?

TIA
Attached Images
     

Viewing all articles
Browse latest Browse all 2918

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>