|
Agreed. Thank you
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I have this simple Lookup Items Editor that I use all over my app. It's used for many different types of lookups. The items in the Lookup Editor are loaded into lists and combos. The PK of the selected lookup item then becomes an FK in some other table.
The Remove button is a new customer requirement.
Before, once an item was added, it could not be removed. Now, they want to be able to keep the lookup lists clean and remove items not used.
So the question then is this... .how do I know if/where a lookup item has been used. I could write a method that looks in each table that uses it to see if the FK appears, but I'm not sure if this is the best approach.
Suggestions are welcome.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Add a disabled field as a nullable datetime to the lookup items table. Then filter the lookup lists, this maintains the FK requirement.
If your client is not satisfied with that then get a new client, they can set requirements they can't design your data structure.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
My client is very reasonable. Great working relationship.
The fix we came up with it to assign rights to it so that only a few users can edit lookups. They're mostly concerned with duplication entries like
"2x4"
And
"2 x 4"
Having one or 2 users manage this will probably solve it because these guys know what's acceptable
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Ah that is a different problem to the FK requirement. The mechanical way is to check the FK constraint to find the table it joins (assuming the lookup item table services many lookups) to then check the table(s) for usage of the value to be deleted.
Or simply rely on limited user capabilities and their common sense
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
That's exactly my concern. Two different items that look close and even mean the same are really 2 PKs.
As I said I could write code to check usage but my security infrastructure is already in place.
It doesn't completely remove the problem but it minimizes it
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: Two different items that look close and even mean the same are really 2 PKs. If the user doesn't know that the combination of those fields (which a PK usually is), then the user doesn't know what makes an item unique, and will be causing duplicate entries.
An overengineered solution; save a soundex of your item. If another is added, check if the soundex (or Levenshtein distance) of it is already there, and open a messagebox suggesting a similar item is already there (Google's "did you mean x?"). You can put these in a separate table.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
If you were to design a new software these days for line of business, would you go for J2EE or the new stuff if dot net was not a choice at all ?
Caveat Emptor.
"Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
|
|
|
|
|
I wouldn't; I'd challenge the choice and go for .NET.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Sounds like one of my jobs.
(No .NET; sent me on a bunch of Java courses, yada, yada ... then said we could use .NET after all; so hang in there, I guess).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
abmv wrote: , would you go for J2EE or the new stuff
You you need to be a bit more specific than that.
In general no I would not use "J2EE" mainly be cause it is 20 years old. So "new stuff" in this context would be more like "pick something that is currently supported."
My focus would be on Spring probably with either Tomcat or JBoss.
abmv wrote: if dot net was not a choice at all
Both technologies have advantage and disadvantages. With more than 10 years of experience in both, Java has a better service oriented eco system so I would normally pick that.
HOWEVER, that only works if you are building/hiring a new group. If you are using an existing group that has experience one of the stacks then you should be using that stack rather than forcing them to use something new.
|
|
|
|
|
A while back I posted questions about this, then walked away. Now I'm considering going back at it again.
The basic idea was to use an enhancement of FileSystemWatcher that I found here (I think it was this one) that solves some issues like multiple events firing for the same file/folder. It works really well and that's not my question.
The big issues I ran into are:
- How to handle multiple versions of the same file being dropped into the watch folder on different PC's at the same time. With latency, I guess I could always take the last file, but it's still a concern.
- How to deal with a file or folder being deleted or edited during a sync. Example, user creates a file/folder, the the sync starts, then as it's syncing, deletes it? or opens it with some app?
I tried to do some file locking as soon as the sync starts, but it's tricky to get the timing right.
The summary of this is, what's the right way to manage files & folders like DropBox does regardless of what's happening to a file or folder?
I'd appreciate some insight.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
dropbox basically tracks and maintains some info--- C:\Users\xxx\AppData\Local\Dropbox\instance1 -- i think they are considering each box running on diff machine as an instance and do it like in a database u lock and win.. u can run process mon and see what happen ....
Caveat Emptor.
"Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
|
|
|
|
|
Something like Dokan.Mem, A filesystem Prototype[^]? It's a bit dated tough.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Save 'em all; tack on a time stamp and source code; sort it all out later.
Some are probably more right than others, by the sounds of it.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Gerry Schmitz wrote: Save 'em all; tack on a time stamp and source code; sort it all out later.
Source code?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
The "source" of the data: IP address; user id; MAC .... stuff like that. Audit trail.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I am trying to design a class for hierarchical data, I have some categories and dynamic number of subcategories for ex:
1.Technology --> C# --> Threading
-->IO
-->Exception
2.Domain --> Finance-->Equity
-->IR
-->Currency
like that multiple categories user can configure and then he will be able to add articles for any of above category. I have multiple thoughts like below codes and having confusion between below designs of classes
Public class Category{
public int Id { get; set;}
public string description { get; set;}
public int ParentCategoryId {get; set;}
}
Public class Category{
public int Id { get; set;}
public string description { get; set;}
public List<Category>SubCategories {get; set;}
}
Public class Category{
public int Id { get; set;}
public string description { get; set;}
public Category Parent {get; set;}
}
|
|
|
|
|
Use a recursive structure.
Public class Category {
public int Id {get;set;}
public int Depth {get;set;}
public Category Parent {get;set;}
public List<Category> Children = new List<Category>();
public bool HasChildren {get{return this.Children.Count > 0;}}
}
Depth 0 is a "root".
Depth 1 has a parent of depth 0
Depth 2 has a parent of depth 1
...
etc.
And the reverse: A child has a parent at depth - 1
Same model as used by "tree views".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Other reply answers the specific question but you might want to consider your design rather than how to implement it.
Hierarchical structures tend to be hard to search.
Is it possible that what you really want are entities with properties?
So...
Entity 1: Domain, Finance, Equity
You might even consider making the categories hierarchical but the entities point to them. Since the categories themselves are a much smaller set then complicated searches on them take less time.
|
|
|
|
|
The fact that one can have multiple "views" of a single collections means they can be "easy" to search: by building "secondary" collections / dictionaries of item "references" over the primary collection.
A tree view, as it's base, uses a list view; which is a "flat" structure.
The "nodes" are indented list items. The "collapsing" is controlled by toggling visibility.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I was suggesting alternatives that should be explored before deciding on a path.
Gerry Schmitz wrote: The fact that one can have multiple "views" of a single collections means they can be "easy" to search: b
Could be. But that depends on actual business needs.
Gerry Schmitz wrote: A tree view,
Just to be clear this is a parent/child structure which could be implemented as a tree.
And searching tree structures based on parent/child structures will be 'slow' in some sense of the word. It is quite possible that the business needs, to which this post is insufficient to describe, might allow for a different structure which would provide better performance, based on the business needs.
|
|
|
|
|
I starting a core 2.2 web API prototype that will feed a WPF application (I can knock a WPF app out rather quickly) so I only need the API and database.
Starting with a SQL Server database which will migrate to Azure if it goes to presentation. I intend to create a web API that serves up JSON data directly from the data table using:
string sResult = JsonConvert.SerializeObject(dtData); This means there are no models required for the select but do I need a model for the insert/update?
I am using a custom DAL (EF will NOT be entertained) that requires parameters so identifying the fields in the json string will be a requirement.
Alternatively should I use a model structure instead of a json string?
Can I also host the web api on Azure.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Mycroft Holmes wrote: Alternatively should I use a model structure instead of a json string?
I would use a model class for consistency and validation purposes, if nothing else. How you hydrate that model really doesn't matter (as far as the utility of the model class goes, at any rate). Additionally, if you ever intend to serve the data in a RESTful format, it will make that transition a lot easier. You should be able to process that model mapping fairly easily in your DAL.
Mycroft Holmes wrote: Can I also host the web api on Azure.
Yep. In fact, you could skip the WebAPI app entirely if you use the Azure CosmosDB, but that's only useful if an object store will serve your needs.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
I was definitely leaning towards the model structure as that is what I am used to. The project needs a purely relational database so SQL Server is always going to be my go to DB.
How do you test and insert/update if you are using a model transport format, mock the model in the method?
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
modified 5-Mar-19 17:39pm.
|
|
|
|