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).
Related
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.
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 7 years ago.
Improve this question
I am working on an Authorization system for a CMS. I have following table structure:
All the other tables are ok for me but i want to know about the best practice
for a GroupPermission table as described below.
Users:
UserId,Name
Groups:
GroupId,Name
GroupUser:
GroupUserId,GroupId,UserId
Modules:
ModuleId,Name
Permissions:
PermissionId,Name,ModuleId,isAllowed
Approach 1:
GroupPermission:
GPId GroupId ModuleId Permissions(var char)
1 1 1 View:true,Create:false,Delete:true,Edit:false
2 1 2 View:ture,inviceCreate:false,AssignCreate:false
Approach 2:
GroupPermission:
GPId GroupId PermissionId
1 1 1
2 1 2
3 1 3
I need your suggestion over the two approaches mentioned ,in first approach there is an advantage of only one row returned for a specific Group but i am concatenating Permissions in a string , so there would be an overhead of string parsing method,
In second approach i am using 'Id' instead of string.
since this table is the mostly used table and would effect the overall performance of application , so this table needs to be optimized to the maximum.
I have studied the databases of other Cms like word press,orchard,silver stripe etc but they only have few user and Groups tables and couldn't find anything useful for my requirement.
Any other alternate suggestions or ideas are greatly appreciated.
Go with the second, normalized approach.
Keeping delimited data in a single column is wrong in 99.999% of the cases.
Having only a single row for each group permision is not an advantage, considering the string manipulation overhead for otherwise is le selects, inserts, updates and deletes.
Just take a moment to think what if someone wants to remove a permision from a group: you will have to figure out if the group even have this permoision, and then find out where it's text starts and where it ends, cut it out of the full string, and only then update the record.
While with the normalized version all you have to do is write a simple delete statement...
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 7 years ago.
Improve this question
I am designing a database. I want to define a automatic sequence on a table primary key field. what is the best solution for it?
I know I can enable identity property for a field, but it has some problems ( for example its seed jumps on restart and unsuccessful events)
I also can use some calculated sequences. for example I can calculate max of the filed values and after incrementing use it as key for new inserted record.
which one is better? Is there another solution?
To my mind there's 3 options:
Identity - the simplest, but can have gaps when server is restarted etc.
Sequence - separate object, you will have still gaps in case of rollback
A separate table for the numbers - you won't have gaps, but it can be a hotspot that can cause blocking.
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.
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.