我是通过查询创建数据库和表还是手动创建Web应用程序? [英] Do I create database and tables through queries or manually for a web app?

查看:93
本文介绍了我是通过查询创建数据库和表还是手动创建Web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该手动还是通过查询创建表格?我的意思是说我有一个记录高度和重量的页面,我希望将值存储在测量表中,我应该在命令行中创建表,还是应该编写创建表查询来创建表if if我的节点server.js中不存在该表?



先谢谢了。



< b>我尝试了什么:



我尝试在命令行中创建表并通过服务器查询,只是想知道哪种方式是这样的它应该是。

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.

推荐答案

这是一个偏好的问题。



这些是我的意见

*您最好使用 CREATE 语句

*太多新程序员依赖在ORM上处理所有DB.

*了解SQL的程序员更值得
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


通常表是永久对象,在使用之前创建和设置一个程序sta RTS。基于此,我个人会避免在使用它的程序中创建表。



此外,表创建可能包含使用该表不在程序范围内的几个方面。例如

- 物理存储布局

- 索引策略

- 特权等



您是否应该使用可视化工具或DDL脚本创建表格是一个意见问题。最重要的是,您了解需要考虑的所有方面。但是,收集此类知识的最佳方法通常是使用DDL语句。



有一点是,您是否需要在多个数据库中创建相同的表。如果这样做,那么手动创建DDL脚本可以节省以后操作的时间。当然,大多数数据库都允许对表进行脚本编写,但脚本的内容和格式可能并不完全符合您的要求,尤其是在您更改现有表时。
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.


感谢您的回复。我问的原因是我第一次创建一个动态的系统。它可以根据系统的最终目标更改或创建表。我想知道我应该创建表并将其保留在那里,它是否被使用是另一个故事,或者我应该让系统根据用户请求创建表。您的回复对我有益,100%。
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%.


这篇关于我是通过查询创建数据库和表还是手动创建Web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆