Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cardinality

Author  Topic 

Mohamed Faisal
Yak Posting Veteran

51 Posts

Posted - 2012-09-24 : 01:49:57
HI All,

I have created a few tables in a database. But how do I cardinality between the tables.For example like 1:N,M:M or 1:N,M:O.
is there a code for to declare them in the tables.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-24 : 03:05:44
nope...its done by means of bridge tables ie tables having reference fields from parent tables. you can mark nature of relationship using data modelling tools

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Mohamed Faisal
Yak Posting Veteran

51 Posts

Posted - 2012-09-24 : 03:43:51
Dear visakh16,

That means there is no coding needed for in the SQL. Then why do we do the cardinality for. Is it part of the designing the database process.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-09-24 : 13:06:32
thats what I told. its a concept. the implementation is done by creating a bridge table having id fields from master table as foreign key references. The nature of relationship is specified in database model diagrams created using data modelling tools

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

klca
Starting Member

17 Posts

Posted - 2013-06-16 : 10:32:53
quote:
Originally posted by visakh16

thats what I told. its a concept. the implementation is done by creating a bridge table having id fields from master table as foreign key references. The nature of relationship is specified in database model diagrams created using data modelling tools

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





If there is no use more than showing it on a diagram, what is the big fuzz of it? It will be really good that such cardinality could be built as an integral part of your database structure (or schema) because it will give you a lot of validation and constraints that otherwise will require a lot of code in order to achieve such validation, doesn't it?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-17 : 00:55:37
quote:
Originally posted by klca

quote:
Originally posted by visakh16

thats what I told. its a concept. the implementation is done by creating a bridge table having id fields from master table as foreign key references. The nature of relationship is specified in database model diagrams created using data modelling tools

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





If there is no use more than showing it on a diagram, what is the big fuzz of it? It will be really good that such cardinality could be built as an integral part of your database structure (or schema) because it will give you a lot of validation and constraints that otherwise will require a lot of code in order to achieve such validation, doesn't it?


The cardinality is implemented by means of primary key foreign key relationships in database.. For 1 - to - 1 and 1 - to - N it simply is represented using master child tables. For M- to - N its implemented by means of a bridge table which will just have reference ids of parent tables and will have multiples per each table

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -