Monday, August 16, 2010
Hacking Security Considerations by Vatsal patel
Security Considerations
Probably the most overlooked aspect of database design is security, when it should be a
major consideration. By not securing your database and thereby your data, you are asking
for trouble. Not all data is intended for everyone’s eyes, and not everyone should have the
ability to manipulate your data and definitely not your database’s structure. The majority of
your database users will only need and should only be granted read (or select) access. When
designing your database, you should establish a list of policies and users for your database.
A database user is anyone who needs access to any part of your database. The highest level
of user is the database administrator who will have access to all database objects and data.
Other users will only have access to certain objects and data. The average end user will only
have access to certain objects, but should never have the ability to alter your database
structure. It never ceases to amaze us how many organizations have one “global” user that
has complete control of the database. This is typically a bad scenario, not because people
are intentionally malicious, but because they are people and no one is perfect. The impact
of a simple mistake can take hours and even days to reverse, if reversal is possible at all.
Policies are basically rules that define which actions a user can perform on your database.
Most RDMSs enable you to assign a separate set of policies, or rights, for each object in your
database. User rights generally fall into one of six different categories:
SELECT enables the user to view data.
INSERT enables the user to create new data.
UPDATE enables the user to modify existing data.
DELETE enables the user to delete data.
EXECUTE enables the user to execute a stored procedure.
ALTER enables the user to alter database structure.
REVIEW
In order to have a truly active Web site, you need to have some sort of data store from
which to retrieve personalized information. In most cases, this “data store” is a relational
database management system (RDBMS) such as SQL Server, Oracle, or Microsoft Access. A
database can consist of many types of objects such as tables and constraints. Designing the
structure of your tables (and other objects) and their interactions is just as much art as it is
science. However, the database normalization rules provide good guidelines to help you
along your way.
QUIZ YOURSELF
1. What is the importance of the primary key in table design? (See “Designing
a Database.”)
2. What is the difference between a primary key and a foreign key? (See “Designing
a Database.”)
3. What is the purpose of normalization? (See “Normalization of Data.”)
Creating a Database
The first step in building a database with SQL Server is to actually create the database. That’s
right. SQL Server is a piece of software that runs on a computer, or server. Once the SQL Server
software is installed you can create a database (or databases) with the SQL Server software
that is then managed by that SQL Server software. Many people refer to SQL Server as a
database, which it is, sort of. SQL Server is actually an application, a Relational Database
Management System (RDBMS), which can contain multiple databases.
We will be using SQL Server 7.0 to create the database in this session. If you
are using SQL Server 2000, the steps will be slightly different.
OK, let’s create the Music database. You’ll start by creating the database using Enterprise
Manager and perform the following steps:
1. Expand the SQL Server Group item, if it isn’t already expanded, in the Enterprise
Manager tree. Once expanded you should see a list of SQL Servers that are registered
with Enterprise Manager.
2. Right-click the SQL Server in which you want to create the Music database.
3. Select New➪Database. Figure 4-1 illustrates steps 1, 2, and 3.
4. You see the Database Properties dialog box, shown in Figure 4-1. On the General
tab, enter Music in the Name field. The Database Properties dialog box allows you
to control other features of your database such as file growth, maximum database
size, transaction log files, and so on. For the sake of brevity, accept the defaults.
Figure 4-1 Specifying database properties with Enterprise Manager
That’s it. You have created a SQL Server database using Enterprise Manager. If you want
to create
1. Select Start➪Programs➪Microsoft SQL Server➪Query Analyzer to open SQL
Server’s Query Analyzer.
2. You see the Connect to SQL Server dialog box. Select the SQL Server on which you
would like to create the Music database from the SQL Server drop-down box. Select
the Use SQL Server authentication radio button. Now enter the appropriate authentication
information in the Login Name and Password fields as shown in Figure 4-2.
3. In the Query Analyzer window, enter the following T-SQL statement:
USE master
GO
CREATE DATABASE Music ON PRIMARY
( NAME = MusicData,
FILENAME = ‘C:\MSSQL7\data\MusicData.mdf’
)
In the previous script, you may need to alter the FILENAME string so that it
reflects a valid path on your computer.
In step 3, you essentially created a database named Music and specified that the data
should be stored in the MusicData.mdf file located, in this example, in the C:\MSSQL7\data
directory. The CREATE DATABASE statement accepts many other parameters, such as
MAXSIZE, FILEGROWTH, SIZE, and so on. However, again, for the sake of brevity, you used
the SQL Server defaults.
Once you have entered the previous SQL statement in the Query Analyzer
window, hit the F5 button, which will execute the SQL script.
Note
Normalization of Data by vatsal patel
Now let’s take a moment to review and validate the design of the t_bands table. Generally,
to validate the design of our table, it’s a good idea to ensure that it is normalized.
Normalization is the process of organizing data into related tables. By normalizing your
data, you are effectively attempting to eliminate redundant data in your database. Several
rules have been established for the normalization of data. These rules are referred to as
normalization forms. The first three normalization forms are:
First Normal Form (FNF): This rule states that a column cannot contain multiple
values. If you further inspect t_bands for FNF compliance, you should come to the
conclusion that the albums and members fields, band_albums and band_members,
should be broken down into smaller, discrete elements. The band_members and
band_albums columns are currently defined such that if a band has multiple members
or have released multiple albums, then band_members and band_albums
columns will contain multiple values.
Second Normal Form (SNF): This rule states that every non-key column must
depend on the entire key, not just the primary key. Because you are using band_id
as your primary key, you are in good shape with respect to SNF.
Third Normal Form (TNF): This rule is very similar to the SNF rule and states that
all nonkey columns must not depend on any other nonkey columns. A table must
also comply with SNF to be in TNF. OK, you pass this test too!
There are three other normalization rules that aren’t covered here. Generally, if your
tables are in Third Normal Form, they probably conform to the other rules.
To fully optimize your tables, you should take some additional measures. It’s a good idea
to break your t_bands table into several tables and link them to t_bands via foreign keys.
Also, you should create a t_music_types table that holds all the possible music types. The
t_bands table should have a foreign key to the primary key of the t_music_types table.
This is generally good practice for two reasons: (1) it ensures that your band’s music type
falls into the music type domain and (2) it is easier to maintain. For example, if you change
your mind and want to refer to “R&B” as “Rhythm & Blues,” you won’t have to change every
instance of “R&B” in the band_music_type_title column—you only need to change
the music type title in the t_music_types table. You could also do the same thing for
the band_record_company_title and contact_business_state fields.
At this point, your database contains three tables: (1) t_bands, (2) t_music_types, and
(3) t_record_companies. Figure 3-2 shows a diagram of our new database design:
Figure 3-2 Database design showing relationship of three tables
In the diagram in Figure 3-2, t_bands is linked to t_music_types via a foreign key to
music_type_id and linked to t_record_companies via a foreign key to record_company_id.
This new relationship between the tables is called one-to-many. In a one-to-many relationship,
each entry in the contact type table may be referenced by one or many contacts.
You now have three tables and have met your current requirements. However, what about
bands and albums? Currently, you are storing all of the band’s albums and members in a single
column, band_albums and band_members, respectively. Currently, if you wanted to
retrieve a list of a band’s members or albums, you would need to retrieve the data in the
band_members or band_albums column and parse it. This is not the optimal approach. The
best approach for this situation is to further normalize your database by creating two new
tables. The first is a table to store all albums (for example, t_albums) and a second that
stores all band members (for example, t_band_members). The tables t_albums and
t_band_members will have foreign keys to the t_bands table. Figure 3-3 shows the new
database diagram.
Diagram of expanded table design
You could certainly modify your table design further. But at some point you need to start
considering performance. Performance can be adversely impacted if, on a regular basis, you
need to join multiple tables with a lot of data. We recommend that you keep the number of
tables in your database to a minimum while following the normalization rules as closely as
possible. You will soon learn that database design is as much art as it is science.
Designing a Database by vatsal patel
Designing a Database
We believe that the best way to learn is by doing—so, let’s start building a database. We
will be using SQL Server 7.0, but you can use anything you like. The important thing to take
away from this session is not only how to build a SQL Server database, but rather how to
design and build a database. Use the RDBMS with which you are most comfortable. If you
are a novice, try using Microsoft Access. Access is generally not the RDBMS of choice as the
back end for a high traffic Web site, but it’s a good program to start with.
In the remainder of this session, we will show you how to build a music catalog
database—band names, band members, albums, and so on. For this purpose, you need to
know what information, or data elements, your database will store. For example, you may
want to gather the following information about a band:
1. Band Title
2. Music Type Title (the type of music a band plays, for example, Rock & Roll)
3. Record Company Title
4. Albums
5. Band Members
Next, you need to determine the data type for each element. The data type specifies the
kind of information (numeric, character, and so on) and how much space that information
takes up in a particular column. Though each RDBMS handles data types differently, you are
likely to encounter at least three—characters, integers, and dates—as described in Table 3-1.
Table 3-1 RDBMS Data Type Categories
Data Type SQL Server Data Type Comments
Character char(n), varchar Stores character information such as a
contact’s first name.
Integer int, smallint, tinyint Stores integer values such as a contact’s age.
Integers can also be used to store foreign key
values. We’ll get to that later.
Date datetime, smalldatetime Store dates and times such as time stamp
information.
Next, you have to decide which data type to assign to each band item. At the same time,
you need to determine which elements are optional and which are required (see Table 3-2)
and how much space each element will occupy in the database. For example, you can reasonably
assume that a band’s name won’t exceed fifty characters in length. So you specify
in the database design that the column should not accept data elements that are longer
than 50 characters in length. Data types represent the kind of data that can be stored in a
particular column. For example, if you want to store a band’s name, you will store character
data. If you want to store the number of members in the band, you would store the data
as a number or integer. Each RDMS supports different data types. SQL Server, for instance,
provides VARCHAR and CHAR among other data types to store character data, and INT and
FLOAT among others to store numeric data.
Table 3-2 does not present an optimal table definition. It is merely a starting
point from which to begin discussion. Database normalization techniques will
be explored later in this session.
Armed with this information, you can now create your table. Follow a standard naming
convention when creating table and column names. For example, you may choose to always
name your tables using the following convention:
t_[plural object descriptor]
Since the table you are creating will contain a record, or row, for each band, choose
t_bands as the table name. Use the following convention to name columns:
[singular object descriptor]_[column descriptor]Your RDBMS should be structured to create a unique identifier for each record. For example,
the first band could be assigned a unique identifier of 1, the second, 2, and so on. In
Oracle, this is called a sequence, in SQL Server it is referred to as an identity. You should
generally make this unique identifier the table’s primary key. A primary key is a field or
group of fields that uniquely identifies a record.
.NET tools by vatsal patel
.NET Tools
Visual Studio .NET and the Microsoft .NET Framework supply a complete solution for developers
to build, deploy, and manage Web Services. The .NET Tools maximize the performance,
reliability, and security of Web Services.
Visual Studio .NET is the next generation of Microsoft’s multi-language development
environment. Visual Studio .NET will help developers quickly build Web Services and applications
(including ASP.NET applications) using their language of choice. Visual Studio .NET
advances the high-productivity programming languages Visual Basic, which includes new
object-oriented programming features; Visual C++, which advances Windows development
and enables you to build .NET applications; and C# (pronounced C sharp).
The .NET Framework is a high-productivity, standards-based, multi-language application
execution environment that handles the essential “house keeping” chores and eases
deployment and management. It provides an application execution environment that
manages memory, addresses, versioning issues, and improves the reliability, scalability, and
security of applications. The .NET Framework consists of several parts, including the
Common Language Runtime and ASP.NET.
REVIEW
ASP is relatively new Web development technology. Although it is very powerful and simple
to use, it does has some flaws. With ASP.NET, Microsoft has introduced a new Web development
platform that addresses many, if not all, of ASP’s shortcomings. ASP.NET offers many
programmatic improvements including a new data access technology called ADO.NET.
ADO.NET is designed to work on the Web, which is inherently disconnected. ASP.NET and
ADO.NET are part of larger framework, generically referred to as the .NET Framework. The
.NET Framework is a set of products and services designed to facilitate the development of
interoperable Web applications based on open standards such as SOAP, XML, and HTTP.
QUIZ YOURSELF
1. What is the function of TCP/IP? (See “Internet Standards.”)
2. What are two problems when developing ASP applications? (See “The Evolution
of ASP.”)
3. What are two improvements provided by ASP.NET over ASP? (See “The Benefits of
ASP.NET.”)
Learning the basics of Structured Query Language
The key to developing an active Web site is data. Data is basically unstructured information
such as a name, address, or user preference (a favorite color, for example). When
you think about it, as Information Technologists, all we do is move data from one place
to another and present it in different formats. There are many different types of data,
including numbers, strings, and dates. For example, the number 30 might represent age, the
string “Jason Butler” might present a name, and 1/1/2000 might represent a date.
A dynamicWeb site starts with a database. This is where information—that is, a collection
of related data elements—is stored, modified, and transmitted. There are many databases
on the market, including Microsoft Access, SQL Server, and Oracle. The type of database you
choose as the back end (or database that supports an application) for your site ultimately
depends on the size and security requirements of your company, as well as your budget.
There are two types of data: (1) relational and (2) non-relational. The difference between
the two is how the data is organized. This session focuses on relational data. Relational
data is stored in a Relational Database Management System (RDBMS). The information in
relational databases is often presented in tables. Tables are created by grouping related data
in columns and rows. When necessary, tables are related back to each other by the RDBMS.
Code written using the .NET Common Language Runtime, is said to be
managed code. Code that does not use this infrastructure is referred to as
unmanaged code.
.NET offers many programmatic improvements and features, one of which is a new version
of ActiveX Data Objects (ADO) called, not surprisingly, ADO.NET. ADO.NET provides a suite of
data handling and binding facilities. The Web is an inherently disconnected environment: a
Web application connects to a datasource, manipulates the data, reconnects to the datasource,
and updates the data. ADO.NET has been designed to work in a disconnected fashion,
which increases data sharing. Additionally, ADO.NET treats data in a very loose,
multidimensional, object-oriented way through a strongly typed object model. With ADO, all
data is represented in two dimensions, rows and columns. With ADO.NET these n-dimensional
data representations of data are called datasets. Iterating through, updating, and
deleting related tables in a dataset is exceptionally simple.
What Is .NET?
With .NET, Microsoft is formalizing a vision of an Internet made up of an infinite number of
interoperable Web applications or services, which will operate in concert to form a global
exchange network. The .NET Framework is really a strategy to tie disparate platforms and
devices together, moving data around in a far more efficient manner than it is currently.
.NET is Microsoft’s platform for Web Services. Web Services allow applications to communicate
and share data over the Internet, regardless of operating system or programming language.
The Microsoft .NET platform includes a comprehensive family of products, built on
Internet standards such as XML and HTTP, that provide facilities for developing, managing,
using, and experiencing XML Web services. There are five areas where Microsoft is building
the .NET platform: .NET Experiences, Clients, Services, Servers, and Tools.
.NET Experiences
.NET Experiences are XML Web services that enable you to access information across the
Internet and from standalone applications. Microsoft will deliver .NET Experiences for individuals
and for businesses. Some of the products that Microsoft is transitioning into .NET
Experiences are the Microsoft Network (MSN) and bCentral.
.NET Clients
.NET Clients are PCs, laptops, workstations, phones, handheld computers, Tablet PCs, game
consoles, and other smart devices. All of these devices will have the ability to consume Web
Services. .NET Clients use software that supports Web Services, and enable you to access your
data regardless of location or type. The .NET client software Microsoft will offer includes
Windows CE, Window 2000, and Windows XP. These applications will power PCs, laptops,
workstations, smart phones, handheld computers, and Tablet PCs.
.NET Services
In addition to developers creating XML Web services, Microsoft is creating a core set of services
that perform routine tasks and act as the backbone for developers to build upon. The
first set of Web Services being built, codenamed “HailStorm,” is user-centric services focused
on users, rather than devices, networks, or applications. “HailStorm” is based upon the
Microsoft Passport user authentication system. With “HailStorm,” users receive relevant
information, as they need it, delivered to the devices they’re using, and based on their
established preferences.
.NET Servers
The .NET Servers, including the Windows 2000 server family, make up Microsoft .NET’s
server infrastructure for developing, deploying, and managing Web Services. Designed with
performance in mind, the .NET Servers will provide enterprises with the resources required
to integrate their systems, applications, and partners via Web Services. The .NET Enterprise
Servers are
SQL Server 2000 to store, retrieve, and analyze relational data.
Application Center 2000 to deploy and manage highly available and scalable Web
applications.
BizTalk Server 2000 to build XML-based business processes across applications and
organizations.
Commerce Server 2000 for quickly building scalable e-commerce solutions.
Content Management Server 2001 to manage content for dynamic e-business Web
sites.
Exchange Server 2000 to enable messaging and collaboration.
Host Integration Server 2000 for integrating data and applications on legacy systems.
Internet Security and Acceleration Server 2000 for establishing secure, fast Internet
connectivity.
Mobile Information 2001 Server to enable application support for mobile devices.
SharePoint Portal Server 2001 to publish business information.
Subscribe to:
Posts (Atom)




