How to update data in database without using several queries? [closed] - database

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
In my application, it shows student's subject and it's result. First, I have written this application to show the subject and results only. But, now we need to extend it's functionality to update subjects results from admin panel.
Problem is in my database, I have recorded results, if the student has taken-part in the given subject. As an example if a student is absent for mathematics, in the application subject will be printed without results for mathematics.
What I need is to update the results for each student. What I have noticed was, I need to write update, insert and delete queries to update student's results.
I don't want to handle 3 queries. I am looking for more flexible way of doing this.
One solution, I came across is, update database manually. That is if the student is absent for any given subject, update results to 0 and keep the record. so in admin panel, I need to use only update query.I am not sure where this is ok from database concepts.
Is there any better solutions?

I didn't understand your question... may be this will be useful check this one
$var=1;
update tablename set col=col+$var
you can directly add value without retrieving previous value.

Related

Which is better to use DynamoDB filter expression or filter in code? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
In our application, we have to filter some data. we are using Dynamo DB. In our team, we have a different opinion to use filter expression at dynamo or application level. I want to know what has been following in the industry. Please let me know if you know about some good blogs?
Consider the scenario, we have to deal-template in the active state which can be deactivated by the user. In the get list call, we want to send only active templates.
Dynamo:
filterCondition := expression.Name(activeColumn).Equal(expression.Value(true))
Application:
List<DealTemplate> templates = getTemplate()
for templaes := range templates {
if template.isActive {
// process
}
}
May be getting close to the line regarding questions with opinion based answers..
But the best solution is to structure your data so you don't have to filter anything out at all. Use either a Local Secondary Index (LSI - no extra cost) or a Global Secondary Index (GSI - extra cost)
This way you don't have to pay to read data that gets thrown away.
Otherwise use a filter expression. You still have to pay to read the data, but you don't have to pay to transfer it back; in real $$ if out of AWS and in overhead regardless.

How to generate unique ids in C [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am developing an app which requires to generate an id for new users I want to do it with the smallest number of characters that allows me to create 100 billion diferent possible ids so how should I do that and how to avoid giving two users the same it? Should I look if that id exists? Should I use a random id generator or give ids in order like 001 002 and so on?
This depends entirely on what kind of functionality you expect from this id, do you intend for these id's to correlate with persisted data, such as a database? If this is the case, it might be more prudent to let the database handle the unique ID generation for you. Otherwise, using sequential values such as 1,2,3... etc would probably be ideal. unsigned long will keep you covered for the first 2 billion users... If you somehow go beyond that, you can rethink your data storage then.
The question is very broad.

Bullet Points and Databases [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I received a list from a customer using bullet points, and then sub bullet points. What is the best way to store these in a Postgres database, if you could give me an example of this, that would be great.
Thanks!
Structure of it is something similar to this:
Defect1
possible instance of defect1
another possible instance of defect1
Defect2
possible instance of defect2
another possible instance of defect2...
For indented lists you're basically talking about a tree structure. There are many ways to store hierarchies. See this answer for a comparison.
Design Relational Database - Use hierarchical datamodels or avoid them?
Depending on how you want to use the data, i.e., if you're just going to spit it back out as it came in, you may be able to skip the hierarchy aspect in this particular use case and just store each line in sequence with an indentation field. It won't do nearly what can be done with a tree, but it may be all that's needed in your particular case.

Database Design for similar data across multiple time [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am attempting to come up with a Database Design that works well for a specific division of my company.
Basically, I have a list of Account Numbers with a ton of fields associated with them. My division needs to compare how these fields change over time (What was in that field for this account number a year ago?).
I am currently thinking of a very linear approach where I use only one large table for the data that is time stamped so a table would have the name AccountInfo04012013 and then the next month would be a new table called AccountInfo05012013. This way we can make comparisons between any two months.
What are the drawbacks of this plan? and what should I be doing instead?
You are going to have to use timestamps. All database managers will have this built in.

Double entry accounting database design [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Simple question
See http://homepages.tcp.co.uk/~m-wigley/gc_wp_ded.html
Ok there are 3 tables ACCOUNT, JOURNAL, and POSTING
If you want to have a transaction status, where should the status column be?
Status should be in the Journal table
Status should be in the Posting table
please explain your choice, thanks.
Simple, but trick question? There is no requirement for a success/failure status because a JOURNAL is a logical unit of work, and all of its POSTINGs are part of that unit of work. Therefore the JOURNAL and its POSTINGS either exist, if the logical unit of work is successful, or they don't exist if the unit of work is unsuccessful.
This simple test (it's there because it worked or it's not there because it didn't) is a consequence of the fact that there is a business requirement to ensure that JOURNAL includes a candidate key comprised of an unbroken sequence of numbers, which is necessary because it gives auditors a false sense of security.
In a real-world system, there would be a second set of tables, along the lines of PENDING_BATCH, PENDING_JOURNAL and PENDING_POSTING which would contain transactions that haven't been completed yet. It would make sense to keep various kinds of status information here. The transaction status for pending transactions belongs on the PENDING_JOURNAL table because the whole journal and all of its postings must either succeed or fail as a unit, so the status of the unit should be normalized to the parent record (i.e. PENDING_JOURNAL).

Resources