Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

How implement object orientation features in sql server? Expand / Collapse
Author
Message
Posted Thursday, December 27, 2012 9:09 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 6:17 AM
Points: 5, Visits: 13
Thanks alot.
How about polymorphism in sql? Could we use stored procedures for polymorphism?
And for nested relationships can we define an attribute as OId and use it in a select query to point to the table that we want use it in our nested relationship?
Post #1400666
Posted Thursday, December 27, 2012 9:19 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:08 PM
Points: 13,205, Visits: 12,687
tz.bahrami (12/27/2012)
Thanks alot.
How about polymorphism in sql? Could we use stored procedures for polymorphism?
And for nested relationships can we define an attribute as OId and use it in a select query to point to the table that we want use it in our nested relationship?


HUH???? How can a stored procedure be used to implement polymorphism? sql is NOT an OO programming language. It is a data storage system. It is not ever going to be this type of OO entity that you are talking about.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1400670
Posted Thursday, December 27, 2012 9:31 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 6:02 AM
Points: 7,135, Visits: 12,744
tz.bahrami (12/27/2012)
Thanks alot.
How about polymorphism in sql? Could we use stored procedures for polymorphism?
And for nested relationships can we define an attribute as OId and use it in a select query to point to the table that we want use it in our nested relationship?

It depends on what you mean by that and how you want to class your entities. In the context of a database you could contrive a qualifying description of polymorphism, but in general, no. Relational database theory is built on the notion of a relation (manifested as a table in an RDBMS) representing a specific entity, and only one. In other words you would not store cars and trees in the same table even though they both inherit from 'System.Object' (drawing on .NET object hierarchy). You might store different models of cars or species of trees where car inherits from vehicle and tree inherits from plant. Or you might want a vehicle table with properties common to cars, trucks, airplanes, etc. with child tables for each of those I mentioned. It depends on how granular you want to get.

For example say you had a table that stored types of trees (named tree) and in that table you wanted to store a deciduous tree and an evergreen. You might have a column named 'max_recorded_height' and another named 'average_life_expectancy.' However, you may not want a column called 'average_needle_length' because deciduous trees do not have needles, only evergreens do. So, you may want to create a child table to tree called evergreen that would only be referred to by objects of type evergreen (who inherit from your tree object) that was instantiated within your application so it could fill those properties that only pertained to evergreens. That said, you would still look into having those properties normalized out of the tree table since not all trees will have needles.

I would suggest you do some reading on normalization, especially normal forms, start with 3NF, and read the article about the impedance mismatch I linked to above.


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1400677
Posted Thursday, December 27, 2012 10:08 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 10:25 AM
Points: 40,385, Visits: 36,827
tz.bahrami (12/27/2012)
How about polymorphism in sql? Could we use stored procedures for polymorphism?
And for nested relationships can we define an attribute as OId and use it in a select query to point to the table that we want use it in our nested relationship?


Once again... SQL Server is not an object database. T-SQL is not an object orientated language.

While you may be able to force some OO-like features into a DB, you're very likely going to end up with a poor design and a badly performing database as a result. Keep the OO in the front end, where your language is OO and not in the database.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1400691
Posted Thursday, December 27, 2012 10:15 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 6:17 AM
Points: 5, Visits: 13
Thanks alot of your instructions.i find my answer.
Post #1400695
Posted Thursday, December 27, 2012 10:33 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Monday, November 17, 2014 12:50 PM
Points: 13,872, Visits: 9,598
There are object-oriented database engines available. Cache is one of them, for example. They have the OO properties that you are looking for. If you absolutely have to have polymorphism in a database, go with an OODBMS (Bing/Google that term if you don't know it), not with an RDBMS.

It is theoretically possible to do inheritence and polymorphism in an RDBMS. But you can't attach methods to an object, and columns aren't really properties. OODBMSs allow you to do proper inheritence, polymophism, properties, and methods. That's what they're for. They tend to be less effective at the things RDBMSs are good at, like data analysis and reporting, data mining, set-based queries, and so on. But they are good for OO data storage.


- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Post #1400700
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse