我一生中的大部分时间都更像是一名营销人员。然而,我最近决定换个方向,为我正在工作的一家雄心勃勃的初创公司学习编程。基本上,该项目基于社交网络元素(关注、提要、帖子、通知等),但有所不同。我想知道应该按什么顺序编写网站基础设施的代码。我认为首先在 MYSQL 中写下整个数据库架构,然后用 PHP 编写所有数据库查询,然后制作注册页面,然后用 PHP 编写网站的整个后端。这种做法正确吗?我将不胜感激您能给我的任何指示。我应该先从后端开始吗?高度可扩展的网站的哪些基础设施组件最好建议我使用 C++ 而不是 PHP 来完成?
谢谢
I have been more of a marketing guy most of my life. However, i have recently decided to shift gear and learn programming for an ambitious start-up that i am working on. Basically, the project is based on elements of social networking elements (follow, feed, posts, notifications etc) but with a twist. I wanted to know in what order should i write the code for the infrastructure of the website. I thought ill first write down the entire database schema in MYSQL, then write all database queries with PHP, followed by making the registration page and then code entire backend of the website in PHP. Is this approach correct? I will appreciate any directions you can give me. Should i first start with the backend? What are some of the infrastructure components of a high scalable website that i will be better advised to do in C++ and not PHP?
Thanks
发布评论
评论(2)
您所描述的是经典的瀑布模型。它几乎永远不会起作用,因为规范会改变,因为
因此,我建议您实施逐个功能。从一个空数据库和一个仅连接到该数据库的 php 脚本开始,然后实现一项又一项功能。
对于每个功能,确定需要添加哪些数据库字段。您可以使用现有的数据库条目或重组数据库以适应新的表和行吗?
然后,您可以同时或依次执行以下三个步骤:
严格的 MVC 和测试都不是必需的,但它们极大地简化了软件开发,并允许您确定您的代码实际上可以在生产中运行。
What you describe is the classic Waterfall Model. It almost never works, since the specifications will change because a combination of
Therefore, I'd recommend you implement feature by feature. Start with an empty database and a php script that just connects to that database, and implement one feature after the next.
For each feature, determine which database fields need to be added. Can you use existing database entries or restructure your database to accommodate the new tables and rows?
Then, you can do the following three steps concurrently or one after another:
Neither strict MVC nor tests are required, but they simplify software development a great deal and allow you to be certain that your code will actually work in production.
PHP 具有一些与 MySQL 数据库交互以及向数据库服务器发送 SQL 命令的强大功能。
您的数据库结构应该尝试获取网站的所有数据元素(用户详细信息、消息、评论等),并将这些信息分解为其最合乎逻辑和最有效的结构。这是通过将大量数据分解为逻辑和离散表来实现的,使用索引号(主键)或您希望关联每个表中的元组的任何字段(外键)进行引用。
让数据库进入这个阶段被称为第四范式(4NF)或博伊斯科德范式(BCNF)。
一旦弄清楚数据库的结构,您就可以使用 SQL 命令对其进行查询,将数据放入某个表中或检索它。
假设您使用 PHP 的
mysql_query ( string $query [, resource $link_identifier ] )
( http://www.php.net/manual/en/function.mysql-query.php )然后您可以将 SQL 数据加载到数组中,并打印出其中的数据一些 HTML。一旦你开始这样做,你可能还想使用 PHP
$_SESSION
全局变量来跟踪任何登录的用户。该全局使用 cookie 来跟踪经过身份验证的用户,对于登录用户非常有用。您需要实现一些登录代码来匹配用户名和密码,然后创建会话(如果通过)。希望有帮助! :)
PHP has got some great features for interacting with a MySQL database, and sending SQL commands to the database server.
Your database structure should attempt to take all of the data elements of your website (user details, messages, comments etc.) and break that information down into its most logical and efficient structure. This is achieved by breaking the whole lot of data into logical and discrete tables, referenced using index numbers (primary keys) or whichever fields (foreign keys) you wish to associate the tuples in each table.
Getting the database to this stage is known as 4th Normal Form (4NF) or Boyce Codd Normal Form (BCNF).
Once you have figured out the structure of your database, you can then go about querying it to either put data in some table or retrieve it, using SQL commands.
Assuming you use PHP's
mysql_query ( string $query [, resource $link_identifier ] )
( http://www.php.net/manual/en/function.mysql-query.php ) you can then load the SQL data into an array, and print out the data amongst some HTML.Once you get this going you might also want to use PHP
$_SESSION
global var to keep track of any logged in users. This global uses a cookie to track authenticated users and is very useful for logging in users. You would need to implement some logging in code to match username to password, and then create the session if it's a good pass.Hope it helps! :)