I am developing a website which uses tables in UI, and our customer wants that the users can customize the columns they want to see in UI for each table, and to store this settings inside the Database.
My question is: what is the cleanest way to support this feature into the Database, avoiding to have the data stored coupled to the UI?
Related
I’m building two applications that need to share some similar data but each will also have unique data. Should I build a separate database for each app or let each app access the same database.
I need the shared data to update automatically on one app if it is changed in another. I’m also using postgresql with react and express with the intent of having both apps be progressive web apps and eventually react native apps.
In general, I would think of this as:
Databases are the unit of backup and recovery.
Databases can contain multiple schemas ("schemata" ?) which are the unit for managing users and objects.
Based on your question:
I need the shared data to update automatically on one app if it is changed in another.
It sounds like you want one database and separate schemas for each application.
It sounds as if you will need to join the database from both applications in a single SQL query. In that case, use one database and multiple schemas to separate the data.
You could have one schema common that contains the data which is shared between all applications and then one schema per application.
Both has pros and cons. But i think keeping them separate will be better. Pro for one can be con for other.
Pros -
separate DB makes maintenance better,faster and easy.
performance wise separate DB is better.
Migrations of code will be easy.
Cons -
Auto synchup can be tricky if tables etc. are different.
If one process need to use tables from both DB, it will be an issue.
I want to create the design of a SQL database that will hold the data entered from a dynamic created websites (something like http://www.wufoo.com).
Users of the system will create forms by dragging controls into the form and then they will use the created forms to build a website by including the forms in some pages.
What would be the options that I have when I create the architecture of the database.
Since you do not know what you will get in your DB, how the object will look like; I would suggest using NoSql.
Otherwise you need to create some very abstract table, let's say Form, and then make in inheritable by other tables (ye, you can do that in EF)
I've got a database and the user can only read and update his tables.
I don't get how can I add new records to the tables and load the updated database in the App's Document folder without losing users' data.
Example:
Database with 2 tables:
Table A where user inserts and updates his data.
Table B which is a data source, where user can only read.
Now I want to add some new records to the Table B and upload the updated database into the App without losing data stored in Table A.
Btw, The database doesn't get copied as an older version is already stored in the Documents folder.
How can it be done?
A few possible considerations:
Periodic data updates between system releases
If you're talking about ensuring the app can receive updates to table B periodically (i.e. between releases of the app), then you presumably want to design a web service to retrieve updates. If table B is not too large, design a web service that retrieves the entire contents of B in some nice format (e.g. JSON is great for this) and then write the code to contact the web service, request this data and then integrate it into the local copy of the database). If B is large, you might want to design a web service that only retrieves any creation, deletion, or update transactions.
If you haven't done this before, I might refer you to Wenderlich's How To Write A Simple PHP/MySQL Web Service for an iOS App and its companion, How to Write an iOS App That Uses a Web Service.
Migrating databases when releasing new version of app
On the other hand, if you're talking about releasing a new version of your app, but not wanting to lose the customer information in table A, you can open both databases simultaneously (open the documents database, and then use the ATTACH DATABASE command to simultaneously open the other one in the same sqlite3 session), and then you easily copy data from one database to the other using SQL. For example, open the new system database (with the updated table B) and attach to the database with the updated user data in table A:
NSString *sql = [NSString stringWithFormat:#"ATTACH DATABASE \"%#\" AS user_db", customerDbPath];
You can then re-populate userdata (table A) from the user_db database:
DELETE FROM userdata;
INSERT INTO userdata SELECT * FROM user_db.userdata
If you're doing this sort of "database migration" (integrating system updates of table B with user updates of table A), you probably want to use some control mechanism by which the system can quickly compare two databases and make sure that you know you're dealing with the same rendition of table B. You can either use the PRAGMA user_version for this purpose, or I personally generally have my own configuration table in which I'm saving general configuration information and I always have a version number in there.
Separate databases?
One final consideration is that you might contemplate having separate databases for these two tables. This generally is not the right approach, but if you have little interaction between the two tables and if they're radically different types of data, it's another approach to consider.
I am creating a software for retail shops and I want that my software support SQL Server and SQLite. If the user is a standalone (one PC) select the sqlite database and if it is over the network then choose the SQL Server option.
I am developing this software in Visual Studio 2010 and vb.net language.
As research we have three types of connections in Visual Studio, ODBC, OleDB and MSSQL.
And OLEDB can support MS-Access database and SQL Server.
Any comment and idea is highly appreciated.
The best way to code your applications is to abstract functionality into different tiers or layers. This can mean lots of things and can get quite complex, but the general idea is to keep your application's parts separated. Let's assume you have an inventory form in your program where you can look up current inventory. The form that displays the inventory doesn't need to know what database your customer is running. Generally you're better served by it not knowing. Likewise, your code that accesses the respective database, whether it be SQL Server, SQLite, or Access, doesn't really need to know what your Inventory form is going to do with the data it is retrieving. All your Inventory code should be doing is displaying your inventory in a way that's most useful to your customer, and all your data coding should be doing is getting the data that is requested of it.
The route I would probably take in your situation is to create a data provider class. Inside that class is where you would encapsulate logic for the different database functions you may have, as well as the different database systems your customers may have. Say for instance a store owner just received a shipment of products and needs to add one to his store's inventory. Ideally, your program should simply be able to perform a call like DataProvider.AddInventory(). Inside the DataProvider class, you would write code to keep track of which database solution the customer is using as well as an implementation of logic for each of the database solutions you'd like to support. Ideally, you should implement every data function you may need your application to perform so that it can be called very simply like the AddInventory() example.
Implementations of data providers can be as simple or complex as you like. In some cases where you're going to have multiple applications written in multiple different languages on multiple different platforms accessing your data source from multiple locations, it may make sense to write some sort of middleware. In your case, it sounds like this is the type of application that will reside "in house" and should be served fine by abstracting the data access to a separate class.
I am adding a custom table to an Ektron database. What is the best practice for connecting to the database? Using standard ADO.NET code or is there a way to use the CMS' connection to the database? What is best practice?
Ektron 8.0.1 SP1
Adding Custom tables to the Ektron Database will not cause any issues,there is no need of another Database if you are having only few custom tables to be added.
Altering the Ektron tables will create issues,so it is better not to go for that.
For accessing data from the Custom Tables make use of LINQ (refer:here).
I know this question is a little old and answered, but I wanted to add my two cents. While altering Ektron's tables isn't advised (that is, without the API or scripts they've provided), adding your own table does no harm. If Ektron didn't support it they wouldn't provide the "Sync Custom Tables" option in eSync.
I came across this and thought that I could add a little to the discussion in case anyone is considering adding a custom table to the Ektron database. I think this topic is still relevant to the current version of Ektron and could be helpful.
Here are some good points:
Do not alter tables created by Ektron. (Point made by Bisileesh extended comment below)
Adding custom tables to the Ektron database is recommended in certain circumstances.
Using a smart form for content may be recommended but there are times when it is not optimal.
Here are some reasons why I say these things:
You should not alter tables created by Ektron for several reasons. Basically you don't want to change these because the Ektron software relies on these tables and modifications could cause errors. Besides the possibility of breaking things, if you ever upgrade Ektron, the Ektron Update may alter table definitions and erase your changes.
Adding tables to the existing Ektron database is a good idea when compared to adding a new database for several reasons.
First, you don't incur the additional cost of a full database structure on your server when you add a table.
Second if you are working in a multiple server environment (development, staging, live) by adding your tables to the Ektron database you will be able to use eSync to manage transferring the data between servers. If you use your own database, you will need to manage synchronization elsewhere.
I started with the idea that it was better to use my own database, but over the years I have discovered the advantages of using the Ektron database. Just as if you were using your own database, you should save the scripts to create the custom tables and perform database backups on a regular basis to ensure that you are protected.
After doing Ektron upgrades you should ensure that your customized tables are still present in the Ektron database.
When setting up eSync for custom tables I had to first run the sync on an empty table. After running the sync to establish a relationship, I was able to add data. There is also a requirement that there be a primary key on the custom tables and I don't think it can be an auto-incremented field. Consult Ektron for the latest requirements.
When considering whether to add data to a smart form or a custom table here are some things to consider. If you use the Smart Form you are committing to using the Ektron provided controls to access your data. This may be a good thing or a bad thing depending on your requirements and the current state of Ektron.In my case, search was a big deal. In versions 7.6 and 8.0 there were problems with the Ektron Search and it was no easy to do boolean searches across multiple fields. To overcome this I used custom tables that I could directly query. The search in version 8.6 has been changed but I still use my custom solution so I don't know if things are working better now.There are other data management issues that come up with smart forms and the Ektron Workarea that make it a good idea to avoid smart forms in some other cases too. The best place to store your data is not one place or the other, it depends on your requirements.
Best practice is to not use custom tables. If you can store your data as smart forms, users can use the workarea to edit their data. If you have to use a custom table, there are several ways:
One way is to pull the connection string from the web.config in an ASPX page
<asp:SqlDataSource ID="EktronSqlDataSource" runat="server" ConnectionString="<%$ConnectionStrings:Ektron.DBConnection %>" ></asp:SqlDataSource>
I'd look at using a different database. As mentioned by maddoxej, Ektron doesn't really like you messing with SQL and tables and what-not.
Granted, you may have admin reasons for using one database, but for the sake of maintainability I think it's worth having a second database which you fully control.
You can add custom tables without effecting existing ones. But to use them you need custom controls each time. Like custom layouts, custom forms, custom widgets.