Search This Blog

Oct 31, 2011

Using SQL to work with Database Data



Database is often the heart of a web site you need to consider very carefully its design. This is because we will have many pages accesing to the database and it will be hard to make changes such as removing tables or renaming columns
Always consider the primary key for your table, In my case I prefer to give each table a column called Id.
Give always to your tables and columns logical names. Avoid characters such as spaces, underscores, and dashes. For example a name like EmployeeID is much easier to read than Employee_ID_3
Always create create relationships between tables when appropriate. With proper relationships you minimize the change of ending up with orphaned or incorrect data.

Don't use SELECT * to get all columns from a database. By suing SELECT * you may be selecting more columns that you actually need.
Remember this word CRUD for Create, Read, Update and Delete that are operations against the database.
Try to take advance of all the tools provided by VWD(Visual Web Developer) that enables you interact with the database. This tools can be: DatagridView, DetailsView, SqlDataSource and others.