It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have these tables: Idea and poll (and others) which are types of what can a member post within a community. I need to show them all in the "Activity stream" ordered by time and date, so a member can see in his "Activity stream" all what others have posted whatever is the type. I've looked around and have found to use the UNION, however they said this way is too slow. I thought to create another table named posts that contains the ID of the post and its time and date, updated in each new post. But either this way costs me a new table. What do you think is the best way? Any other suggestion will be appreciated.
Yes it is, like "Tom asked a question:__ in:__ few minutes a go"
So you need a user name, an action, a timestamp and a hidden id.
Well performance-wise a separate table is better (you avoid unions and maybe joins if it's not necessary to be mormalized), but you have the extra storage (is this an issue?) and the overhead of inserting new records to this table (tiny). Be aware for the usage of a switch to get the details of each activity from its origin table.
Bottom line everything depends on the data volume and the traffic.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am new to database design, I am trying to build a database of shopping system.
Assume we have a Customer table and a Staff table.
The requirement is:
To allow part of the customers to have privilege of "Item return & refund".
To allow part of the staff to have the authority to process the refund.
My idea is to simply add a column with a Boolean value to "Flag" which customer or which staff has the authority or not?
Is that correct to solve this problem? Any potential problem?
This would be correct for a simplistic design. However, if you want to be able to expand on your website or if your needs grow over time, you may need to allow for more detailed permissions. A user_permissions table and an employee_permission table would be desirable in that case.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am creating a view and I was asked to do a 'replace' and a 'cast', so as an example:
SELECT CAST(qtyshipped AS INT) AS 'QTYShipped', REPLACE(itemval,'.','')
FROM Database
Within the view, should not actually change the information in the database but just in the query correct? (It works perfectly in my sandbox server but i just want to confirm)
Not a dumb question at all. And the answer is yes, it only changes the result of the query, the underlying data will remain the same.
That is already a good query. But I need to tell some points with you.
REPLACE function is case-sensitive. Although I've seen in your code that you are only replacing period.
Why is your column qtyshipped is not in numeric type? You should have change that into numeric. So you won't need casting which may lower the performance.
It will not affect your database since your are only executing SELECT not UPDATE.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I'm looking to have a count of the number of comments left under an article and display it on the index page beside that particular article - like the example here in red circles. Any suggestions as to how I might do this?
The picture is an example of what I'm trying to do, its not my site.
This sounds like a good candidate for Rails.cache. Every time you create a new comment simply increment that cache counter using the post id.
If the cache entry does not exist, do a simple article.comments.count (depends on your domain model of course) query and re-cache it.
Storing it in a cache is one idea, yes.
But storing it in a counter_cache column is probably a better idea. That way even if your server was restarted somehow you wouldn't loose the cached values. See http://guides.rubyonrails.org/association_basics.html, section 4.1.2.4.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Hi i am new to this concept and i need your suggestion. i have an excel spreadsheet having about 35 columns and i have to create tables out of it. i have to draw an ER diagram but i dont know which should be the main table having foreign keys of all other tables or is there going to be one main table or multiple main tables?
Normalization is a database concept - it is all about removing redundancies from your data.
There are several different normalization forms, each building on top of the previous.
First normal form - each column in a table should only hold one value, so things like a comma separated list is a no no.
To be honest, the subject matter can get very complex - see this article on how to apply normalization to a table.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I need to find the best solution to make the DB Normalized with large amount of data expected.
My site has a Table Tags (contain key word,id) and also 4 types of data related to this tags table like(articles,resources,jobs,...).
The big question is:-
for the relation with tags what best solution for optimazaion & query speed?
make a table for each relation like:
table articlesToTags(ArticleID,TagID)
table jobsToTags(jobid,tagid)
etc.
or put it all in one table like
table tagsrelation(tagid,itemid,itemtype)
I need your help. Please provide me with articles to help me in this design
consider that in future the site can conation new section relate to tag
Thanks
I would go for the normalized version of your schema (which is the table-relation). This type of schemas are very useful for scenarios where the application might grow.
The bad thing of having all the data in just one table is that if you have a bunch of attributes for both relationships, you'll end up with a table with a lot of attributes, which when growing will be slow to query, thus becoming a performance hit of your app.
So, finally the problem is to choose simplicity and quick end against well designed code considering scalability as well.
Hope I can help