When should you consider representing a primary key ...?

When should I treat the primary key as classes ?

Should we only represent primary keys as classes when a table uses a composite key?

For instance:

public class PrimaryKey
    { ... ... ...}

Then

private PrimaryKey _parentID;
        public PrimaryKey ParentID
        {
            get { return _parentID; }
            set { _parentID = value; }
        }

and

public void Delete(PrimaryKey id)
        {...}

When should you consider saving data as comma-separated values ​​in a column of a database table, rather than storing them in different columns?

+3
source share
6 answers

When should I consider representing the table-id columns as classes?

It's much harder to answer without knowing the application architecture. If you use ORM like nhibernate or linq in sql, they will automatically create classes for you.

In the general case, if your primary key is composite and makes sense in your domain, create a class for it.

, .

, ( , , , ). , , - , , .

When should I consider storing data as comma-separated values in a column in a DB table rather than storing them in different columns?.

. normalized, . - , SQL.

+8

table-id ?

?

, , , ?

, .

+1

, ( ), (.. , , ) .

"" RDBMS: , // (-), , , .

+1

- . SQL -.

, 12 - , (-), 12 ; : , > 100 000,00 . "" 12 , , , .

, "" ... - .

, . : OPTION A OPTION B OPTION B OPTION C, . "B, C" "B C", , .

+1

, , " ", OR/M , .

+1

At first, not sure what you are looking for. I create business objects as classes that map to my data layer, which is usually data containing data.

The second question is never. There are very few situations where I will keep a comma-separated list instead of creating a normalized data structure.

0
source

Source: https://habr.com/ru/post/1735884/


All Articles