How to do Normalization? [closed] - sql

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.

Related

Looking for a collection of data with no clear pattern [closed]

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 9 years ago.
I am trying to run a query to search for a collection of data with no clear pattern, in fact it conflicts with an existing pattern.
The solution I have in mind is to run the query with an AND for all the data that does have a pattern(let's assume every other record follows pattern, except for what i am looking for, so it's basically scattered with no clear way of putting it together) and them what's left over, can be retrieved and displayed.
The solution I have in mind is to run the query with an AND for all
the data that does have a pattern
Well, if you want to find everything that doesn't follow any pattern just enclose all the patterns within brackets and combine with boolean AND.
Then just put a NOT outside the brackets.
Example:
select * from data where
NOT (CONDITION1 AND CONDITION2 AND...AND CONDITION_N)
I imagine your conditions are statements such as string comparisons using like (and wildcards) in addition to arithmetic comparisons.

How can I represent this idea to the database design? [closed]

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.

Show data from multiple tables by date and time [closed]

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.

RoR - How To Count & Display Comments [closed]

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.

What is the best design for these data base tables? [closed]

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