Autor Beitrag
NOS1971
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 193

Windows 8.1 PRO 64 Bit
Delphi XE7 Professional
BeitragVerfasst: Sa 08.03.14 13:50 
Hallo zusammen,

dank einiger Tipps von Euch habe ich es soweit hinbekommen das zumindest schon einmal parallel meine Daten aus der URL Analyse in der DB landen ... doch in der Strukturierung der DB habe ich ein paar Probleme ... In meiner ursprünglichen Klasse habe ich die normalen Daten der URL in Variablen gehabt und zum Beispiel eine Liste der H Tags als TStringList oder eine Liste der PartneSites als TStringlist ... Wie bekomme ich nun eine Art TStringlist oder eine Vergleichbare Datenstruktur in einen Datensatz einer Tabelle ?

Hier mal meine ursprüngliche Klasse

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
  // WebURLDataItem class
  TWebURLDataItem = packed class
  strict private
    var
     FOrigURLString: string;
     FPageRank: integer;
     FAnalysed: integer;
     FURLLinkString: string;
     FHTTPStatus: integer;
     FURLType: integer;
     FExternalLinks: integer;
     FInLinks : integer;
     FRootURL: string;
     FURLString: string;
     FContentLength: int64;
     FInternalLinks: integer;
     FNeededAnalysisTime: int64;
     FServer: string;
     FContentType: string;
     FIsFeed: integer;
     FURLLocation: integer;
     FCharSet: string;
     FDate: extended;
     FURLExtension: string;
     FURLText : string;
     FRetryCount: integer;
     FConnectionStatusReport: TStringList;
     FParentSites: TStringList;
     FHTags: TStringList;
     FURLTags: TStringList;
     FRedirectList: TStringlist;
  public
    constructor Create;
    destructor Destroy; override;
    property RootURL: string read FRootURL write FRootURL; // root url of analysis
    property URLString: string read FURLString write FURLString; // url
    property OrigURLString: string read FOrigURLString write FOrigURLString; // orig url string
    property URLLinkString: string read FURLLinkString write FURLLinkString; // link wich contains the url
    property URLType: integer read FURLType write FURLType; // url type
    property Analysed: integer read FAnalysed write FAnalysed; // is the url analysed
    property HTTPStatus: integer read FHTTPStatus write FHTTPStatus; // url http status
    property PageRank: integer read FPageRank write FPageRank; // url pagerank
    property InternalLinks: integer read FInternalLinks write FInternalLinks; // internal links on url
    property ExternalLinks: integer read FExternalLinks write FExternalLinks; // external links on url
    property InLinks: integer read FInLinks write FInLinks; // links pointing to this url
    property ContentLength: int64 read FContentLength write FContentLength; // content length
    property ParentSites: TStringList read FParentSites write FParentSites; // list of parent items and data
    property HTags: TStringList read FHTags write FHTags; // list of h tags on site
    property URLTags: TStringList read FURLTags write FURLTags; // list of meta tags on site
    property NeededAnalysisTime: int64 read FNeededAnalysisTime write FNeededAnalysisTime; // needed analysis time
    property Server: string read FServer write FServer; // server information
    property ContentType: string read FContentType write FContentType; // content type
    property IsFeed: integer read FIsFeed write FIsFeed; // is it a feed or not
    property URLLocation: integer read FURLLocation write FURLLocation; // is the location to where the url points internal or external
    property CharSet: string read FCharSet write FCharSet; // site charset
    property Date: extended read FDate write FDate; // request date
    property URLExtension: string read FURLExtension write FURLExtension; // url file extension of a link
    property RetryCount: integer read FRetryCount write FRetryCount; // retries to get the source
    property URLText: string read FURLText write FURLText; // link text
    property RedirectList: TStringList read FRedirectList write FRedirectList; // list of redirects
    property ConnectionStatusReport: TStringList read FConnectionStatusReport; // list with the connectionstatus
  end;
  PWebURLDataItem = ^TWebURLDataItem;

Ich hoffe Ihr könnt mir hier das ein oder andere Stichwort dazu geben.

Grüße und Dank ins Forum,
Andreas
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Sa 08.03.14 14:16 
Ich bin nicht ganz sicher, ob ich das richtig verstanden habe, aber der Beschreibung nach scheint es sich um eine 1:n-Beziehung zu handeln, d.h. einem Datensatz in Tabelle A sind keiner, einer oder mehrere Datensätze aus Tabelle B zugeordnet (man spricht hier auch von Master/Detail). Das ist über Fremdschlüssel einfach lösbar:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Mastertabelle
=============
ID integer (PK autoinc)
weitere Daten

Detailtabelle
=============
ID integer (PK autoinc)
Master_ID (FK auf Mastertabelle.ID)
weitere Daten

Über die Fremdschlüssel (FK) lässt sich so ermitteln, welche Datensätze zu einem bestimmten Datensatz in der Mastertabelle gehören.
NOS1971 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 193

Windows 8.1 PRO 64 Bit
Delphi XE7 Professional
BeitragVerfasst: Sa 08.03.14 15:00 
Also das Problem ist das

der MasterDatensatz bis zu 500.000 mal vorkommen kann ..... jeder davon enthält eine völlig unterschiedliche anzahl von ParentSites, H-Tags etc. die mehr als nur ein detail haben .... also ist es nicht ganz 1 zu N wenn ich das als db rookie so richtig verstehe ...
WasWeißDennIch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 653
Erhaltene Danke: 160



BeitragVerfasst: Sa 08.03.14 15:16 
Es gibt je Mastersatz n Detailsätze, oder? Die Anzahl der Masterdatensätze spielt bei der Beziehung untereinander ja keine Rolle. Vielleicht mal ein paar Beispieldaten:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Mastertabelle:

ID | Daten
==========
 1 | AAAA
 2 | BBBB
 3 | CCCC
 4 | DDDD


Detailtabelle:

ID | MasterID | Daten
=====================
 1 | 1        | 123
 2 | 1        | 234
 3 | 2        | 987
 4 | 3        |  42 
 5 | 3        | 456
 6 | 3        | 123

Wir haben also 4 Masterdatensätze. Zu 1 gibt es zwei, zu 2 einen, zu 3 drei und zu 4 überhaupt keinen Detailsatz. Vielleicht solltest Du Dich zunächst in relationale Datenbanken und Normalisierung einlesen, sonst gibt das später nur Kummer, wenn Änderungen an der DB erfolgen sollen.
NOS1971 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 193

Windows 8.1 PRO 64 Bit
Delphi XE7 Professional
BeitragVerfasst: Sa 08.03.14 15:25 
Zunächst einmal danke für die Links ... ich denke ich sollte mich wirklich intensiver damit befassen bevor ich da weitermache und die details einbaue ...

So wie Du es dargestellt hast ist es vom Prinzip richtig .... bei den ParentSites ist es ja letzten endes so das ich quasi nur die id des datensatzes der mastertabelle speichern muss ... also habe ich quasi eine tabelle die die master id's mit den anderen verknüpft ...

ich sage erst einmal recht herzlichen Dank bis hierher und mache mich erstmal fitter mit DB's ...

Liebe Grüße,
Andreas