Wednesday, December 21, 2016

FAQ – Day 1 : What are the Properties of the Relational Tables?

Frequently Asked Questions – Day 1


Relational tables have following six properties:


Values Are Atomic

In RDBMS, the columns in a relational table are not repeating group or arrays. The benefit of the one value property is that it simplifies data manipulation logic. Such tables are referred to as being in the “First Normal Form” (1NF).

Column Values Are of the Same Kind

In RDBMS terms this means that all values in a column come from the same domain. A domain is a set of values which a column may have. This property simplifies data access because developers and users can be certain of the type of data contained in a given column. It also simplifies data validation. Because all values are from the same domain, the domain can be defined and enforced with the Data Definition Language (DDL) of the database software.

Each Row is Unique

This property ensures that no two rows in a relational table are identical; there is at least one column, or set of columns, the values of which uniquely identify each row in the table. Such columns are called primary keys. This property guarantees that every row in a relational table is meaningful and that a specific row can be identified by specifying the primary key value.

The Sequence of Columns is Insignificant

The benefit of this property is that it enables many users to share the same table without concern of how the table is organized. It also permits the physical structure of the database to change without affecting the relational tables.

The Sequence of Rows is Insignificant

This property is analogous the one above but applies to rows instead of columns. The main benefit is that the rows of a relational table can be retrieved in different order and sequences. Adding information to a relational table is simplified and does not affect existing queries.

Each Column Has a Unique Name

Columns must be referenced by name. A column name need not be unique within an entire database but only within the table to which it belongs.

Tuesday, December 20, 2016

FAQ – Day 1 : What is RDBMS?

Frequently Asked Questions – Day 1

RDBMS stands for Relational Database Management System. 

A Relational database management system (RDBMS) is a database management system (DBMS) that is based on the relational model as introduced by E. F. Codd.

RDBMS data is structured in database tables, fields and records. Each RDBMS table consists of database table rows. Each database table row consists of one or more database table fields. 

RDBMS also provide relational operators to manipulate the data stored into the database tables. Most RDBMS use SQL as database query language.

The most popular RDBMS are MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access.

Friday, December 16, 2016

Count the number of tables in the SQL Server database.

Count the number of tables in the SQL Server database:

Using below SQL query to fetch the total number of table in the SQL Server database:

Use Your_DataBaseNameSelect * from INFORMATION_SCHEMA.TABLES

Here you get total count of table(base table, view).



If you want fetch count of only TABLE in the database, write below query:

Select * from INFORMATION_SCHEMA.TABLESWhere TABLE_TYPE='BASE TABLE'



If you want fetch count of only VIEW count in the database, write below query:

Select * from INFORMATION_SCHEMA.TABLESWhere TABLE_TYPE='VIEW'

Tuesday, December 13, 2016

Delegate : Access method from parent page(aspx) to child page(control) using delegate.

Delegate : How to access method from parent page(aspx) to child page(control) using delegate.


Here i want to call function from parent page to child page. Here i have gridview at aspx(Detail.aspx) page. Also bindgrid() method having on code page. And i have create control on this page, at that control page i want reload bindgrid() method to refresh the gridview.

Method to bindGrid() at parent (aspx) page as below:
private void bindGrid()
        {
            DataTable dt = new DataTable();
            dt = _clsDetail.GetData();
            if (dt != null && dt.Rows.Count > 0)
            {
                gvDetail.DataSource = dt != null && dt.Rows.Count > 0 ? dt : null;
                gvDetail.DataBind();
                ViewState["gvDetail"] = dt != null && dt.Rows.Count > 0 ? dt : null;
            }
        }

For this functionality i have create a delegate, having no parameter on control page like:

        public delegate void delegate_name();
        public event delegate_name event_name;

Example:
        public delegate void DataSaveCalled();
        public event DataSaveCalled DataSaved;

And here i have call this DataSaved function after DetailSave button click as below at control page:

protected void btnDetailSave_Click(object sender, EventArgs e)
        {
            try
            {
                string strout = "";
                bool status = false;
                _clsDetail.add_Detail(out strout, out status);

                if (status == true)
                {
                    lblMsg.Text="Request added successfully.";

                    //To access the bindGrid() method here:
                    if (DataSaved != null)
                    {
                        DataSaved();
                    }
                }
                else
                {
                    lblMsg.Text="Request not added.";
                }
            }
            catch (Exception ex)
            { throw ex }
        }

Now i assign that method from parend (aspx) page to control page using define delegate at child (control) page like:

At Page_Load() of parent (aspx) page:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                control_name.event_name += new Controls.control_name.delegate_name(assign_function_to_call);
            }
        }

Example:
protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ccShowRequest.DataSaved += new Controls.Detail.OnDataSaveCalled(bindGrid);             
            }
        }

This is all about delegate, That you want to access method from parent page(aspx) to child page(control).

Wednesday, December 7, 2016

Concatenating Column Values into a Comma-Separated List into SQL Server

Here i am telling about concatenating column value into comma-separated list as below:

Declare @AllEmail AS VARCHAR(8000),@Position int=3
Declare @t table (ID int identity,EmailID nvarchar(200))
Insert into @t(EmailID)
Select distinct(EmailID) From Employee Where 
Position=@Position AND IsActive=1 AND IsDeleted=0
SELECT @AllEmail = ISNULL(@AllEmail +';','') + EmailID FROM @t
SELECT @
AllEmail 
Here you get output at resultset as comma separated email id.