What is the best design for these data base tables? [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 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

Related

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.

What's a quick way to create SQL tables when starting out? [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 find that creating SQL tables tedious when starting to create a web app (ASP/Python/PHP).
Do you guys know any tools that makes creating tables quicker and faster and easier? Thanks in advance! :-)
In my opinion writing a CREATE TABLE statement is far less tedious than writing HTML pages.
The recommended approach is to use a ER design tool co create and define your database model. Most (if not all) ER designer can then create the necessary DDL statement directly from the model.
With this approach you also have a documentation of your database model which is always a good thing.
It depends on the tools/libraries you use to create your app.
If you use an ORM, many ORMs offer you the possibility to create the database with all tables automatically, according to the classes and mappings you defined in your application.

Very complex database architecture, how to deal with it? [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 have worked on several rails applications and now I work on a very complex one, from the database side. A lots of nested models, several polymorphyc associations...
How you deal with that complexity ? How can I know that we are working in the good direction ? What about performance issues ?
Thansk for your opinions.
First of all, you need to estimate the performance of the queries that your application runs against the database. Then you can try to optimize the queries, for example, by adding some indexes. Maybe in some cases you will also need to consider denormalizing some data to get better performance.
Performance of the queries may also depend on your data size. If you have really big data set and queries are optimal, then you may consider introducing (distributed) caching. Or if data model allows that think of partitioning your database on several nodes to improve query performance.
But still the first step should be a setup of some SQL query performance monitoring.
You should consider a NOSQL solution such as MongoDB or CouchDB. Sometimes an RDBMS is not the right tool for the job.
http://www.mongodb.org/
http://couchdb.apache.org/

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.

How to do Normalization? [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.
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.