Showing posts with label constraint. Show all posts
Showing posts with label constraint. Show all posts

Wednesday, March 21, 2012

Is this A Valid Table Schema

GO

CREATE TABLE [dbo].[CmnLanguage]
(
[Id] [char](2) NOT NULL CONSTRAINT PkCmnLanguage_Id PRIMARY KEY,
[UniqueName] [varchar](26) NOT NULL,
[NativeName] [nvarchar](26) NOT NULL,
[DirectionType] [smallint] NOT NULL,
[IsVisible] [bit] NOT NULL,
[CreatedDateTime] [datetime] NOT NULL DEFAULT GETDATE(),
[ModifiedDateTime] [datetime] NULL
)

GO

CREATE TABLE [dbo].[CmnLink]
(
[Id] [int] IDENTITY(1,1) NOT NULL CONSTRAINT PkCmnLink_Id PRIMARY KEY,
[UniqueName] [varchar](52) NOT NULL,
[IsVisible] [bit] NOT NULL,
[CreatedDateTime] [datetime] NOT NULL DEFAULT GETDATE(),
[ModifiedDateTime] [datetime] NULL
)

GO

CREATE TABLE [dbo].[CmnLinkCmnLanguage]
(
[LinkId] [int] NOT NULL CONSTRAINT FkCmnLinkCmnLanguage_LinkId FOREIGN KEY (LinkId) REFERENCES CmnLink(Id) ON DELETE CASCADE,
[LanguageId] [char](2) NOT NULL CONSTRAINT FkCmnLinkCmnLanguage_LanguageId FOREIGN KEY (LanguageId) REFERENCES CmnLanguage(Id) ON UPDATE CASCADE ON DELETE CASCADE,
[CreatedDateTime] [datetime] NOT NULL DEFAULT GETDATE(),
[ModifiedDateTime] [datetime] NULL
)

Well, thats not really a schema at all. Thats a script. Sometimes also called a Create Script or Change script. I suppose someone may refer to it as a schema since it really is a deffinition of a set of tables (3 of them)

Try it out, see if it works. Run this inside a project and see if your tables and relationships get generated correctly.

|||

I already test it. But I am asking Is it valid in respect of rules.

|||

I think what you're asking is: Does it follow best pratices. There's no way for us to know what rules you'd like it to follow, but best pratices are kind of dictated by the most elegant way of doing something.

I've run your scripts on a database, and had it create the three tables, and 2 relationships. I'm not quite sure what you're trying to accomplish. It appears to be some sort of localization mapping set of tables, but I am not sure I understand why the CmnLinkCmnLanguage table exists, it doesnt make sense to me why it's there?

Could you explain further what you're end goal is, and what you hope to accomplish with these sets of tables?

|||

Ok I will explain it from start.

I am working on a completely multilingual website.

Now at this point I am working on Database end.

As this is a multilingual website so I need the Language Table as show below.

----------

Language

----------

Id

RomanName

NativeName

Direction

IsVisible

----------


Next.

I have Book Table.

----------

Book

----------

Id

RomanName

NativeName

IsVisible

----------

Every thing is fine till here.

But I have a limited type of Books and each book is avalaible in different languages.

For Example I add a book translated in Arabic, Urdu and English.

These three books have different ID. But these are the translation of Same book.

And when I have this Book in Urdu By default. And need all the available languages for this book then problem occurs.

To resovle this issue I modify the Book Table and break it into 2 Tables.

----------

Book

----------

Id

RomanName

IsVisible

----------

----------

BookNative

----------

BookId

LanguageId

NativeName

----------


Then an ID will assign for the book and all available language editions have not the ID.

At this end the above mentioned goal will got.

But I explain it on another post

http://forums.asp.net/t/1145293.aspx

And they replied its not correct.

Then again I think it for some time.

And another solution will come in mind.

That make a single Table for Book

----------

Book

----------

Id

Name

IsVisible

BookGroupID

----------

And for the above mentioned goal make a separate BookGroup Table


----------

BookGroup

----------

Id

Name

IsVisible

----------

After this solution Book Table is alone.


That was all the story.

Hope you will pick it.

And reply me with some great idea.


Waiting for your reply.

Monday, February 20, 2012

Is there any difference between Integrity and Constraint ?

For an EDMS application, there are two separate tasks for maintaining Data
Integrity and Constraint for the DB.
From my understanding, the Constraint is already includes the Referential
Integrity, is there any other meaning for Data Integrity ?
Your advice is sought.Hi,
You are correct; The data integrity itself is maintained using contraints.
Take a look into the below URL.
http://www.utexas.edu/its/windows/d...ing/rm/rm5.html
Thanks
Hari
SQL Server MVP
"John" <John@.discussions.microsoft.com> wrote in message
news:OL3Ha9OyGHA.1340@.TK2MSFTNGP05.phx.gbl...
> For an EDMS application, there are two separate tasks for maintaining Data
> Integrity and Constraint for the DB.
> From my understanding, the Constraint is already includes the Referential
> Integrity, is there any other meaning for Data Integrity ?
> Your advice is sought.
>
>|||Data integrity is a broad concept, being a desirable characteristic of
any database. It relates to the consistency, accuracy and validity of
the data.
Referential integrity is only one aspect of integrity. Referential
integrity is usually enforced using foreign key constraints, but can
also be enforced (with less performance and/or safety) using triggers
or other mechanisms (for example on the application side).
The constraints are rules or restrictions that are enforced at the
database level. There are several types of constraints:
- primary key constraints (that ensure entity integrity)
- foreign key constraints (that ensure referential integrity)
- check constraints (that ensure domain integrity and some simple
business rules)
More complex business rules are usually enforced using triggers.
For more informations, see:
http://msdn2.microsoft.com/en-us/library/ms184276.aspx
https://www.cs.tcd.ie/courses/baict...s/integrity.pdf
Razvan
John wrote:
> For an EDMS application, there are two separate tasks for maintaining Data
> Integrity and Constraint for the DB.
> From my understanding, the Constraint is already includes the Referential
> Integrity, is there any other meaning for Data Integrity ?
> Your advice is sought.|||Dear Razvan,
In other words, Data Integrity test may be testing of whether the data is
valid (for instance, within the valid range) .... while constraints test
may be checking the referential integrity ?
Thanks
"Razvan Socol" <rsocol@.gmail.com> wrote in message
news:1156605409.337915.44370@.75g2000cwc.googlegroups.com...
> Data integrity is a broad concept, being a desirable characteristic of
> any database. It relates to the consistency, accuracy and validity of
> the data.
> Referential integrity is only one aspect of integrity. Referential
> integrity is usually enforced using foreign key constraints, but can
> also be enforced (with less performance and/or safety) using triggers
> or other mechanisms (for example on the application side).
> The constraints are rules or restrictions that are enforced at the
> database level. There are several types of constraints:
> - primary key constraints (that ensure entity integrity)
> - foreign key constraints (that ensure referential integrity)
> - check constraints (that ensure domain integrity and some simple
> business rules)
> More complex business rules are usually enforced using triggers.
> For more informations, see:
> http://msdn2.microsoft.com/en-us/library/ms184276.aspx
> https://www.cs.tcd.ie/courses/baict...s/integrity.pdf
> Razvan
> John wrote:
>|||The particular meanings of the terms "Data integrity test" and
"Constraints test" in a particular software may be different of what we
think about them. Please consult the user manual of that software or
contact the product support to get specific information.
Razvan
John wrote:
> Dear Razvan,
> In other words, Data Integrity test may be testing of whether the data is
> valid (for instance, within the valid range) .... while constraints test
> may be checking the referential integrity ?
> Thanks

Is there any difference between Integrity and Constraint ?

For an EDMS application, there are two separate tasks for maintaining Data
Integrity and Constraint for the DB.
From my understanding, the Constraint is already includes the Referential
Integrity, is there any other meaning for Data Integrity ?
Your advice is sought.Hi,
You are correct; The data integrity itself is maintained using contraints.
Take a look into the below URL.
http://www.utexas.edu/its/windows/database/datamodeling/rm/rm5.html
Thanks
Hari
SQL Server MVP
"John" <John@.discussions.microsoft.com> wrote in message
news:OL3Ha9OyGHA.1340@.TK2MSFTNGP05.phx.gbl...
> For an EDMS application, there are two separate tasks for maintaining Data
> Integrity and Constraint for the DB.
> From my understanding, the Constraint is already includes the Referential
> Integrity, is there any other meaning for Data Integrity ?
> Your advice is sought.
>
>|||Data integrity is a broad concept, being a desirable characteristic of
any database. It relates to the consistency, accuracy and validity of
the data.
Referential integrity is only one aspect of integrity. Referential
integrity is usually enforced using foreign key constraints, but can
also be enforced (with less performance and/or safety) using triggers
or other mechanisms (for example on the application side).
The constraints are rules or restrictions that are enforced at the
database level. There are several types of constraints:
- primary key constraints (that ensure entity integrity)
- foreign key constraints (that ensure referential integrity)
- check constraints (that ensure domain integrity and some simple
business rules)
More complex business rules are usually enforced using triggers.
For more informations, see:
http://msdn2.microsoft.com/en-us/library/ms184276.aspx
https://www.cs.tcd.ie/courses/baict/baim/js/dbms/integrity.pdf
Razvan
John wrote:
> For an EDMS application, there are two separate tasks for maintaining Data
> Integrity and Constraint for the DB.
> From my understanding, the Constraint is already includes the Referential
> Integrity, is there any other meaning for Data Integrity ?
> Your advice is sought.|||Dear Razvan,
In other words, Data Integrity test may be testing of whether the data is
valid (for instance, within the valid range) .... while constraints test
may be checking the referential integrity ?
Thanks
"Razvan Socol" <rsocol@.gmail.com> wrote in message
news:1156605409.337915.44370@.75g2000cwc.googlegroups.com...
> Data integrity is a broad concept, being a desirable characteristic of
> any database. It relates to the consistency, accuracy and validity of
> the data.
> Referential integrity is only one aspect of integrity. Referential
> integrity is usually enforced using foreign key constraints, but can
> also be enforced (with less performance and/or safety) using triggers
> or other mechanisms (for example on the application side).
> The constraints are rules or restrictions that are enforced at the
> database level. There are several types of constraints:
> - primary key constraints (that ensure entity integrity)
> - foreign key constraints (that ensure referential integrity)
> - check constraints (that ensure domain integrity and some simple
> business rules)
> More complex business rules are usually enforced using triggers.
> For more informations, see:
> http://msdn2.microsoft.com/en-us/library/ms184276.aspx
> https://www.cs.tcd.ie/courses/baict/baim/js/dbms/integrity.pdf
> Razvan
> John wrote:
>> For an EDMS application, there are two separate tasks for maintaining
>> Data
>> Integrity and Constraint for the DB.
>> From my understanding, the Constraint is already includes the Referential
>> Integrity, is there any other meaning for Data Integrity ?
>> Your advice is sought.
>|||The particular meanings of the terms "Data integrity test" and
"Constraints test" in a particular software may be different of what we
think about them. Please consult the user manual of that software or
contact the product support to get specific information.
Razvan
John wrote:
> Dear Razvan,
> In other words, Data Integrity test may be testing of whether the data is
> valid (for instance, within the valid range) .... while constraints test
> may be checking the referential integrity ?
> Thanks