Click here to Skip to main content
15,889,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Should I create tables by hand or by queries? What I meant is let say I have a page that records height and weight and I want the values to be stored in "measurements" table, should I create the table in a command line or should I write a create table query to create table if the table doesn't exist in my node server.js?

Thanks in advanced.

What I have tried:

I have tried creating table in command line and through queries by server, just wanted to know which way is the way that it should be.
Posted
Updated 18-Dec-18 17:14pm

This is a matter of preference.

These are my opinions
* You are better using CREATE statements
* Too many of the newer programmers rely on ORM's to take care of everything DB.
* A programmer who knows SQL is worth more
 
Share this answer
 
Typically tables are permanent objects, created and set up before the usage of a program starts. Based on that, I personally would avoid creating a table in a program that uses it.

Furthermore a table creation may contain several aspects that are not in the scope of the program using the table. For example
- Physical storage layout
- Indexing strategy
- Privileges etc.

Should you create the table using a visual tool or a DDL script is a matter of opinion. The most important thing is that you know all the aspects you need to take into account. However, very often the best way to gather such knowledge is to use DDL statements.

One thing is, do you need to create the same table in multiple databases. If you do, then creating the DDL script by hand may save time in later operations. Of course most of the databases allow scripting a table but the content and the format of the script may not be exactly what you want, especially if you alter existing tables.
 
Share this answer
 
Thank you for your responses. The reason that I asked is it is my first time creating a system which is dynamic. It may alter or create table based on the end goals of the system. I am wondering should I create the table and leave it there, it is being used or not is another story or I should let the system to create the table upon user request. Your responses are beneficial to me, 100%.
 
Share this answer
 
Comments
Richard Deeming 20-Dec-18 10:26am    
If you want to reply to a solution, click the "Have a Question or Comment?" button under that solution. DO NOT post your reply as a new "solution".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900